A game about forced loneliness, made by TACStudios
1using System.ComponentModel;
2using UnityEngine;
3
4namespace Unity.VisualScripting
5{
6#if MODULE_ANIMATION_EXISTS
7 /// <summary>
8 /// Called when an animation event points to TriggerAnimationEvent.
9 /// This version allows you to use the string parameter as the event name.
10 /// </summary>
11 [UnitCategory("Events/Animation")]
12 [UnitShortTitle("Animation Event")]
13 [UnitTitle("Named Animation Event")]
14 [TypeIcon(typeof(AnimationClip))]
15 [DisplayName("Visual Scripting Named Animation Event")]
16 public sealed class BoltNamedAnimationEvent : MachineEventUnit<AnimationEvent>
17 {
18 protected override string hookName => EventHooks.AnimationEvent;
19
20 /// <summary>
21 /// The name of the event. The event will only trigger if this value
22 /// is equal to the string parameter passed in the animation event.
23 /// </summary>
24 [DoNotSerialize]
25 [PortLabelHidden]
26 public ValueInput name { get; private set; }
27
28 /// <summary>
29 /// The float parameter passed to the event.
30 /// </summary>
31 [DoNotSerialize]
32 [PortLabel("Float")]
33 public ValueOutput floatParameter { get; private set; }
34
35 /// <summary>
36 /// The integer parameter passed to the function.
37 /// </summary>
38 [DoNotSerialize]
39 [PortLabel("Integer")]
40 public ValueOutput intParameter { get; private set; }
41
42 /// <summary>
43 /// The Unity object parameter passed to the function.
44 /// </summary>
45 [DoNotSerialize]
46 [PortLabel("Object")]
47 public ValueOutput objectReferenceParameter { get; private set; }
48
49 protected override void Definition()
50 {
51 base.Definition();
52
53 name = ValueInput(nameof(name), string.Empty);
54
55 floatParameter = ValueOutput<float>(nameof(floatParameter));
56 intParameter = ValueOutput<int>(nameof(intParameter));
57 objectReferenceParameter = ValueOutput<GameObject>(nameof(objectReferenceParameter));
58 }
59
60 protected override bool ShouldTrigger(Flow flow, AnimationEvent animationEvent)
61 {
62 return CompareNames(flow, name, animationEvent.stringParameter);
63 }
64
65 protected override void AssignArguments(Flow flow, AnimationEvent animationEvent)
66 {
67 flow.SetValue(floatParameter, animationEvent.floatParameter);
68 flow.SetValue(intParameter, animationEvent.intParameter);
69 flow.SetValue(objectReferenceParameter, animationEvent.objectReferenceParameter);
70 }
71 }
72#endif
73}