Fix weapon cooldown serialization while mapping (#15123)
This commit is contained in:
@@ -70,6 +70,16 @@ public abstract class SharedMeleeWeaponSystem : EntitySystem
|
||||
SubscribeAllEvent<HeavyAttackEvent>(OnHeavyAttack);
|
||||
SubscribeAllEvent<DisarmAttackEvent>(OnDisarmAttack);
|
||||
SubscribeAllEvent<StopAttackEvent>(OnStopAttack);
|
||||
|
||||
#if DEBUG
|
||||
SubscribeLocalEvent<MeleeWeaponComponent, MapInitEvent>(OnMapInit);
|
||||
}
|
||||
|
||||
private void OnMapInit(EntityUid uid, MeleeWeaponComponent component, MapInitEvent args)
|
||||
{
|
||||
if (component.NextAttack > TimeSpan.Zero)
|
||||
Logger.Warning($"Initializing a map that contains an entity that is on cooldown. Entity: {ToPrettyString(uid)}");
|
||||
#endif
|
||||
}
|
||||
|
||||
private void OnMeleeSelected(EntityUid uid, MeleeWeaponComponent component, HandSelectedEvent args)
|
||||
@@ -80,6 +90,9 @@ public abstract class SharedMeleeWeaponSystem : EntitySystem
|
||||
if (!component.ResetOnHandSelected)
|
||||
return;
|
||||
|
||||
if (Paused(uid))
|
||||
return;
|
||||
|
||||
// If someone swaps to this weapon then reset its cd.
|
||||
var curTime = Timing.CurTime;
|
||||
var minimum = curTime + TimeSpan.FromSeconds(1 / component.AttackRate);
|
||||
|
||||
Reference in New Issue
Block a user