Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_CharacterAnimationEventCinematicTrack.c
Go to the documentation of this file.
1[CinematicTrackAttribute(name:"Character Animation Event Track", description:"Uses character animation events to do stuff")]
3{
4 static const string EVENT_NAME_SIGNAL = "SignalCinematicTimeline";
5 static const string EVENT_NAME_SOUND = "SoundCinematicTimeline";
6
7 [Attribute("")]
8 protected string m_sSourceEntityName;
9
10 [Attribute("")]
11 protected bool m_bUsePlayerCharacter;
12
13 [Attribute("")]
14 protected string m_sTargerEntityName;
15
16 bool m_bIsFirstFrame = true;
17
18 //------------------------------------------------------------------------------------------------
25 protected void OnAnimationEvent(AnimationEventID animEventType, AnimationEventID animUserString, int intParam, float timeFromStart, float timeToEnd)
26 {
27 const string eventName = GameAnimationUtils.GetEventString(animEventType);
28
29 // Sets signal on animation event
30 // animUserString = signal name
31 // intParam = signal value
32 if (eventName == EVENT_NAME_SIGNAL)
33 {
35 if (!entity)
36 {
37 return;
38 }
39
41 if (!signalsManagerComponent)
42 {
43 return;
44 }
45
46 const string signalName = GameAnimationUtils.GetEventString(animUserString);
47 signalsManagerComponent.SetSignalValue(signalsManagerComponent.AddOrFindSignal(signalName), intParam);
48 }
49 // Plays sound on linked entity
50 // animUserString = sound event name
51 else if(eventName == EVENT_NAME_SOUND)
52 {
54 if (!entity)
55 {
56 return;
57 }
58
59 SoundComponent soundComponent = SoundComponent.Cast(entity.FindComponent(SoundComponent));
60 if (!soundComponent)
61 {
62 return;
63 }
64
65 const string soundEventName = GameAnimationUtils.GetEventString(animUserString);
66 soundComponent.SoundEvent(soundEventName);
67 }
68 }
69
71 {
73 {
74 PlayerController playerController = GetGame().GetPlayerController();
75 if (!playerController)
76 {
77 return null;
78 }
79
80 return playerController.GetControlledEntity();
81 }
82 else
83 {
85 }
86 }
87
88 override void OnApply(float time)
89 {
90 super.OnApply(time);
91
93 {
94 // Register to OnAnimation event
95 const IEntity sourceEntity = GetSourceEntity();
96 if (!sourceEntity)
97 {
98 return;
99 }
100
101 const SCR_ChimeraCharacter chimeraCharacter = SCR_ChimeraCharacter.Cast(sourceEntity);
102 if (!chimeraCharacter)
103 {
104 return;
105 }
106
107 SCR_CharacterControllerComponent characterController = SCR_CharacterControllerComponent.Cast(chimeraCharacter.FindComponent(SCR_CharacterControllerComponent));
108 if (!characterController)
109 {
110 return;
111 }
112
113 characterController.GetOnAnimationEvent().Insert(OnAnimationEvent);
114
115 m_bIsFirstFrame = false;
116 }
117 }
118
119 override void OnFinish()
120 {
121 super.OnFinish();
122
123 // Unregister OnAnimation event
124 const IEntity sourceEntity = GetSourceEntity();
125 if (!sourceEntity)
126 {
127 return;
128 }
129
130 const SCR_ChimeraCharacter chimeraCharacter = SCR_ChimeraCharacter.Cast(sourceEntity);
131 if (!chimeraCharacter)
132 {
133 return;
134 }
135
136 SCR_CharacterControllerComponent characterController = SCR_CharacterControllerComponent.Cast(chimeraCharacter.FindComponent(SCR_CharacterControllerComponent));
137 if (!characterController)
138 {
139 return;
140 }
141
142 characterController.GetOnAnimationEvent().Remove(OnAnimationEvent);
143 }
144}
int AnimationEventID
ArmaReforgerScripted GetGame()
Definition game.c:1398
proto external Managed FindComponent(typename typeName)
void OnAnimationEvent(AnimationEventID animEventType, AnimationEventID animUserString, int intParam, float timeFromStart, float timeToEnd)
SCR_FieldOfViewSettings Attribute