123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609 |
- /**@class WeaponGuardBase
- * @brief represents guard on a transition from state to state
- **/
- class WeaponGuardBase
- {
- /**@fn GuardCondition
- * @brief enable or disable transition based on condition
- * the guard is a boolean operation executed first and which can prevent the transition from firing by returning false
- * @return true if transition is allowed
- **/
- bool GuardCondition (WeaponEventBase e) { return true; }
- };
- class GuardAnd extends WeaponGuardBase
- {
- ref WeaponGuardBase m_arg0;
- ref WeaponGuardBase m_arg1;
- void GuardAnd (WeaponGuardBase arg0 = NULL, WeaponGuardBase arg1 = NULL) { m_arg0 = arg0; m_arg1 = arg1; }
- override bool GuardCondition (WeaponEventBase e)
- {
- bool result = m_arg0.GuardCondition(e) && m_arg1.GuardCondition(e);
- if (LogManager.IsWeaponLogEnable()) { wpnDebugPrint("[wpnfsm] guard - " + m_arg0.Type() + " && " + m_arg1.Type() + " = " + result); }
- return result;
- }
- };
- class GuardNot extends WeaponGuardBase
- {
- ref WeaponGuardBase m_arg0;
- void GuardNot (WeaponGuardBase arg0 = NULL) { m_arg0 = arg0; }
- override bool GuardCondition (WeaponEventBase e)
- {
- bool result = !m_arg0.GuardCondition(e);
- if (LogManager.IsWeaponLogEnable()) { wpnDebugPrint("[wpnfsm] guard - ! " + m_arg0.Type() + " = " + result); }
- return result;
- }
- };
- class GuardOr extends WeaponGuardBase
- {
- ref WeaponGuardBase m_arg0;
- ref WeaponGuardBase m_arg1;
- void GuardOr (WeaponGuardBase arg0 = NULL, WeaponGuardBase arg1 = NULL) { m_arg0 = arg0; m_arg1 = arg1; }
- override bool GuardCondition (WeaponEventBase e)
- {
- bool result = m_arg0.GuardCondition(e) || m_arg1.GuardCondition(e);
- if (LogManager.IsWeaponLogEnable()) { wpnDebugPrint("[wpnfsm] guard - " + m_arg0.Type() + " || " + m_arg1.Type() + " = " + result); }
- return result;
- }
- };
- // guards /////////////////////////////////////////////////////////////////////////////////////////////////////////////
- class WeaponGuardJammed extends WeaponGuardBase
- {
- protected Weapon_Base m_weapon;
- void WeaponGuardJammed (Weapon_Base w = NULL) { m_weapon = w; }
- override bool GuardCondition (WeaponEventBase e)
- {
- /*int mi = m_weapon.GetCurrentMuzzle();
- if (m_weapon.IsChamberJammed(mi))*/
- if (m_weapon.IsJammed())
- {
- if (LogManager.IsWeaponLogEnable()) { wpnDebugPrint("[wpnfsm] " + Object.GetDebugName(m_weapon) + " guard - jammed"); }
- return true;
- }
- if (LogManager.IsWeaponLogEnable()) { wpnDebugPrint("[wpnfsm] guard - not jammed"); }
- return false;
- }
- };
- class WeaponGuardIsDestroyed extends WeaponGuardBase
- {
- protected Weapon_Base m_weapon;
- void WeaponGuardIsDestroyed (Weapon_Base w = NULL) { m_weapon = w; }
- override bool GuardCondition (WeaponEventBase e)
- {
- if (m_weapon.IsDamageDestroyed())
- {
- if (LogManager.IsWeaponLogEnable()) { wpnDebugPrint("[wpnfsm] " + Object.GetDebugName(m_weapon) + " guard - weapon destroyed"); }
- return true;
- }
- if (LogManager.IsWeaponLogEnable()) { wpnDebugPrint("[wpnfsm] " + Object.GetDebugName(m_weapon) + " guard - weapon not destroyed"); }
- return false;
- }
- }
- class WeaponGuardHasAmmo extends WeaponGuardBase
- {
- protected Weapon_Base m_weapon;
- void WeaponGuardHasAmmo (Weapon_Base w = NULL) { m_weapon = w; }
- override bool GuardCondition (WeaponEventBase e)
- {
- int mi = m_weapon.GetCurrentMuzzle();
- Magazine mag = m_weapon.GetMagazine(mi);
- if (mag != NULL && mag.GetAmmoCount() > 0)
- {
- if (LogManager.IsWeaponLogEnable()) { wpnDebugPrint("[wpnfsm] " + Object.GetDebugName(m_weapon) + " guard - has ammo"); }
- return true;
- }
- if (LogManager.IsWeaponLogEnable()) { wpnDebugPrint("[wpnfsm] " + Object.GetDebugName(m_weapon) + " guard - no ammo"); }
- return false;
- }
- };
- class WeaponGuardHasAmmoInnerMagazine extends WeaponGuardBase
- {
- protected Weapon_Base m_weapon;
- void WeaponGuardHasAmmoInnerMagazine (Weapon_Base w = NULL) { m_weapon = w; }
- override bool GuardCondition (WeaponEventBase e)
- {
- int mi = m_weapon.GetCurrentMuzzle();
- if (m_weapon.GetInternalMagazineCartridgeCount(mi) >= 1)
- {
- if (LogManager.IsWeaponLogEnable()) { wpnDebugPrint("[wpnfsm] " + Object.GetDebugName(m_weapon) + " guard - has ammo in inner magazine"); }
- return true;
- }
- if (LogManager.IsWeaponLogEnable()) { wpnDebugPrint("[wpnfsm] " + Object.GetDebugName(m_weapon) + " guard - no ammo in inner magazine"); }
- return false;
- }
- };
- class WeaponGuardHasAmmoInEvent extends WeaponGuardBase
- {
- protected Weapon_Base m_weapon;
- void WeaponGuardHasAmmoInEvent (Weapon_Base w = NULL) { m_weapon = w; }
- override bool GuardCondition (WeaponEventBase e)
- {
- Magazine mag = e.m_magazine;
- if (mag != NULL && mag.GetAmmoCount() > 0)
- {
- if (LogManager.IsWeaponLogEnable()) { wpnDebugPrint("[wpnfsm] " + Object.GetDebugName(m_weapon) + " guard - has ammo in event"); }
- return true;
- }
- if (LogManager.IsWeaponLogEnable()) { wpnDebugPrint("[wpnfsm] " + Object.GetDebugName(m_weapon) + " guard - no ammo in event"); }
- return false;
- }
- };
- class WeaponGuardHasMag extends WeaponGuardBase
- {
- protected Weapon_Base m_weapon;
- void WeaponGuardHasMag (Weapon_Base w = NULL) { m_weapon = w; }
- override bool GuardCondition (WeaponEventBase e)
- {
- int mi = m_weapon.GetCurrentMuzzle();
- Magazine mag = m_weapon.GetMagazine(mi);
- if (mag != NULL)
- {
- if (LogManager.IsWeaponLogEnable()) { wpnDebugPrint("[wpnfsm] " + Object.GetDebugName(m_weapon) + " guard - has magazine"); }
- return true;
- }
- if (LogManager.IsWeaponLogEnable()) { wpnDebugPrint("[wpnfsm] " + Object.GetDebugName(m_weapon) + " guard - no magazine"); }
- return false;
- }
- };
- class WeaponGuardChamberEmpty extends WeaponGuardBase
- {
- protected Weapon_Base m_weapon;
- protected int m_muzzle;
- void WeaponGuardChamberEmpty (Weapon_Base w = NULL, int muzzle_index = 0 ) { m_weapon = w; m_muzzle = muzzle_index; }
- override bool GuardCondition (WeaponEventBase e)
- {
- if (m_weapon.IsChamberEmpty(m_muzzle))
- {
- if (LogManager.IsWeaponLogEnable()) { wpnDebugPrint("[wpnfsm] " + Object.GetDebugName(m_weapon) + " guard - chamber (" + m_muzzle + ") empty"); }
- return true;
- }
- if (LogManager.IsWeaponLogEnable()) { wpnDebugPrint("[wpnfsm] " + Object.GetDebugName(m_weapon) + " guard - chamber (" + m_muzzle + ") not empty"); }
- return false;
- }
- };
- class WeaponGuardCurrentChamberEmpty extends WeaponGuardBase
- {
- protected Weapon_Base m_weapon;
- void WeaponGuardCurrentChamberEmpty (Weapon_Base w = NULL) { m_weapon = w; }
- override bool GuardCondition (WeaponEventBase e)
- {
- int mi = m_weapon.GetCurrentMuzzle();
- if (m_weapon.IsChamberEmpty(mi))
- {
- if (LogManager.IsWeaponLogEnable()) { wpnDebugPrint("[wpnfsm] " + Object.GetDebugName(m_weapon) + " guard - chamber empty"); }
- return true;
- }
- if (LogManager.IsWeaponLogEnable()) { wpnDebugPrint("[wpnfsm] " + Object.GetDebugName(m_weapon) + " guard - chamber not empty"); }
- return false;
- }
- };
- class WeaponGuardAnyChamberEmpty extends WeaponGuardBase
- {
- protected Weapon_Base m_weapon;
- protected int m_muzzle;
- void WeaponGuardAnyChamberEmpty (Weapon_Base w = NULL, int muzzle_index = 0 ) { m_weapon = w; m_muzzle = muzzle_index; }
- override bool GuardCondition (WeaponEventBase e)
- {
- for (int i = 0; i < m_weapon.GetMuzzleCount(); i++)
- {
- if (m_weapon.IsChamberEmpty(i))
- {
- if (LogManager.IsWeaponLogEnable()) { wpnDebugPrint("[wpnfsm] " + Object.GetDebugName(m_weapon) + " guard - multi chamber (" + i + ") empty"); }
- return true;
- }
- }
- if (LogManager.IsWeaponLogEnable()) { wpnDebugPrint("[wpnfsm] " + Object.GetDebugName(m_weapon) + " guard - no chamber empty"); }
- return false;
- }
- };
- class WeaponGuardChamberFull extends WeaponGuardBase
- {
- protected Weapon_Base m_weapon;
- protected int m_muzzle;
- void WeaponGuardChamberFull (Weapon_Base w = NULL, int muzzle_index = 0 ) { m_weapon = w; m_muzzle = muzzle_index; }
- override bool GuardCondition (WeaponEventBase e)
- {
- if (m_weapon.IsChamberFull(m_muzzle))
- {
- if (LogManager.IsWeaponLogEnable()) { wpnDebugPrint("[wpnfsm] " + Object.GetDebugName(m_weapon) + " guard - chamber (" + m_muzzle + ") full"); }
- return true;
- }
- if (LogManager.IsWeaponLogEnable()) { wpnDebugPrint("[wpnfsm] " + Object.GetDebugName(m_weapon) + " guard - chamber (" + m_muzzle + ") not full"); }
- return false;
- }
- };
- class WeaponGuardCurrentChamberFull extends WeaponGuardBase
- {
- protected Weapon_Base m_weapon;
- void WeaponGuardCurrentChamberFull (Weapon_Base w = NULL) { m_weapon = w; }
- override bool GuardCondition (WeaponEventBase e)
- {
- int mi = m_weapon.GetCurrentMuzzle();
- if (m_weapon.IsChamberFull(mi))
- {
- if (LogManager.IsWeaponLogEnable()) { wpnDebugPrint("[wpnfsm] " + Object.GetDebugName(m_weapon) + " guard - chamber full"); }
- return true;
- }
- if (LogManager.IsWeaponLogEnable()) { wpnDebugPrint("[wpnfsm] " + Object.GetDebugName(m_weapon) + " guard - chamber not full"); }
- return false;
- }
- };
- class WeaponGuardInnerMagazineFull extends WeaponGuardBase
- {
- protected Weapon_Base m_weapon;
- void WeaponGuardInnerMagazineFull (Weapon_Base w = NULL) { m_weapon = w; }
- override bool GuardCondition (WeaponEventBase e)
- {
- int mi = m_weapon.GetCurrentMuzzle();
- if (m_weapon.IsInternalMagazineFull(mi))
- {
- if (LogManager.IsWeaponLogEnable()) { wpnDebugPrint("[wpnfsm] " + Object.GetDebugName(m_weapon) + " guard - internal magazine full"); }
- return true;
- }
- if (LogManager.IsWeaponLogEnable()) { wpnDebugPrint("[wpnfsm] " + Object.GetDebugName(m_weapon) + " guard - internal magazine not full"); }
- return false;
- }
- };
- class WeaponGuardInnerMagazineFullShareChamber extends WeaponGuardBase
- {
- protected Weapon_Base m_weapon;
- void WeaponGuardInnerMagazineFullShareChamber (Weapon_Base w = NULL) { m_weapon = w; }
- override bool GuardCondition (WeaponEventBase e)
- {
- int mi = m_weapon.GetCurrentMuzzle();
-
- if ( m_weapon.IsChamberFull(mi) && m_weapon.IsInternalMagazineFull(mi))
- {
- if (LogManager.IsWeaponLogEnable()) { wpnDebugPrint("[wpnfsm] " + Object.GetDebugName(m_weapon) + " guard - internal magazine with share chamber is full"); }
- return true;
- }
- if (LogManager.IsWeaponLogEnable()) { wpnDebugPrint("[wpnfsm] " + Object.GetDebugName(m_weapon) + " guard - internal magazine with share chamber is not full"); }
- return false;
- }
- };
- class WeaponGuardChamberFiredOut extends WeaponGuardBase
- {
- protected Weapon_Base m_weapon;
- protected int m_muzzle;
- void WeaponGuardChamberFiredOut (Weapon_Base w = NULL, int muzzle_index = 0 ) { m_weapon = w; m_muzzle = muzzle_index; }
- override bool GuardCondition (WeaponEventBase e)
- {
- if (m_weapon.IsChamberFiredOut(m_muzzle))
- {
- if (LogManager.IsWeaponLogEnable()) { wpnDebugPrint("[wpnfsm] " + Object.GetDebugName(m_weapon) + " guard - chamber (" + m_muzzle + ") fireout"); }
- return true;
- }
- if (LogManager.IsWeaponLogEnable()) { wpnDebugPrint("[wpnfsm] " + Object.GetDebugName(m_weapon) + " guard - chamber (" + m_muzzle + ") not fireout"); }
- return false;
- }
- };
- class WeaponGuardCurrentChamberFiredOut extends WeaponGuardBase
- {
- protected Weapon_Base m_weapon;
- void WeaponGuardCurrentChamberFiredOut (Weapon_Base w = NULL) { m_weapon = w; }
- override bool GuardCondition (WeaponEventBase e)
- {
- int mi = m_weapon.GetCurrentMuzzle();
- if (m_weapon.IsChamberFiredOut(mi))
- {
- if (LogManager.IsWeaponLogEnable()) { wpnDebugPrint("[wpnfsm] " + Object.GetDebugName(m_weapon) + " guard - chamber fired out"); }
- return true;
- }
- if (LogManager.IsWeaponLogEnable()) { wpnDebugPrint("[wpnfsm] " + Object.GetDebugName(m_weapon) + " guard - chamber not fired out"); }
- return false;
- }
- };
- class WeaponGuardAnyChamberFiredOut extends WeaponGuardBase
- {
- protected Weapon_Base m_weapon;
- void WeaponGuardAnyChamberFiredOut (Weapon_Base w = NULL) { m_weapon = w; }
- override bool GuardCondition (WeaponEventBase e)
- {
- for (int i = 0; i < m_weapon.GetMuzzleCount(); i++)
- {
- if (m_weapon.IsChamberFiredOut(i))
- {
- if (LogManager.IsWeaponLogEnable()) { wpnDebugPrint("[wpnfsm] " + Object.GetDebugName(m_weapon) + " guard - multi chamber (" + i + ") fired out"); }
- return true;
- }
- }
- if (LogManager.IsWeaponLogEnable()) { wpnDebugPrint("[wpnfsm] " + Object.GetDebugName(m_weapon) + " guard - any chamber has not fired out"); }
- return false;
- }
- };
- class WeaponGuardCanAttachMag extends WeaponGuardBase
- {
- protected Weapon_Base m_weapon;
- void WeaponGuardCanAttachMag (Weapon_Base w = NULL) { m_weapon = w; }
- override bool GuardCondition (WeaponEventBase e)
- {
- int mi = m_weapon.GetCurrentMuzzle();
- if (m_weapon && e.m_magazine && m_weapon.CanAttachMagazine(mi, e.m_magazine))
- {
- if (LogManager.IsWeaponLogEnable()) { wpnDebugPrint("[wpnfsm] " + Object.GetDebugName(m_weapon) + " guard - can attach magazine"); }
- return true;
- }
- if (LogManager.IsWeaponLogEnable()) { wpnDebugPrint("[wpnfsm] " + Object.GetDebugName(m_weapon) + " guard - cannot attach magazine"); }
- return false;
- }
- };
- class WeaponGuardCanSwapMag extends WeaponGuardBase
- {
- protected Weapon_Base m_weapon;
- void WeaponGuardCanSwapMag (Weapon_Base w = NULL) { m_weapon = w; }
- override bool GuardCondition (WeaponEventBase e)
- {
- int mi = m_weapon.GetCurrentMuzzle();
- Magazine attached_mag = m_weapon.GetMagazine(mi);
- if (m_weapon && e.m_magazine && e.m_magazine != attached_mag /*&& m_weapon.CanSwapMagazine(mi, e.m_magazine)*/)
- {
- if (LogManager.IsWeaponLogEnable()) { wpnDebugPrint("[wpnfsm] " + Object.GetDebugName(m_weapon) + " guard - can swap magazine"); }
- return true;
- }
- if (LogManager.IsWeaponLogEnable()) { wpnDebugPrint("[wpnfsm] " + Object.GetDebugName(m_weapon) + " guard - cannot swap magazine"); }
- return false;
- }
- };
- class WeaponGuardCanDetachMag extends WeaponGuardBase
- {
- protected Weapon_Base m_weapon;
- void WeaponGuardCanDetachMag (Weapon_Base w = NULL) { m_weapon = w; }
- override bool GuardCondition (WeaponEventBase e)
- {
- int mi = m_weapon.GetCurrentMuzzle();
- if (m_weapon && e.m_magazine && m_weapon.GetMagazine(mi)/* && m_weapon.CanDetachMagazine(mi, e.m_magazine)*/)
- {
- if (LogManager.IsWeaponLogEnable()) { wpnDebugPrint("[wpnfsm] " + Object.GetDebugName(m_weapon) + " guard - can detach magazine"); }
- return true;
- }
- if (LogManager.IsWeaponLogEnable()) { wpnDebugPrint("[wpnfsm] " + Object.GetDebugName(m_weapon) + " guard - cannot detach magazine"); }
- return false;
- }
- };
- class WeaponGuardChamberHasRoomForMoreThanOne extends WeaponGuardBase
- {
- protected Weapon_Base m_weapon;
- void WeaponGuardChamberHasRoomForMoreThanOne (Weapon_Base w = NULL) { m_weapon = w; }
- override bool GuardCondition (WeaponEventBase e)
- {
- int mi = m_weapon.GetCurrentMuzzle();
- if (m_weapon.GetInternalMagazineMaxCartridgeCount(mi) - m_weapon.GetInternalMagazineCartridgeCount(mi) > 1)
- {
- if (LogManager.IsWeaponLogEnable()) { wpnDebugPrint("[wpnfsm] " + Object.GetDebugName(m_weapon) + " guard - chamber has room for more than 1b"); }
- return true;
- }
- if (LogManager.IsWeaponLogEnable()) { wpnDebugPrint("[wpnfsm] " + Object.GetDebugName(m_weapon) + " guard - chamber has no room for more than 1b"); }
- return false;
- }
- };
- class WeaponGuardInternalMagazineHasRoomForBullet extends WeaponGuardBase
- {
- protected Weapon_Base m_weapon;
- void WeaponGuardInternalMagazineHasRoomForBullet (Weapon_Base w = NULL) { m_weapon = w; }
- override bool GuardCondition (WeaponEventBase e)
- {
- int mi = m_weapon.GetCurrentMuzzle();
- if (m_weapon.GetInternalMagazineMaxCartridgeCount(mi) - m_weapon.GetInternalMagazineCartridgeCount(mi) >= 1)
- {
- if (LogManager.IsWeaponLogEnable()) { wpnDebugPrint("[wpnfsm] " + Object.GetDebugName(m_weapon) + " guard - chamber has room for bullet"); }
- return true;
- }
- if (LogManager.IsWeaponLogEnable()) { wpnDebugPrint("[wpnfsm] " + Object.GetDebugName(m_weapon) + " guard - chamber has no room for bullet"); }
- return false;
- }
- };
- class WeaponGuardChamberHasRoomForOne extends WeaponGuardBase
- {
- protected Weapon_Base m_weapon;
- void WeaponGuardChamberHasRoomForOne (Weapon_Base w = NULL) { m_weapon = w; }
- override bool GuardCondition (WeaponEventBase e)
- {
- int mi = m_weapon.GetCurrentMuzzle();
- if (m_weapon.GetTotalMaxCartridgeCount(mi) - m_weapon.GetTotalCartridgeCount(mi) == 1)
- {
- if (LogManager.IsWeaponLogEnable()) { wpnDebugPrint("[wpnfsm] " + Object.GetDebugName(m_weapon) + " guard - chamber has room for 1b"); }
- return true;
- }
- if (LogManager.IsWeaponLogEnable()) { wpnDebugPrint("[wpnfsm] " + Object.GetDebugName(m_weapon) + " guard - chamber has no room for 1b"); }
- return false;
- }
- };
- class WeaponGuardChamberMultiHasRoomBulltet extends WeaponGuardBase
- {
- protected Weapon_Base m_weapon;
- void WeaponGuardChamberMultiHasRoomBulltet (Weapon_Base w = NULL) { m_weapon = w; }
- override bool GuardCondition (WeaponEventBase e)
- {
- int i = m_weapon.GetMuzzleCount() - 1;
- for ( ; i >= 0; i--)
- {
- if (m_weapon.GetTotalMaxCartridgeCount(i) - m_weapon.GetTotalCartridgeCount(i) >= 1)
- {
- if (LogManager.IsWeaponLogEnable()) { wpnDebugPrint("[wpnfsm] " + Object.GetDebugName(m_weapon) + " guard - chamber has room for 1b"); }
- return true;
- }
- if (LogManager.IsWeaponLogEnable()) { wpnDebugPrint("[wpnfsm] " + Object.GetDebugName(m_weapon) + " guard - chamber has no room for 1b"); }
- }
- return false;
- }
- };
- class WeaponGuardChamberMultiHasRoomBulltetIgnoreLast extends WeaponGuardBase
- {
- protected Weapon_Base m_weapon;
- void WeaponGuardChamberMultiHasRoomBulltetIgnoreLast (Weapon_Base w = NULL) { m_weapon = w; }
- override bool GuardCondition (WeaponEventBase e)
- {
- int i = m_weapon.GetMuzzleCount() - 1;
- bool emty_one = false;
- for ( ; i >= 0; i--)
- {
- if (m_weapon.GetTotalMaxCartridgeCount(i) - m_weapon.GetTotalCartridgeCount(i) >= 1)
- {
- if ( !emty_one )
- {
- emty_one = true;
- }
- else
- {
- if (LogManager.IsWeaponLogEnable()) { wpnDebugPrint("[wpnfsm] " + Object.GetDebugName(m_weapon) + " guard - chamber has room for 1b"); }
- return true;
- }
- }
- if (LogManager.IsWeaponLogEnable()) { wpnDebugPrint("[wpnfsm] " + Object.GetDebugName(m_weapon) + " guard - chamber has no room for 1b"); }
- }
- return false;
- }
- };
- class WeaponGuardHasAmmoInLoopedState extends WeaponGuardBase
- {
- WeaponChambering_Base m_state;
- void WeaponGuardHasAmmoInLoopedState (WeaponChambering_Base state) { m_state = state; }
- override bool GuardCondition (WeaponEventBase e)
- {
- Magazine mag = m_state.m_srcMagazine;
- if (mag != NULL && mag.GetAmmoCount() > 0)
- {
- if (LogManager.IsWeaponLogEnable()) { wpnDebugPrint("[wpnfsm] guard - has ammo in looped state"); }
- return true;
- }
- if (LogManager.IsWeaponLogEnable()) { wpnDebugPrint("[wpnfsm] guard - no ammo in looped state"); }
- return false;
- }
- };
- class WeaponGuardMagazinesHaveEqualSizes extends WeaponGuardBase
- {
- protected Weapon_Base m_weapon;
- void WeaponGuardMagazinesHaveEqualSizes (Weapon_Base w = NULL) { m_weapon = w; }
- override bool GuardCondition (WeaponEventBase e)
- {
- int mi = m_weapon.GetCurrentMuzzle();
- Magazine mag = m_weapon.GetMagazine(mi);
- Magazine mag2 = e.m_magazine;
- if (mag != NULL && mag2 != NULL)
- {
- bool eq = magazinesHaveEqualSizes(mag, mag2);
- if (eq)
- {
- if (LogManager.IsWeaponLogEnable()) { wpnDebugPrint("[wpnfsm] " + Object.GetDebugName(m_weapon) + " guard - same inventory sizes"); }
- return true;
- }
- if (LogManager.IsWeaponLogEnable()) { wpnDebugPrint("[wpnfsm] " + Object.GetDebugName(m_weapon) + " guard - different inventory sizes"); }
- return false;
- }
- Error("[wpnfsm] " + Object.GetDebugName(m_weapon) + " guard - mag == NULL or mag2 == NULL, cannot perform comparison");
- return false;
- }
- };
- class WeaponGuardWeaponCharged extends WeaponGuardBase
- {
- protected Weapon_Base m_weapon;
-
- void WeaponGuardWeaponCharged (Weapon_Base w = NULL) { m_weapon = w; }
-
- override bool GuardCondition (WeaponEventBase e)
- {
- return m_weapon.IsCharged();
- }
- }
- class WeaponGuardWeaponDischarged extends WeaponGuardBase
- {
- protected Weapon_Base m_weapon;
-
- void WeaponGuardWeaponDischarged (Weapon_Base w = NULL) { m_weapon = w; }
-
- override bool GuardCondition (WeaponEventBase e)
- {
- return !m_weapon.IsCharged();
- }
- }
- class WeaponGuardWeaponOpen extends WeaponGuardBase
- {
- protected Weapon_Base m_weapon;
-
- void WeaponGuardWeaponOpen (Weapon_Base w = NULL) { m_weapon = w; }
-
- override bool GuardCondition (WeaponEventBase e)
- {
- return m_weapon.IsWeaponOpen();
- }
- }
- class WeaponGuardWeaponManagerWantContinue extends WeaponGuardBase
- {
- override bool GuardCondition (WeaponEventBase e)
- {
- PlayerBase player = PlayerBase.Cast(e.m_player);
- return player.GetWeaponManager().WantContinue();
- }
- };
|