A game about forced loneliness, made by TACStudios
1using System;
2using System.Collections.Generic;
3using UnityEngine;
4
5namespace Unity.VisualScripting
6{
7#if MODULE_PARTICLE_SYSTEM_EXISTS
8 /// <summary>
9 /// Called when a particle hits a collider.
10 /// </summary>
11 [UnitCategory("Events/Physics")]
12 public sealed class OnParticleCollision : GameObjectEventUnit<GameObject>
13 {
14 public override Type MessageListenerType => typeof(UnityOnParticleCollisionMessageListener);
15 protected override string hookName => EventHooks.OnParticleCollision;
16
17 /// <summary>
18 /// A game object with an attached collider struck by the particle system.
19 /// </summary>
20 [DoNotSerialize]
21 public ValueOutput other { get; private set; }
22
23 /// <summary>
24 /// The particle collision events.
25 /// </summary>
26 [DoNotSerialize]
27 public ValueOutput collisionEvents { get; private set; }
28
29 protected override void Definition()
30 {
31 base.Definition();
32
33 other = ValueOutput<GameObject>(nameof(other));
34
35 collisionEvents = ValueOutput<List<ParticleCollisionEvent>>(nameof(collisionEvents));
36 }
37
38 protected override void AssignArguments(Flow flow, GameObject other)
39 {
40 flow.SetValue(this.other, other);
41
42 var collisionEvents = new List<ParticleCollisionEvent>();
43
44 var data = flow.stack.GetElementData<Data>(this);
45
46 data.target.GetComponent<ParticleSystem>().GetCollisionEvents(other, collisionEvents);
47
48 flow.SetValue(this.collisionEvents, collisionEvents);
49 }
50 }
51#endif
52}