Dayz Explorer  1.24.157551 (v105080)
Dayz Code Explorer by Zeroy
weaponfireandchambernextfrominnermag.c
Go to the documentation of this file.
1 class WeaponFireAndChamberNextFromInnerMag extends WeaponStateBase
2 {
4  int m_actionType;
5 
6  float m_dtAccumulator;
7  ref WeaponFire m_fire;
8 
9  void WeaponFireAndChamberNextFromInnerMag (Weapon_Base w = NULL, WeaponStateBase parent = NULL, WeaponActions action = WeaponActions.NONE, int actionType = -1)
10  {
11  m_action = action;
12  m_actionType = actionType;
13 
14  // setup nested state machine
15  m_fire = new WeaponFireAndChamber(m_weapon, this, m_action, m_actionType);
16 
17  // events
18  WeaponEventBase _fin_ = new WeaponEventHumanCommandActionFinished;
19  WeaponEventAnimBulletEject __be_ = new WeaponEventAnimBulletEject;
20  WeaponEventReloadTimeout __to_ = new WeaponEventReloadTimeout;
21 
22  m_fsm = new WeaponFSM(this); // @NOTE: set owner of the submachine fsm
23 
24  // transitions
25  m_fsm.AddTransition(new WeaponTransition(m_fire, _fin_, NULL));
26  m_fsm.AddTransition(new WeaponTransition(m_fire, __to_, NULL));
27 
28  m_fsm.SetInitialState(m_fire);
29  }
30 
31  override void OnEntry (WeaponEventBase e)
32  {
33  super.OnEntry(e);
34  if (e)
35  m_dtAccumulator = 0;
36  }
37 
38  override void OnUpdate (float dt)
39  {
40  m_dtAccumulator += dt;
41  DayZPlayer p;
42  Class.CastTo(p, m_weapon.GetHierarchyParent());
43  if( p )
44  {
45  HumanInputController hic = p.GetInputController();
46 
47  int muzzleIndex = m_weapon.GetCurrentMuzzle();
48  float reloadTime = m_weapon.GetReloadTime(muzzleIndex);
49  if ( hic.IsAttackButton() && m_dtAccumulator >= reloadTime)
50  if (m_weapon.CanProcessWeaponEvents())
51  m_weapon.ProcessWeaponEvent(new WeaponEventReloadTimeout(p));
52  }
53  }
54 
55  override void OnExit (WeaponEventBase e)
56  {
57  m_dtAccumulator = 0;
58  super.OnExit(e);
59  }
60 };
61 
62 
OnExit
override void OnExit(HandEventBase e)
Definition: hand_states.c:28
WeaponFire
Definition: weaponfire.c:98
m_dtAccumulator
class WeaponFireWithEject extends WeaponFire m_dtAccumulator
m_action
class WeaponEndAction extends WeaponStartAction m_action
DayZPlayer
Definition: dayzplayerimplement.c:72
WeaponActions
WeaponActions
actions
Definition: human.c:808
OnUpdate
proto native void OnUpdate()
Definition: tools.c:349
WeaponTransition
enum FSMTransition WeaponTransition
HumanInputController
Definition: human.c:17
WeaponEventBase
signalize mechanism manipulation
Definition: events.c:34
WeaponStateBase
represent weapon state base
Definition: bullethide.c:1
m_weapon
class WeaponGuardIsDestroyed extends WeaponGuardBase m_weapon
Definition: guards.c:583
Weapon_Base
shorthand
Definition: boltactionrifle_base.c:5
WeaponFSM
weapon finite state machine
Class
Super root of all classes in Enforce script.
Definition: enscript.c:10
OnEntry
HandStateEquipped OnEntry
Definition: weaponchambering.c:208