DayZ Scripts
PC Stable Documentation
 
Loading...
Searching...
No Matches
HFSMBase< WeaponStateBase, WeaponEventBase, WeaponActionBase, WeaponGuardBase > Class Reference

Private Member Functions

protected void SetInternalID (WeaponStateBase state)
 unique list of states in this machine (automation of save/load)
 
override void AddTransition (FSMTransition< WeaponStateBase, WeaponEventBase, WeaponActionBase, WeaponGuardBase > t)
 adds transition into transition table As a side effect registers the state(s) into m_UniqueStates
 
override protected ProcessEventResult ProcessLocalTransition (FSMTransition< WeaponStateBase, WeaponEventBase, WeaponActionBase, WeaponGuardBase > t, WeaponEventBase e)
 
override protected ProcessEventResult ProcessAbortTransition (FSMTransition< WeaponStateBase, WeaponEventBase, WeaponActionBase, WeaponGuardBase > t, WeaponEventBase e)
 
override WeaponStateBase ProcessAbortEvent (WeaponEventBase e, out ProcessEventResult result)
 
override ProcessEventResult ProcessEvent (WeaponEventBase e)
 
WeaponStateBase FindStateForInternalID (int id)
 retrieve base state that matches given internal id
 
WeaponStableState FindStableStateForID (int id)
 load from database - reverse lookup for state from saved id
 
protected bool LoadAndSetCurrentFSMState (ParamsReadContext ctx, int version)
 
bool LoadCurrentFSMState (ParamsReadContext ctx, int version)
 load current state of fsm
 
bool LoadCurrentUnstableFSMState (ParamsWriteContext ctx, int version)
 
bool SaveCurrentFSMState (ParamsWriteContext ctx)
 save current state of fsm
 
bool SaveCurrentUnstableFSMState (ParamsWriteContext ctx)
 
void ValidateAndRepair ()
 validate the state of the gun and repair if mismatch
 
protected bool Internal_ValidateAndRepair ()
 validate the state of the gun and repair if mismatch
 
protected bool ValidateAndRepairHelper (Weapon_Base weapon, string name, bool stateCondition, bool gunCondition, WeaponEventBase e1, WeaponEventBase e2, out WeaponStableState state)
 
protected void OnFailThresholdBreached (Weapon weapon, string name, bool stateCondition, bool gunCondition)
 
protected WeaponStableState ValidateAndRepairStateFinder (bool condition, WeaponEventBase e1, WeaponEventBase e2, WeaponStableState state)
 
bool OnStoreLoad (ParamsReadContext ctx, int version)
 load state of fsm
 
int GetCurrentStableStateID ()
 
int GetInternalStateID ()
 
void OnStoreSave (ParamsWriteContext ctx)
 save state of fsm
 
void RandomizeFSMState (bool hasBullet, bool hasMagazine, bool isJammed)
 Deprecated, use RandomizeFSMStateEx for better results.
 
void RandomizeFSMStateEx (array< MuzzleState > muzzleStates, bool hasMagazine, bool isJammed)
 With the parameters given, selects a random suitable state for the FSM of the weapon @NOTE: It is better to use Weapon_Base.RandomizeFSMState instead of calling this one @WARNING: Weapon_Base.Synchronize call might be needed, if this method is called while clients are connected.
 

Private Attributes

private int m_SynchronizeAttempts
 
private int m_LastSynchronizeTime
 
protected int m_NextStateId = 0
 
protected ref array< WeaponStateBasem_UniqueStates = new array<WeaponStateBase>
 counter for InternalID: each state in a fsm is assigned an unique number
 

Static Private Attributes

static private const int MAX_SYNCHRONIZE_ATTEMPTS = 12
 
static private const int MIN_SYNCHRONIZE_INTERVAL = 3000
 
static private const int RESET_SYNCHRONIZE_THRESHOLD = 3600000
 

Member Function Documentation

◆ AddTransition()

adds transition into transition table As a side effect registers the state(s) into m_UniqueStates

◆ FindStableStateForID()

FindStableStateForID ( int  id)
inlineprivate

load from database - reverse lookup for state from saved id

Parameters
[in]idthe id stored in database during save

References WeaponStableState::GetCurrentStateID().

◆ FindStateForInternalID()

FindStateForInternalID ( int  id)
inlineprivate

retrieve base state that matches given internal id

Parameters
[in]idthe id stored in database during save

References WeaponStateBase::GetInternalStateID().

◆ GetCurrentStableStateID()

int GetCurrentStableStateID ( )
inlineprivate

