Dayz Explorer  1.24.157551 (v105080)
Dayz Code Explorer by Zeroy
weaponfireandchambernext.c
Go to the documentation of this file.
1 class WeaponFireAndChamberNext extends WeaponStateBase
2 {
4  int m_actionType;
5 
6  float m_dtAccumulator;
7  ref WeaponFire m_fire;
8 
9  void WeaponFireAndChamberNext (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;
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 
50  if ( m_dtAccumulator >= reloadTime && ( hic.IsAttackButton() || (m_weapon.GetBurstCount() < m_weapon.GetCurrentModeBurstSize(muzzleIndex))))
51  {
52  if (m_weapon.CanProcessWeaponEvents())
53  {
54  m_weapon.ProcessWeaponEvent(new WeaponEventReloadTimeout(p));
55  }
56  }
57  }
58  }
59 
60  override void OnExit (WeaponEventBase e)
61  {
62  //m_weapon.ResetBurstCount();
63  m_dtAccumulator = 0;
64  super.OnExit(e);
65  }
66 
67  override void OnAbort (WeaponEventBase e)
68  {
69  m_weapon.ResetBurstCount();
70  super.OnAbort(e);
71  }
72 };
73 
74 
OnAbort
override void OnAbort()
Definition: remotedetonator.c:300
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
WeaponActions
WeaponActions
actions
Definition: human.c:808
OnUpdate
proto native void OnUpdate()
Definition: tools.c:349
WeaponTransition
enum FSMTransition WeaponTransition
DayZPlayerImplement
Definition: manbase.c:1
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