Dayz 1.25
Dayz Code Explorer by KGB
Загрузка...
Поиск...
Не найдено
Файл WeaponStableState.c

См. исходные тексты.

Перечисления

enum  MuzzleState { U = -1 , E = 0 , F = 1 , L = 2 }
 

Функции

void WeaponStableState (Weapon_Base w=NULL, WeaponStateBase parent=NULL, int anim_state=-1)
 
void SyncAnimState ()
 
override void OnEntry (WeaponEventBase e)
 
override void OnUpdate (float dt)
 
override void OnExit (WeaponEventBase e)
 
override bool IsIdle ()
 
int GetCurrentStateID ()
 
Weapon state properties

Properties defining the state in several properties for other systems Override these to set them up

Several systems depends on this: WeaponFSM.RandomizeFSMState, which picks out a suitable FSM state when attaching magazine through CE WeaponFSM.ValidateAndRepair, which will attempt to identify a desync and repair the FSM state if so

@WARNING So it is important to set these up correctly to prevent any desync of weapon FSM and actual wepon state

bool IsRepairEnabled ()
 Whether WeaponFSM.ValidateAndRepair should be applied on this state @NOTE: This property was implemented at the same time as ValARep To have it disabled by default In case there are modders who created their own state But potentially did not set up their properties correctly As having ValARep run on an improper setup would result in horrible VME spam and desync @WARNING: When enabling repair, it is imperative that all properties are set up correctly.
 
bool HasBullet ()
 Whether there is a bullet in the chamber @NOTE: This should only be false when it is empty So this is true when there is a bullet in the chamber Regardless of the bullet being loaded, firedout or jammed.
 
bool HasMagazine ()
 Whether there is a magazine attached.
 
bool IsJammed ()
 Whether the gun is jammed.
 
bool IsDischarged ()
 Whether the gun is discharged.
 
bool IsWeaponOpen ()
 Whether the gun is open.
 
void InitMuzzleArray ()
 Override with the filling of m_muzzleHasBullet.
 
bool IsSingleState ()
 Special one for when the weapon only has one singular state (like Magnum)
 
Weapon state properties helpers

Several helpers for better access of certain properties

MuzzleState GetMuzzleState (int idx)
 Get chamber state of the muzzle at index.
 
int GetMuzzleStateCount ()
 
bool IsChamberValid (int idx)
 
bool IsChamberFiredOut (int idx)
 
bool IsChamberFull (int idx)
 
void ValidateMuzzleArray ()
 Safety check and error message in case not set up correctly.
 

Переменные

enum MuzzleState m_animState
 
ref array< MuzzleStatem_muzzleHasBullet = new array<MuzzleState>()
 

Перечисления

◆ MuzzleState

Элементы перечислений

UNKNOWN.

EMPTY.

FIRED.

LOADED.

15{
17 U = -1,
19 E = 0,
21 F = 1,
23 L = 2
24}
@ E
EMPTY.
Definition WeaponStableState.c:19
@ U
UNKNOWN.
Definition WeaponStableState.c:17
@ L
LOADED.
Definition WeaponStableState.c:23
@ F
FIRED.
Definition WeaponStableState.c:21

Функции

◆ GetCurrentStateID()

int GetCurrentStateID ( )
93{ return 0; }

◆ GetMuzzleState()

MuzzleState GetMuzzleState ( int idx)

Get chamber state of the muzzle at index.

150{ return m_muzzleHasBullet[idx]; }
ref array< MuzzleState > m_muzzleHasBullet
Definition WeaponStableState.c:30
Definition EntityAI.c:95

Перекрестные ссылки m_muzzleHasBullet.

◆ GetMuzzleStateCount()

int GetMuzzleStateCount ( )
151{ return m_muzzleHasBullet.Count(); }

Перекрестные ссылки m_muzzleHasBullet.

◆ HasBullet()

bool HasBullet ( )

Whether there is a bullet in the chamber @NOTE: This should only be false when it is empty So this is true when there is a bullet in the chamber Regardless of the bullet being loaded, firedout or jammed.

122{ return false; }

◆ HasMagazine()

bool HasMagazine ( )

Whether there is a magazine attached.

125{ return false; }

◆ InitMuzzleArray()

void InitMuzzleArray ( )

Override with the filling of m_muzzleHasBullet.

MuzzleState
Definition WeaponStableState.c:15

Перекрестные ссылки m_muzzleHasBullet.

◆ IsChamberFiredOut()

◆ IsChamberFull()

◆ IsChamberValid()

bool IsChamberValid ( int idx)
152{ return m_muzzleHasBullet[idx] != MuzzleState.U; }

Перекрестные ссылки m_muzzleHasBullet.

◆ IsDischarged()

bool IsDischarged ( )

Whether the gun is discharged.

131{ return false; }

◆ IsIdle()

override bool IsIdle ( )
91{ return true; }

Используется в Weapon::CanRemoveFromHands() и ManBase::OnQuickBarSingleUse().

◆ IsJammed()

bool IsJammed ( )

Whether the gun is jammed.

128{ return false; }

◆ IsRepairEnabled()

bool IsRepairEnabled ( )

Whether WeaponFSM.ValidateAndRepair should be applied on this state @NOTE: This property was implemented at the same time as ValARep To have it disabled by default In case there are modders who created their own state But potentially did not set up their properties correctly As having ValARep run on an improper setup would result in horrible VME spam and desync @WARNING: When enabling repair, it is imperative that all properties are set up correctly.

115{ return false; }

◆ IsSingleState()

bool IsSingleState ( )

