DIFF

class WeaponFSMSource

WeaponFSM HFSMBase

All members, including inherited

weapon finite state machine

Constants 3

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

ms

private static const int RESET_SYNCHRONIZE_THRESHOLD = 3600000

ms

Members 4

private int m_SynchronizeAttempts
private int m_LastSynchronizeTime
protected int m_NextStateId = 0

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

Referenced by SetInternalID()
protected ref array<WeaponStateBase> m_UniqueStates = new array<WeaponStateBase>

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

Methods 24

protected void SetInternalID(WeaponStateBase state)
Referenced by AddTransition()

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

Referenced by BoltActionRifle_ExternalMagazine_Base.InitStateMachine(), BoltActionRifle_InnerMagazine_Base.InitStateMachine(), ChamberFirst_InnerMagazine_SemiAutomatic_Base.InitStateMachine()
Show 41 more, ChamberMultiBullet.ChamberMultiBullet(), Crossbow_Base.InitStateMachine(), DoubleBarrel_Base.InitStateMachine(), Flaregun.InitStateMachine(), LoopedChambering.LoopedChambering(), LoopedChamberingCombineChamberInternalMagazine.LoopedChamberingCombineChamberInternalMagazine(), LoopedChamberingEjectLast.LoopedChamberingEjectLast(), Magnum_Base.InitStateMachine(), Mp133Shotgun_Base.InitStateMachine(), OpenBolt_Base.InitStateMachine(), Pistol_Base.InitStateMachine(), Repeater_Base.InitStateMachine(), Rifle_Base.InitStateMachine(), RifleBoltFree_Base.InitStateMachine(), RifleBoltLock_Base.InitStateMachine(), RifleChambering.RifleChambering(), RifleEjectCasing.RifleEjectCasing(), RifleReChambering.RifleReChambering(), RifleSingleShot_Base.InitStateMachine(), RifleSingleShotManual_Base.InitStateMachine(), SingleShotPistol_Base.InitStateMachine(), SKS_Base.InitStateMachine(), WeaponAttachMagazine.WeaponAttachMagazine(), WeaponAttachMagazineOpenBoltCharged.WeaponAttachMagazineOpenBoltCharged(), WeaponChambering.WeaponChambering(), WeaponCharging.WeaponCharging(), WeaponChargingInnerMag.WeaponChargingInnerMag(), WeaponChargingMultiple.WeaponChargingMultiple(), WeaponChargingStretch.WeaponChargingStretch(), WeaponDetachingMag.WeaponDetachingMag(), WeaponDetachingMagOpenBolt.WeaponDetachingMagOpenBolt(), WeaponEjectBullet.WeaponEjectBullet(), WeaponFireAndChamberNext.WeaponFireAndChamberNext(), WeaponFireAndChamberNextFromInnerMag.WeaponFireAndChamberNextFromInnerMag(), WeaponFireLast.WeaponFireLast(), WeaponMagnumChambering.WeaponMagnumChambering(), WeaponRechamber.WeaponRechamber(), WeaponReplacingMagAndChamberNext.WeaponReplacingMagAndChamberNext(), WeaponReplacingMagAndChamberNextOpenBoltCharged.WeaponReplacingMagAndChamberNextOpenBoltCharged(), WeaponStateBase.AddTransition(), and WeaponUnjamming.WeaponUnjamming()
References Action(), fsmDebugPrint(), HFSMBase.GetOwnerState()
Show 15 more, LogManager.IsInventoryHFSMLogEnable(), OnEntry(), OnStateChanged(), OnSubMachineChanged(), Class.ToString(), ToString(), ToString(), ToString(), ToString(), ValidateAndRepair(), FSMTransition.m_action, FSMTransition.m_dstState, FSMTransition.m_guard, FSMTransition.m_srcState, and HFSMBase.m_State
References Action(), fsmDebugPrint(), GetParentState()
Show 14 more, GetParentState(), LogManager.IsInventoryHFSMLogEnable(), OnEntry(), Class.ToString(), ToString(), ToString(), ToString(), ToString(), ValidateAndRepair(), FSMTransition.m_action, FSMTransition.m_dstState, FSMTransition.m_guard, FSMTransition.m_srcState, and HFSMBase.m_State
Referenced by ProcessAbortEvent()
WeaponStateBase FindStateForInternalID(int id)

retrieve base state that matches given internal id

in id
the id stored in database during save
References array.Count(), array.Get(), GetInternalStateID()
Show 1 more, m_UniqueStates
WeaponStableState FindStableStateForID(int id)

load from database - reverse lookup for state from saved id

in id
the id stored in database during save
Referenced by OnStoreLoad()
bool LoadCurrentFSMState(ParamsReadContext ctx, int version)

load current state of fsm

bool LoadCurrentUnstableFSMState(ParamsWriteContext ctx, int version)
References array.Count(), Error(), array.Get()
Show 6 more, GetInternalStateID(), LogManager.IsWeaponLogEnable(), LoadAndSetCurrentFSMState(), LoadCurrentFSMState(), wpnDebugSpam(), and m_UniqueStates
void ValidateAndRepair()

validate the state of the gun and repair if mismatch

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

tries to return identifier of current stable state

if the weapon is in stable state, i.e. not reloading, firing, detaching, ... than the identifier of the stable state is used directly. otherwise if the weapon is in unstable state, than the function uses abort information to determine the closest stable state that is coherent with weapon's state.

Returns: integer id that will be stored to database

int GetInternalStateID()

return internal identifier of current state

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