Dayz Explorer  1.24.157551 (v105080)
Dayz Code Explorer by Zeroy
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  {
14  ActionContinuousBase actionS = ActionContinuousBase.Cast(m_ActionData.m_Action);
15  if ( m_ActionData.m_State == UA_INITIALIZE )
16  {
17  actionS.OnStartAnimationLoop( m_ActionData );
18  m_ActionData.m_State = UA_PROCESSING;
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  {
27  ActionContinuousBase actionE = ActionContinuousBase.Cast(m_ActionData.m_Action);
28  actionE.OnEndAnimationLoop( m_ActionData );
29  m_callLoopEnd = false;
30  }
31  return DefaultCancelCondition();
32  }
33 
34 
35  override void OnAnimationEvent(int pEventID)
36  {
37  if ( m_ActionData && m_ActionData.m_Action )
38  {
39  AnimatedActionBase action = AnimatedActionBase.Cast(m_ActionData.m_Action);
40 #ifdef DEVELOPER
41  //Print("ActionInteractBase.c | OnAnimationEvent | OnAnimationEvent called");
42 #endif
43 
44  if ( LogManager.IsActionLogEnable() )
45  {
46  Debug.ActionLog("Time stamp: " + m_ActionData.m_Player.GetSimulationTimeStamp() + " / " + pEventID, this.ToString() , "n/a", "OnAnimationEvent", m_ActionData.m_Player.ToString() );
47  }
48 
49  if ( !m_Interrupted && pEventID == UA_IN_START )
50  {
51  m_inLoop = true;
52  //ActionContinuousBase.Cast(action).OnStartLoop( m_ActionData );
53  }
54  else if ( !m_Interrupted && pEventID == UA_IN_END )
55  {
56 
57  m_inLoop = false;
58  //ActionContinuousBase.Cast(action).OnCompleteLoop( m_ActionData );
59  }
60  else if ( !m_Interrupted && pEventID == UA_ANIM_EVENT )
61  {
62  action.OnAnimationEvent( m_ActionData );
63  //action.OnCompleteLoop( m_ActionData );
64  }
65  }
66  else
67  {
68  //Debug.LogError("Call OnAnimationEvent ")
69  }
70  }
71 
72  override void InitActionComponent()
73  {
74  m_Interrupted = false;
75  m_Canceled = false;
76  m_inLoop = false;
77 
79  if ( m_ActionData.m_ActionComponent )
80  {
81  m_ActionData.m_ActionComponent.Init(m_ActionData);
82  }
83  m_ActionData.m_State = UA_INITIALIZE;
84  RegisterAnimationEvent("ActionExecStart", UA_IN_START);
85  RegisterAnimationEvent("ActionExecEnd", UA_IN_END);
88  m_SoundObject = m_ActionData.m_Action.PlayActionSound(m_ActionData.m_Player);
89  }
90 
91  override void EndActionComponent()
92  {
93  // TODO for second type animation SetCommand(DayZPlayerConstants.CMD_ACTIONINT_FINISH);
94  if ( m_ActionData.m_State == UA_FINISHED )
95  {
96  SetCommand(DayZPlayerConstants.CMD_ACTIONINT_END);
97  }
98  else if (m_ActionData.m_State == UA_CANCEL )
99  {
100  ActionContinuousBase action = ActionContinuousBase.Cast(m_ActionData.m_Action);
101  if(action.HasAlternativeInterrupt())
102  {
103  SetCommand(DayZPlayerConstants.CMD_ACTIONINT_FINISH);
104  }
105  else
106  {
107  SetCommand(DayZPlayerConstants.CMD_ACTIONINT_END);
108  }
109  m_Canceled = true;
110  return;
111  //Cancel();
112  }
113  else
114  {
115  m_Canceled = true;
116  SetCommand(DayZPlayerConstants.CMD_ACTIONINT_END);
117  return;
118  }
119  m_ActionData.m_State = UA_FINISHED;
120  }
121 
122  void UserEndsAction()
123  {
124  if ( m_ActionData.m_ActionComponent )
125  {
126  m_ActionData.m_State = m_ActionData.m_ActionComponent.Cancel(m_ActionData);
127  }
128  EndActionComponent();
129  }
130 };
131 
133 {
134  PluginAdminLog m_AdminLog;
135 
136  void ActionContinuousBase()
137  {
138  m_CallbackClass = ActionContinuousBaseCB;
139  m_CommandUID = DayZPlayerConstants.CMD_ACTIONMOD_EAT;
140 
141  if( GetGame() && GetGame().IsServer() )
142  {
143  m_AdminLog = PluginAdminLog.Cast( GetPlugin(PluginAdminLog) );
144  }
145  }
146 
147  override void OnEndInput( ActionData action_data )
148  {
149  ActionContinuousBaseCB callback;
150  if( Class.CastTo(callback, action_data.m_Callback) )
151  {
152  if ( callback.GetState() != callback.STATE_LOOP_END && callback.GetState() != callback.STATE_LOOP_END2 )
153  {
154  callback.UserEndsAction();
155  }
156  }
157  }
158 
159  bool HasAlternativeInterrupt()
160  {
161  return false;
162  }
163 
164  override typename GetInputType()
165  {
167  }
168 
169  override int GetActionCategory()
170  {
171  return AC_CONTINUOUS;
172  }
173 
174  void OnStartAnimationLoop( ActionData action_data )
175  {
176  if ( LogManager.IsActionLogEnable() )
177  {
178  Debug.ActionLog("Time stamp: " + action_data.m_Player.GetSimulationTimeStamp(), this.ToString() , "n/a", "OnStartAnimationLoop", action_data.m_Player.ToString() );
179  }
180 
181  if (GetGame().IsServer())
182  {
183  OnStartAnimationLoopServer(action_data);
184  }
185  else
186  {
187  OnStartAnimationLoopClient(action_data);
188  }
189  action_data.m_WasExecuted = false;
190  }
191 
192  void OnEndAnimationLoop( ActionData action_data )
193  {
194  if ( LogManager.IsActionLogEnable() )
195  {
196  Debug.ActionLog("Time stamp: " + action_data.m_Player.GetSimulationTimeStamp(), this.ToString() , "n/a", "OnEndAnimationLoop", action_data.m_Player.ToString() );
197  }
198  if (GetGame().IsServer())
199  {
200  OnEndAnimationLoopServer(action_data);
201  }
202  else
203  {
204  OnEndAnimationLoopClient(action_data);
205  }
206  action_data.m_WasExecuted = false;
207  }
208 
209  void OnFinishProgress( ActionData action_data )
210  {
211  if ( LogManager.IsActionLogEnable() )
212  {
213  Debug.ActionLog("Time stamp: " + action_data.m_Player.GetSimulationTimeStamp(), this.ToString() , "n/a", "OnFinishProgress", action_data.m_Player.ToString() );
214  }
215  if (GetGame().IsServer())
216  {
217  OnFinishProgressServer(action_data);
218 
219  if ( m_AdminLog )
220  {
221  m_AdminLog.OnContinouousAction( action_data );
222  }
223  }
224  else
225  {
226  OnFinishProgressClient(action_data);
227  }
228  action_data.m_WasExecuted = false;
229  }
230 
231 
232  protected void OnStartAnimationLoopServer( ActionData action_data ) //method called on start main animation loop (after in animation part )
233  {
234  action_data.m_WasActionStarted = true;
235  }
236 
237  protected void OnStartAnimationLoopClient( ActionData action_data ) //method called on start main animation loop (after in animation part )
238  {
239  action_data.m_WasActionStarted = true;
240  }
241 
242  protected void OnEndAnimationLoopServer( ActionData action_data ) //method called on finish main animation loop (before out animation part )
243  {
244  }
245  protected void OnEndAnimationLoopClient( ActionData action_data ) //method called on finish main animation loop (before out animation part )
246  {
247  }
248 
249  protected void OnFinishProgressServer( ActionData action_data )
250  {
251  }
252 
253  protected void OnFinishProgressClient( ActionData action_data )
254  {
255  }
256 };
GetGame
proto native CGame GetGame()
LogManager
Definition: debug.c:734
GetState
proto native int GetState()
returns one of STATE_...
Definition: staminahandler.c:29
UA_IN_START
const int UA_IN_START
Definition: constants.c:449
UA_ANIM_EVENT
const int UA_ANIM_EVENT
Definition: constants.c:443
EnableCancelCondition
proto native void EnableCancelCondition(bool pEnable)
AC_CONTINUOUS
const int AC_CONTINUOUS
Definition: _constants.c:3
m_AdminLog
PluginAdminLog m_AdminLog
Definition: emotemanager.c:150
UA_CANCEL
const int UA_CANCEL
Definition: constants.c:437
AnimatedActionBase
Definition: animatedactionbase.c:133
GetPlugin
PluginBase GetPlugin(typename plugin_type)
Definition: pluginmanager.c:316
m_Canceled
bool m_Canceled
Definition: smptanimmeta.c:16
UA_FINISHED
const int UA_FINISHED
Definition: constants.c:436
ActionData
Definition: actionbase.c:20
DefaultCancelCondition
proto native bool DefaultCancelCondition()
system implemented cancel condition (now raise or sprint cancels action)
RegisterAnimationEvent
class DayZCreatureAnimInterface RegisterAnimationEvent(string event_name, string function_name)
DayZPlayerConstants
DayZPlayerConstants
defined in C++
Definition: dayzplayer.c:601
UA_INITIALIZE
const int UA_INITIALIZE
Definition: constants.c:444
m_Interrupted
bool m_Interrupted
Definition: actionmanagerbase.c:49
ActionContinuousBaseCB
Definition: actioncontinuousbase.c:1
CreateActionComponent
ActionEmptyMagazine CreateActionComponent
Definition: actionemptymagazine.c:8
Debug
Definition: debug.c:13
UA_PROCESSING
const int UA_PROCESSING
Definition: constants.c:434
ActionContinuousBase
Definition: actioncontinuousbase.c:132
ActionBaseCB
Definition: animatedactionbase.c:1
Class
Super root of all classes in Enforce script.
Definition: enscript.c:10
UA_IN_END
const int UA_IN_END
Definition: constants.c:450
ContinuousDefaultActionInput
void ContinuousDefaultActionInput(PlayerBase player)
Definition: actioninput.c:606