Special one for when the weapon only has one singular state (like Magnum)

140{ return false; }

Используется в ValidateMuzzleArray().

◆ IsWeaponOpen()

bool IsWeaponOpen ( )

Whether the gun is open.

134{ return false; }

◆ OnEntry()

73 {
74 super.OnEntry(e);
75 m_weapon.SetJammed(false);
76 if (e)
78 m_weapon.ResetWeaponAnimState();
79 }
class WeaponGuardIsDestroyed extends WeaponGuardBase m_weapon
Definition Guards.c:604
void SyncAnimState()
Definition WeaponStableState.c:39

Перекрестные ссылки m_weapon и SyncAnimState().

◆ OnExit()

86 {
87 m_weapon.ResetWeaponAnimState();
88 super.OnExit(e);
89 }

Перекрестные ссылки m_weapon.

◆ OnUpdate()

override void OnUpdate ( float dt)
81 {
82 super.OnUpdate(dt);
84 }

Перекрестные ссылки SyncAnimState().

◆ SyncAnimState()

void SyncAnimState ( )
40 {
41 int curr = m_weapon.GetWeaponAnimState();
42 if (curr != m_animState)
43 {
44 //if (LogManager.IsWeaponLogEnable()) fsmDebugSpam("[wpnfsm] " + Object.GetDebugName(m_weapon) + " synchronizing anim state: " + curr + " --> " + m_animState);
46 if (Class.CastTo(p, m_weapon.GetHierarchyParent()))
47 {
48 if (p.GetItemInHands() == m_weapon)
49 {
50 HumanCommandWeapons hcw = p.GetCommandModifier_Weapons();
51 if (hcw)
52 {
53 hcw.SetInitState(m_animState);
54 if (LogManager.IsWeaponLogEnable()) fsmDebugSpam("[wpnfsm] " + Object.GetDebugName(m_weapon) + " state=" + m_weapon.GetCurrentState().Type() + " synchronized anim state: " + typename.EnumToString(PistolAnimState, curr) + " --> " + typename.EnumToString(PistolAnimState, m_animState));
55 }
56 else
57 {
58 Human wpnOwner = Human.Cast(m_weapon.GetHierarchyRootPlayer());
60 if (LogManager.IsWeaponLogEnable()) fsmDebugSpam("[wpnfsm] " + Object.GetDebugName(m_weapon) + " state=" + m_weapon.GetCurrentState().Type() + " synchronized remote anim state: " + typename.EnumToString(PistolAnimState, curr) + " --> " + typename.EnumToString(PistolAnimState, m_animState));
61 }
62 }
63 m_weapon.SetWeaponAnimState(m_animState);
64 }
65 else
66 {
67 m_weapon.SetGroundAnimFrameIndex(m_animState);
68 }
69 }
70 }
void fsmDebugSpam(string s)
Definition HFSMBase.c:9
PistolAnimState
Definition Pistol_Base.c:3
enum MuzzleState m_animState
Super root of all classes in Enforce script.
Definition EnScript.c:11
Definition human.c:987
proto static native void StaticSetInitState(Human pHuman, int pFrameIdx)
just static version of SetInitState
Definition Debug.c:735
static bool IsWeaponLogEnable()
Definition Debug.c:859
Definition ObjectTyped.c:2
Definition PlayerBaseClient.c:2
static proto bool CastTo(out Class to, Class from)
Try to safely down-cast base class to child class.

Перекрестные ссылки Class::CastTo(), fsmDebugSpam(), LogManager::IsWeaponLogEnable(), m_animState, m_weapon и HumanCommandWeapons::StaticSetInitState().

Используется в HandStateBase::OnEntry(), OnEntry(), HandStateBase::OnUpdate() и OnUpdate().

◆ ValidateMuzzleArray()

void ValidateMuzzleArray ( )

Safety check and error message in case not set up correctly.

160 {
161 // There is only one
162 if (IsSingleState())
163 return;
164
165 bool failed = false;
166
167 if (!failed)
168 {
170 {
171 if ( state == MuzzleState.U )
172 {
173 failed = true;
174 break;
175 }
176 }
177 }
178
179 if (failed)
180 {
182
183 #ifdef DEVELOPER
184 if (DayZGame.m_IsPreviewSpawn)
185 {
186 // we do not want VMEs when spawning the item in order to visualize it for preview in script console
188 }
189 #endif
190
191 ErrorEx("Muzzle array validation has failed. Please set up the correct muzzle states by overriding InitMuzzleArray.", severity);
192 }
193 }
bool IsSingleState()
Special one for when the weapon only has one singular state (like Magnum)
Definition WeaponStableState.c:140
ErrorExSeverity
Definition EnDebug.c:62
enum ShapeType ErrorEx

Перекрестные ссылки ErrorEx, IsSingleState() и m_muzzleHasBullet.

Используется в WeaponStableState().

◆ WeaponStableState()

void WeaponStableState ( Weapon_Base w = NULL,
WeaponStateBase parent = NULL,
int anim_state = -1 )
33 {
37 }
void InitMuzzleArray()
Override with the filling of m_muzzleHasBullet.
Definition WeaponStableState.c:137
void ValidateMuzzleArray()
Safety check and error message in case not set up correctly.
Definition WeaponStableState.c:159

Перекрестные ссылки WeaponStableState::InitMuzzleArray(), m_animState и ValidateMuzzleArray().

Используется в Weapon_Base::InitStateMachine().

Переменные

◆ m_animState

enum MuzzleState m_animState

Используется в SyncAnimState() и WeaponStableState().

◆ m_muzzleHasBullet