DayZ 1.24
Loading...
Searching...
No Matches
RifleChambering.c
Go to the documentation of this file.
1class RifleChambering extends WeaponStateBase
2{
6
11
13 {
15 m_actionType = actionType;
16
17 // setup nested state machine
18 m_start = new WeaponChambering_Start(m_weapon, this, m_action, m_actionType);
21 m_w4t = new WeaponChambering_W4T(m_weapon, this);
22 // events
23 WeaponEventAnimBulletEject __be_ = new WeaponEventAnimBulletEject;
24 WeaponEventAnimBulletShow __bs_ = new WeaponEventAnimBulletShow;
25 WeaponEventAnimBulletInChamber __bc_ = new WeaponEventAnimBulletInChamber;
26 WeaponEventBase _fin_ = new WeaponEventHumanCommandActionFinished;
27
28 m_fsm = new WeaponFSM(this); // @NOTE: set owner of the submachine fsm
29 m_fsm.AddTransition(new WeaponTransition(m_start, __be_, m_eject));
30 m_fsm.AddTransition(new WeaponTransition(m_eject, __bs_, m_chamber));
31 m_fsm.AddTransition(new WeaponTransition(m_chamber, __bc_, m_w4t));
32 m_fsm.AddTransition(new WeaponTransition(m_w4t, _fin_, NULL));
33
34 // Safety exits
35 m_fsm.AddTransition(new WeaponTransition(m_chamber, _fin_, null));
36 m_fsm.AddTransition(new WeaponTransition(m_eject, _fin_, null));
37 m_fsm.AddTransition(new WeaponTransition(m_start, _fin_, null));
38
39 m_fsm.SetInitialState(m_start);
40 }
41
42 override void OnEntry(WeaponEventBase e)
43 {
44 if (e != NULL)
45 {
46 if (e.m_magazine != NULL)
47 {
48 if (LogManager.IsWeaponLogEnable()) wpnDebugPrint("[wpnfsm] " + Object.GetDebugName(m_weapon) + " RifleChambering, taking mag from event e.mag=" + e.m_magazine.ToString());
49 m_srcMagazine = e.m_magazine;
50 m_chamber.m_srcMagazine = m_srcMagazine;
51 }
52 }
53 else
54 {
55 if (LogManager.IsWeaponLogEnable()) wpnDebugPrint("[wpnfsm] " + Object.GetDebugName(m_weapon) + " RifleChambering (e=NULL), m_srcMagazine=" + m_srcMagazine.ToString());
56 }
57 if (LogManager.IsWeaponLogEnable()) wpnDebugPrint("[wpnfsm] " + Object.GetDebugName(m_weapon) + " m_srcMagazine=" + m_srcMagazine.ToString());
58
59 super.OnEntry(e); // @NOTE: super at the end (prevent override from submachine start)
60 }
61
62 override void OnAbort(WeaponEventBase e)
63 {
64 super.OnAbort(e);
66 }
67
68 override void OnExit(WeaponEventBase e)
69 {
70 super.OnExit(e);
72 }
73
75 {
76 if (!super.SaveCurrentFSMState(ctx))
77 return false;
78
79 if (!ctx.Write(m_srcMagazine))
80 {
81 Error("[wpnfsm] " + Object.GetDebugName(m_weapon) + " RifleChambering.SaveCurrentFSMState: cannot save m_srcMagazine for weapon=" + m_weapon);
82 return false;
83 }
84 return true;
85 }
86
87 override bool LoadCurrentFSMState(ParamsReadContext ctx, int version)
88 {
89 if (!super.LoadCurrentFSMState(ctx, version))
90 return false;
91
92 if (!ctx.Read(m_srcMagazine))
93 {
94 Error("[wpnfsm] " + Object.GetDebugName(m_weapon) + " RifleChambering.LoadCurrentFSMState: cannot read m_srcMagazine for weapon=" + m_weapon);
95 return false;
96 }
97 return true;
98 }
99};
100
void wpnDebugPrint(string s)
Definition Debug.c:9
class WeaponGuardIsDestroyed extends WeaponGuardBase m_weapon
Definition Guards.c:602
enum FSMTransition WeaponTransition
Magazine m_srcMagazine
ref WeaponStateBase m_start
class WeaponEndAction extends WeaponStartAction m_action
ref WeaponChambering_Base m_chamber
ref WeaponEjectCasingMultiMuzzle m_eject
static bool IsWeaponLogEnable()
Definition Debug.c:799
Serialization general interface. Serializer API works with:
Definition Serializer.c:56
signalize mechanism manipulation
Definition Events.c:35
weapon finite state machine
represent weapon state base
Definition BulletHide.c:2
int m_actionType
action to be played
ref WeaponChambering_W4T m_w4t
Magazine m_srcMagazine
destination of the ejected cartridge
WeaponActions m_action
ref WeaponChambering_Cartridge m_chamber
override void OnEntry(WeaponEventBase e)
ref WeaponStateBase m_start
source of the cartridge
override bool LoadCurrentFSMState(ParamsReadContext ctx, int version)
ref WeaponEjectCasing m_eject
override void OnAbort(WeaponEventBase e)
void WeaponEjectCasing(Weapon_Base w=NULL, WeaponStateBase parent=NULL)
void RifleChambering(Weapon_Base w=NULL, WeaponStateBase parent=NULL, WeaponActions action=WeaponActions.NONE, int actionType=-1)
override void OnExit(WeaponEventBase e)
override bool SaveCurrentFSMState(ParamsWriteContext ctx)
void Error(string err)
Messagebox with error message.
Definition EnDebug.c:90
WeaponActions
actions
Definition human.c:796