Dayz Explorer 1.28.160049
Loading...
Searching...
No Matches
actioncontinuousbase.c
Go to the documentation of this file.
2{
3 bool m_inLoop = false;
4 bool m_callLoopEnd = false;
5
6 bool CancelCondition()
7 {
8 if ( !m_ActionData )
9 {
10 return DefaultCancelCondition();
11 }
12 if ((GetState() == STATE_LOOP_LOOP || GetState() == STATE_LOOP_LOOP2 || m_inLoop) )
13 {
15 if ( m_ActionData.m_State == UA_INITIALIZE )
16 {
17 actionS.OnStartAnimationLoop( m_ActionData );
19 m_callLoopEnd = true;
20 }
21
22 if (!m_Interrupted)
23 actionS.Do(m_ActionData, m_ActionData.m_State);
24 }
25 else if (m_callLoopEnd == true)
26 {
28 actionE.OnEndAnimationLoop( m_ActionData );
29 m_callLoopEnd = false;
30 }
31 return DefaultCancelCondition();
32 }
33
34 void SetInLoop(bool value)
35 {
36 m_inLoop = value;
37 }
38
39 override void InitActionComponent()
40 {
41 m_Interrupted = false;
42 m_Canceled = false;
43 m_inLoop = false;
44
46 if ( m_ActionData.m_ActionComponent )
47 {
48 m_ActionData.m_ActionComponent.Init(m_ActionData);
49 }
51 RegisterAnimationEvent("ActionExecStart", UA_IN_START);
52 RegisterAnimationEvent("ActionExecEnd", UA_IN_END);
54 EnableCancelCondition(true);
55 m_SoundObject = m_ActionData.m_Action.PlayActionSound(m_ActionData.m_Player);
56 }
57
58 //TODO: consider this for general use
59 /*override void EndActionComponent()
60 {
61 ActionContinuousBase action = ActionContinuousBase.Cast(m_ActionData.m_Action);
62
63 if (m_ActionData.m_State != UA_FINISHED)
64 m_Canceled = true;
65
66 if (m_ActionData.m_State == UA_FINISHED || m_ActionData.m_State == UA_CANCEL)
67 {
68 if (action.UseAlternativeInterrupt(m_ActionData))
69 SetCommand(DayZPlayerConstants.CMD_ACTIONINT_FINISH);
70 else
71 SetCommand(DayZPlayerConstants.CMD_ACTIONINT_END);
72 }
73 else
74 {
75 SetCommand(DayZPlayerConstants.CMD_ACTIONINT_INTERRUPT);
76 }
77 }*/
78
79 override void EndActionComponent()
80 {
81 // TODO for second type animation SetCommand(DayZPlayerConstants.CMD_ACTIONINT_FINISH);
82 if ( m_ActionData.m_State == UA_FINISHED )
83 {
84 SetCommand(DayZPlayerConstants.CMD_ACTIONINT_END);
85 }
86 else if (m_ActionData.m_State == UA_CANCEL )
87 {
89 if(action.HasAlternativeInterrupt())
90 {
91 SetCommand(DayZPlayerConstants.CMD_ACTIONINT_FINISH);
92 }
93 else
94 {
95 SetCommand(DayZPlayerConstants.CMD_ACTIONINT_END);
96 }
97 m_Canceled = true;
98 return;
99 //Cancel();
100 }
101 else
102 {
103 m_Canceled = true;
104 SetCommand(DayZPlayerConstants.CMD_ACTIONINT_END);
105 return;
106 }
107 m_ActionData.m_State = UA_FINISHED;
108 }
109
110 void UserEndsAction()
111 {
112 if ( m_ActionData.m_ActionComponent )
113 {
114 m_ActionData.m_State = m_ActionData.m_ActionComponent.Cancel(m_ActionData);
115 }
116 //EndActionComponent(); //already handled in 'AnimatedActionBase::Do' on cancel
117 }
118};
119
121{
122 PluginAdminLog m_AdminLog;
123
125 {
127 m_CommandUID = DayZPlayerConstants.CMD_ACTIONMOD_EAT;
128
129 if( GetGame() && GetGame().IsServer() )
130 {
131 m_AdminLog = PluginAdminLog.Cast( GetPlugin(PluginAdminLog) );
132 }
133 }
134
135 override void OnEndInput( ActionData action_data )
136 {
137 ActionContinuousBaseCB callback;
138 if( Class.CastTo(callback, action_data.m_Callback) )
139 {
140 if ( callback.GetState() != callback.STATE_LOOP_END && callback.GetState() != callback.STATE_LOOP_END2 )
141 {
142 callback.UserEndsAction();
143 }
144 }
145 }
146
147 bool HasAlternativeInterrupt()
148 {
149 return false;
150 }
151
152 bool UseAlternativeInterrupt(ActionData action_data)
153 {
154 return false;
155 }
156
157 // lock default camera while performing the action
158 bool IsCameraLockOnPerform()
159 {
160 return true;
161 }
162
163 // camera up/down angle when performing a fullbody action
164 // values beetwen 0 and -90 (looking at ground) / 0 and 90 (looking above)
165 Vector2 GetCameraUDAngle()
166 {
167 Vector2 udAngle = new Vector2(-70, 45);
168 return udAngle;
169 }
170
171 // camera (heading) left/right angle when performing a fullbody action
172 // values beetwen 0 and -180 (left restriction) / 0 and 180 (right restriction)
173 Vector2 GetCameraLRAngle()
174 {
175 Vector2 lrAngle = new Vector2(-70, 70);
176 return lrAngle;
177 }
178
179 override typename GetInputType()
180 {
182 }
183
184 override int GetActionCategory()
185 {
186 return AC_CONTINUOUS;
187 }
188
189 override void OnAnimationEvent(ActionData action_data)
190 {
191 super.OnAnimationEvent(action_data);
192 ActionContinuousBaseCB callback;
193 if (Class.CastTo(callback, action_data.m_Callback))
194 {
195 if (action_data.m_DelayedAnimationEventID == UA_IN_START)
196 {
197 OnStartAnimationLoop(action_data);
198 callback.SetInLoop(true);
199 }
200 else if (action_data.m_DelayedAnimationEventID == UA_IN_END)
201 {
202 OnEndAnimationLoop(action_data);
203 callback.SetInLoop(false);
204 }
205 }
206 }
207
208 void OnStartAnimationLoop( ActionData action_data )
209 {
210 if ( LogManager.IsActionLogEnable() )
211 {
212 Debug.ActionLog("Time stamp: " + action_data.m_Player.GetSimulationTimeStamp(), this.ToString() , "n/a", "OnStartAnimationLoop", action_data.m_Player.ToString() );
213 }
214
215 if (GetGame().IsServer())
216 {
217 OnStartAnimationLoopServer(action_data);
218 }
219 else
220 {
221 OnStartAnimationLoopClient(action_data);
222 }
223 action_data.m_WasExecuted = false;
224 }
225
226 void OnEndAnimationLoop( ActionData action_data )
227 {
228 if ( LogManager.IsActionLogEnable() )
229 {
230 Debug.ActionLog("Time stamp: " + action_data.m_Player.GetSimulationTimeStamp(), this.ToString() , "n/a", "OnEndAnimationLoop", action_data.m_Player.ToString() );
231 }
232 if (GetGame().IsServer())
233 {
234 OnEndAnimationLoopServer(action_data);
235 }
236 else
237 {
238 OnEndAnimationLoopClient(action_data);
239 }
240 action_data.m_WasExecuted = false;
241 }
242
243 void OnFinishProgress( ActionData action_data )
244 {
245 if ( LogManager.IsActionLogEnable() )
246 {
247 Debug.ActionLog("Time stamp: " + action_data.m_Player.GetSimulationTimeStamp(), this.ToString() , "n/a", "OnFinishProgress", action_data.m_Player.ToString() );
248 }
249 if (GetGame().IsServer())
250 {
251 OnFinishProgressServer(action_data);
252
253 if ( m_AdminLog )
254 {
255 m_AdminLog.OnContinouousAction( action_data );
256 }
257 }
258 else
259 {
260 OnFinishProgressClient(action_data);
261 }
262 action_data.m_WasExecuted = false;
263 }
264
265
266 protected void OnStartAnimationLoopServer( ActionData action_data ) //method called on start main animation loop (after in animation part )
267 {
268 action_data.m_WasActionStarted = true;
269 }
270
271 protected void OnStartAnimationLoopClient( ActionData action_data ) //method called on start main animation loop (after in animation part )
272 {
273 action_data.m_WasActionStarted = true;
274 }
275
276 protected void OnEndAnimationLoopServer( ActionData action_data ) //method called on finish main animation loop (before out animation part )
277 {
278 }
279 protected void OnEndAnimationLoopClient( ActionData action_data ) //method called on finish main animation loop (before out animation part )
280 {
281 }
282
283 protected void OnFinishProgressServer( ActionData action_data )
284 {
285 }
286
287 protected void OnFinishProgressClient( ActionData action_data )
288 {
289 }
290};
const int AC_CONTINUOUS
Definition _constants.c:3
void ContinuousDefaultActionInput(PlayerBase player)
void CreateActionComponent()
void SetCommand(int command_uid)
SoundOnVehicle m_SoundObject
ActionData m_ActionData
void OnFinishProgressClient(ActionData action_data)
void OnEndAnimationLoopClient(ActionData action_data)
void OnStartAnimationLoopServer(ActionData action_data)
void OnFinishProgressServer(ActionData action_data)
void OnStartAnimationLoopClient(ActionData action_data)
void OnEndAnimationLoopServer(ActionData action_data)
Super root of all classes in Enforce script.
Definition enscript.c:11
Definition debug.c:2
class DayZCreatureAnimInterface RegisterAnimationEvent(string event_name, string function_name)
DayZPlayerConstants
defined in C++
Definition dayzplayer.c:602
PluginAdminLog m_AdminLog
proto native CGame GetGame()
const int UA_IN_START
Definition constants.c:479
const int UA_FINISHED
Definition constants.c:466
const int UA_INITIALIZE
Definition constants.c:474
const int UA_ANIM_EVENT
Definition constants.c:473
const int UA_IN_END
Definition constants.c:480
const int UA_PROCESSING
Definition constants.c:464
const int UA_CANCEL
Definition constants.c:467
PluginBase GetPlugin(typename plugin_type)