◆ GetInternalStateID()

int GetInternalStateID ( )
inlineprivate

◆ Internal_ValidateAndRepair()

Internal_ValidateAndRepair ( )
inlineprivate

validate the state of the gun and repair if mismatch

Returns
bool whether it performed repairing or not

References WeaponStableState::HasMagazine(), WeaponStableState::IsJammed(), WeaponStableState::IsRepairEnabled(), and m_State.

◆ LoadAndSetCurrentFSMState()

protected bool LoadAndSetCurrentFSMState ( ParamsReadContext  ctx,
int  version 
)
inlineprivate

◆ LoadCurrentFSMState()

LoadCurrentFSMState ( ParamsReadContext  ctx,
int  version 
)
inlineprivate

load current state of fsm

References LogManager::IsWeaponLogEnable(), m_State, and wpnDebugSpam().

◆ LoadCurrentUnstableFSMState()

bool LoadCurrentUnstableFSMState ( ParamsWriteContext  ctx,
int  version 
)
inlineprivate

◆ OnFailThresholdBreached()

protected void OnFailThresholdBreached ( Weapon  weapon,
string  name,
bool  stateCondition,
bool  gunCondition 
)
inlineprivate

References Error(), m_State, and name.

◆ OnStoreLoad()

OnStoreLoad ( ParamsReadContext  ctx,
int  version 
)
inlineprivate

◆ OnStoreSave()

OnStoreSave ( ParamsWriteContext  ctx)
inlineprivate

◆ ProcessAbortEvent()

◆ ProcessAbortTransition()

◆ ProcessEvent()

◆ ProcessLocalTransition()

◆ RandomizeFSMState()

RandomizeFSMState ( bool  hasBullet,
bool  hasMagazine,
bool  isJammed 
)
inlineprivate

Deprecated, use RandomizeFSMStateEx for better results.

◆ RandomizeFSMStateEx()

RandomizeFSMStateEx ( array< MuzzleState muzzleStates,
bool  hasMagazine,
bool  isJammed 
)
inlineprivate

With the parameters given, selects a random suitable state for the FSM of the weapon @NOTE: It is better to use Weapon_Base.RandomizeFSMState instead of calling this one @WARNING: Weapon_Base.Synchronize call might be needed, if this method is called while clients are connected.

References ErrorEx, WeaponStableState::GetCurrentStateID(), WeaponStableState::HasMagazine(), INDEX_NOT_FOUND, WeaponStableState::IsJammed(), LogManager::IsWeaponLogEnable(), m_State, Math::RandomInt(), Start(), and wpnDebugPrint().

◆ SaveCurrentFSMState()

◆ SaveCurrentUnstableFSMState()

◆ SetInternalID()

protected void SetInternalID ( WeaponStateBase  state)
inlineprivate

unique list of states in this machine (automation of save/load)

References WeaponStateBase::GetInternalStateID(), and WeaponStateBase::SetInternalStateID().

◆ ValidateAndRepair()

ValidateAndRepair ( )
inlineprivate

validate the state of the gun and repair if mismatch

◆ ValidateAndRepairHelper()

protected bool ValidateAndRepairHelper ( Weapon_Base  weapon,
string  name,
bool  stateCondition,
bool  gunCondition,
WeaponEventBase  e1,
WeaponEventBase  e2,
out WeaponStableState  state 
)
inlineprivate

◆ ValidateAndRepairStateFinder()

protected WeaponStableState ValidateAndRepairStateFinder ( bool  condition,
WeaponEventBase  e1,
WeaponEventBase  e2,
WeaponStableState  state 
)
inlineprivate

Field Documentation

◆ m_LastSynchronizeTime

private int m_LastSynchronizeTime
private

◆ m_NextStateId

protected int m_NextStateId = 0
private

◆ m_SynchronizeAttempts

private int m_SynchronizeAttempts
private

◆ m_UniqueStates

protected ref array<WeaponStateBase> m_UniqueStates = new array<WeaponStateBase>
private

counter for InternalID: each state in a fsm is assigned an unique number

◆ MAX_SYNCHRONIZE_ATTEMPTS

private const int MAX_SYNCHRONIZE_ATTEMPTS = 12
staticprivate

◆ MIN_SYNCHRONIZE_INTERVAL

private const int MIN_SYNCHRONIZE_INTERVAL = 3000
staticprivate

◆ RESET_SYNCHRONIZE_THRESHOLD

private const int RESET_SYNCHRONIZE_THRESHOLD = 3600000
staticprivate

The documentation for this class was generated from the following file: