|
class ActionBaseCB : HumanCommandActionCallback |
|
{ |
|
protected ActionData m_ActionData; |
|
protected SoundOnVehicle m_SoundObject; |
|
protected bool m_Canceled; |
|
protected bool m_Interrupted; |
|
|
|
|
|
void ActionBaseCB() |
|
{ |
|
} |
|
|
|
int GetPossileStanceMask() |
|
{ |
|
return m_ActionData.m_PossibleStanceMask; |
|
} |
|
|
|
|
|
override void OnFinish(bool pCanceled) |
|
{ |
|
if ( LogManager.IsActionLogEnable() ) |
|
{ |
|
if ( m_ActionData) |
|
Debug.ActionLog("Time stamp: " + m_ActionData.m_Player.GetSimulationTimeStamp(), m_ActionData.m_Action.ToString() , "n/a", "OnFinish", m_ActionData.m_Player.ToString() ); |
|
else |
|
Debug.ActionLog("n/a", this.ToString() , "n/a", "OnFinish", "n/a" ); |
|
} |
|
if ( m_SoundObject ) |
|
{ |
|
GetGame().ObjectDelete(m_SoundObject); |
|
} |
|
if ( m_ActionData && m_ActionData.m_Player ) |
|
{ |
|
if ( pCanceled ) |
|
{ |
|
m_ActionData.m_State = m_ActionData.m_ActionComponent.Interrupt(m_ActionData); |
|
} |
|
|
|
AnimatedActionBase action = AnimatedActionBase.Cast(m_ActionData.m_Action); |
|
|
|
if(action) |
|
action.End(m_ActionData); |
|
} |
|
} |
|
|
|
void SetCommand( int command_uid ) |
|
{ |
|
InternalCommand(command_uid); |
|
} |
|
|
|
|
|
|
|
void CreateActionComponent() |
|
{ |
|
m_ActionData.m_ActionComponent = new CADummy; |
|
} |
|
|
|
void InitActionComponent() |
|
{ |
|
} |
|
|
|
void ProgressActionComponent() |
|
{ |
|
if ( m_ActionData.m_ActionComponent ) |
|
{ |
|
m_ActionData.m_State = m_ActionData.m_ActionComponent.Execute(m_ActionData); |
|
} |
|
} |
|
|
|
void EndActionComponent() |
|
{ |
|
} |
|
|
|
|
|
void Interrupt() |
|
{ |
|
if ( GetGame().IsServer() ) |
|
{ |
|
if ( LogManager.IsActionLogEnable() ) |
|
{ |
|
Debug.ActionLog("n/a", this.ToString() , "n/a", "Interrupt", m_ActionData.m_Player.ToString() ); |
|
} |
|
if ( GetGame().IsMultiplayer() ) |
|
{ |
|
DayZPlayerSyncJunctures.SendActionInterrupt(m_ActionData.m_Player); |
|
} |
|
} |
|
else |
|
{ |
|
if (ScriptInputUserData.CanStoreInputUserData()) |
|
{ |
|
ScriptInputUserData ctx = new ScriptInputUserData; |
|
ctx.Write(INPUT_UDT_STANDARD_ACTION_END_REQUEST); |
|
ctx.Write(DayZPlayerConstants.CMD_ACTIONINT_INTERRUPT); |
|
ctx.Send(); |
|
} |
|
} |
|
m_Interrupted = true; |
|
} |
|
|
|
void SetActionData(ActionData action_data ) |
|
{ |
|
m_ActionData = action_data; |
|
} |
|
|
|
override bool IsUserActionCallback() |
|
{ |
|
return true; |
|
} |
|
|
|
float GetActionComponentProgress() |
|
{ |
|
if ( m_ActionData.m_ActionComponent ) |
|
{ |
|
return m_ActionData.m_ActionComponent.GetProgress(); |
|
} |
|
return 0; |
|
} |
|
|
|
int GetActionState() |
|
{ |
|
return m_ActionData.m_State; |
|
} |
|
|
|
ActionTarget GetTarget() |
|
{ |
|
return m_ActionData.m_Target; |
|
} |
|
}; |
|
|
|
|
|
|
|
class AnimatedActionBase : ActionBase |
|
{ |
|
protected int m_CommandUID; |
|
protected int m_CommandUIDProne; |
|
protected typename m_CallbackClass; |
|
|
|
|
|
|
|
|
|
|
|
void AnimatedActionBase() |
|
{ |
|
|
|
m_CallbackClass = ActionBaseCB; |
|
} |
|
|
|
protected void OnAlternativeEndServer( PlayerBase player ) |
|
{ |
|
} |
|
protected void OnAlternativeEndClient( PlayerBase player ) |
|
{ |
|
} |
|
|
|
protected void OnInterruptServer( PlayerBase player ) |
|
{ |
|
} |
|
protected void OnInterruptClient( PlayerBase player ) |
|
{ |
|
} |
|
|
|
protected void OnExecute( ActionData action_data ) |
|
{ |
|
} |
|
|
|
protected void OnExecuteServer( ActionData action_data ) |
|
{ |
|
} |
|
|
|
protected void OnExecuteClient( ActionData action_data ) |
|
{ |
|
} |
|
|
|
|
|
void OnAnimationEvent( ActionData action_data ) |
|
{ |
|
if (action_data && !action_data.m_WasExecuted) |
|
{ |
|
ActionBase action = action_data.m_Action; |
|
|
|
if (action && ( !action.UseMainItem() || action_data.m_MainItem ) && ( !action.HasTarget() || action_data.m_Target )) |
|
{ |
|
if ( LogManager.IsActionLogEnable() ) |
|
{ |
|
Debug.ActionLog("Time stamp: " + action_data.m_Player.GetSimulationTimeStamp(), this.ToString() , "n/a", "OnExecute", action_data.m_Player.ToString() ); |
|
} |
|
OnExecute(action_data); |
|
|
|
if (GetGame().IsServer()) |
|
OnExecuteServer(action_data); |
|
else |
|
OnExecuteClient(action_data); |
|
|
|
action_data.m_WasExecuted = true; |
|
action_data.m_WasActionStarted = true; |
|
} |
|
} |
|
} |
|
|
|
override bool ActionConditionContinue( ActionData action_data ) |
|
{ |
|
return ActionCondition(action_data.m_Player,action_data.m_Target,action_data.m_MainItem); |
|
} |
|
|
|
override bool ActionCondition( PlayerBase player, ActionTarget target, ItemBase item ) |
|
{ |
|
return true; |
|
} |
|
|
|
|
|
protected int GetActionCommand( PlayerBase player ) |
|
{ |
|
if ( HasProneException() ) |
|
{ |
|
if ( player.IsPlayerInStance(DayZPlayerConstants.STANCEMASK_CROUCH | DayZPlayerConstants.STANCEMASK_ERECT)) |
|
return m_CommandUID; |
|
else |
|
return m_CommandUIDProne; |
|
} |
|
return m_CommandUID; |
|
} |
|
|
|
protected typename GetCallbackClassTypename() |
|
{ |
|
return m_CallbackClass; |
|
} |
|
|
|
|
|
override bool HasProneException() |
|
{ |
|
return false; |
|
} |
|
|
|
|
|
protected void CreateAndSetupActionCallback( ActionData action_data ) |
|
{ |
|
|
|
ActionBaseCB callback; |
|
if ( IsFullBody(action_data.m_Player) ) |
|
{ |
|
Class.CastTo(callback, action_data.m_Player.StartCommand_Action(GetActionCommand(action_data.m_Player),GetCallbackClassTypename(),GetStanceMask(action_data.m_Player))); |
|
|
|
} |
|
else |
|
{ |
|
Class.CastTo(callback, action_data.m_Player.AddCommandModifier_Action(GetActionCommand(action_data.m_Player),GetCallbackClassTypename())); |
|
|
|
|
|
} |
|
callback.SetActionData(action_data); |
|
callback.InitActionComponent(); |
|
action_data.m_Callback = callback; |
|
} |
|
|
|
|
|
|
|
|
|
|
|
override void Start( ActionData action_data ) |
|
{ |
|
super.Start( action_data ); |
|
|
|
|
|
if( !IsInstant() ) |
|
{ |
|
CreateAndSetupActionCallback(action_data); |
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
override void Interrupt( ActionData action_data ) |
|
{ |
|
if ( action_data.m_Callback ) |
|
{ |
|
action_data.m_Callback.Cancel(); |
|
} |
|
else |
|
{ |
|
End( action_data ); |
|
} |
|
} |
|
|
|
void OnJumpStart() |
|
{ |
|
|
|
} |
|
|
|
|
|
void Do( ActionData action_data, int state ) |
|
{ |
|
if ( state == UA_ERROR || !action_data.m_Callback || !action_data.m_Player || !action_data.m_ActionComponent ) |
|
{ |
|
#ifdef DIAG_DEVELOPER |
|
if ( LogManager.IsActionLogEnable() ) |
|
{ |
|
Debug.ActionLog("ABRUPT CANCEL, CONDITIONS NOT MET", this.ToString() , "n/a", "Do", action_data.m_Player.ToString() ); |
|
} |
|
#endif |
|
if ( action_data.m_Callback && action_data.m_Player ) |
|
{ |
|
action_data.m_Callback.Interrupt(); |
|
} |
|
else |
|
{ |
|
Debug.ActionLog("PLAYER LOST", this.ToString() , "n/a", "Do", action_data.m_Player.ToString() ); |
|
} |
|
} |
|
else |
|
{ |
|
switch ( state ) |
|
{ |
|
case UA_PROCESSING: |
|
if ( CanContinue(action_data) ) |
|
{ |
|
action_data.m_Callback.ProgressActionComponent(); |
|
InformPlayers(action_data.m_Player, action_data.m_Target, UA_PROCESSING); |
|
} |
|
else |
|
{ |
|
action_data.m_Callback.Interrupt(); |
|
InformPlayers(action_data.m_Player, action_data.m_Target, UA_CANCEL); |
|
Do(action_data, UA_CANCEL); |
|
} |
|
break; |
|
|
|
case UA_FINISHED: |
|
InformPlayers(action_data.m_Player,action_data.m_Target,UA_FINISHED); |
|
action_data.m_Callback.EndActionComponent(); |
|
break; |
|
|
|
case UA_CANCEL: |
|
InformPlayers(action_data.m_Player,action_data.m_Target,UA_CANCEL); |
|
action_data.m_Callback.EndActionComponent(); |
|
break; |
|
|
|
case UA_INITIALIZE: |
|
if ( !CanContinue(action_data) ) |
|
{ |
|
action_data.m_Callback.Interrupt(); |
|
InformPlayers(action_data.m_Player, action_data.m_Target, UA_CANCEL); |
|
Do(action_data, UA_CANCEL); |
|
} |
|
default: |
|
Debug.ActionLog("Action component returned wrong value", this.ToString() , "n/a", "Do", action_data.m_Player.ToString() ); |
|
action_data.m_Callback.Interrupt(); |
|
break; |
|
} |
|
} |
|
} |
|
|
|
|
|
override void End( ActionData action_data ) |
|
{ |
|
if ( action_data.m_Player ) |
|
{ |
|
if ( GetGame().IsServer() ) |
|
{ |
|
OnEndServer(action_data); |
|
action_data.m_Player.SetSoundCategoryHash(0); |
|
} |
|
else |
|
{ |
|
OnEndClient(action_data); |
|
} |
|
OnEnd(action_data); |
|
|
|
|
|
if ( action_data.m_WasActionStarted ) |
|
{ |
|
if ( IsEat() ) |
|
{ |
|
GetGame().GetAnalyticsClient().OnActionEat(); |
|
} |
|
else if ( IsDrink() ) |
|
{ |
|
GetGame().GetAnalyticsClient().OnActionDrink(); |
|
} |
|
|
|
action_data.m_WasActionStarted = false; |
|
} |
|
|
|
action_data.m_Player.GetActionManager().OnActionEnd(); |
|
|
|
|
|
} |
|
else |
|
{ |
|
if ( LogManager.IsActionLogEnable() ) |
|
{ |
|
Debug.ActionLog("Ation could not be finished right at the end", this.ToString() , "n/a", "End", action_data.m_Player.ToString() ); |
|
} |
|
action_data.m_Callback.Interrupt(); |
|
} |
|
} |
|
|
|
override float GetProgress( ActionData action_data ) |
|
{ |
|
if ( action_data.m_ActionComponent ) |
|
{ |
|
return action_data.m_ActionComponent.GetProgress(); |
|
} |
|
return 0; |
|
} |
|
}; |