NSWeapon: add method WeaponIsFiring()

This commit is contained in:
Marco Cawthorne 2024-07-30 20:45:04 -07:00
parent caac73bec9
commit 7c68a0317e
Signed by: eukara
GPG key ID: CE2032F0A2882A22
2 changed files with 15 additions and 4 deletions

View file

@ -142,6 +142,9 @@ public:
/** Overridable: Called once when the weapon stopped firing. */
virtual void WeaponStoppedFiring(void);
/** Returns whether the weapon is being actively fired by the owner. */
nonvirtual bool WeaponIsFiring(void);
/** Overridable: Controls def_onFire event. */
virtual void FiredWeaponAttack(string);
/** Overridable: Controls def_onRelease event. */
@ -167,6 +170,8 @@ private:
nonvirtual void _SwitchedFromCallback(void);
/** Called to cache some entityDef values. */
nonvirtual void _CacheWeaponDefVariables(void);
nonvirtual void _WeaponStartedFiring(void);
nonvirtual void _WeaponStoppedFiring(void);
#ifdef SERVER
nonvirtual void _ReloadFinished(void);

View file

@ -1092,11 +1092,11 @@ NSWeapon::_WeaponStartedFiring(void)
}
/* hasn't been fired yet. */
if (!(vv_flags & VFL_FIRING)) {
if (!(owner.vv_flags & VFL_FIRING)) {
WeaponStartedFiring();
}
vv_flags |= VFL_FIRING;
owner.vv_flags |= VFL_FIRING;
}
void
@ -1107,11 +1107,17 @@ NSWeapon::_WeaponStoppedFiring(void)
}
/* was still registed as firing */
if (vv_flags & VFL_FIRING) {
if (owner.vv_flags & VFL_FIRING) {
WeaponStoppedFiring();
}
vv_flags &= ~VFL_FIRING;
owner.vv_flags &= ~VFL_FIRING;
}
bool
NSWeapon::WeaponIsFiring(void)
{
return (owner.vv_flags & VFL_FIRING) ? (true) : (false);
}
void