Skip to content

Commit

Permalink
turn MeleeCooldown field from timespan into float to fix failing test
Browse files Browse the repository at this point in the history
  • Loading branch information
angelofallars committed Dec 11, 2024
1 parent 1af360b commit e4710c3
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
4 changes: 2 additions & 2 deletions Content.Shared/Weapons/Ranged/Components/GunComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -211,8 +211,8 @@ public sealed partial class GunComponent : Component
/// <summary>
/// After dealing a melee attack with this gun, the minimum cooldown before the gun can shoot again.
/// </summary>
[DataField(customTypeSerializer:typeof(TimeOffsetSerializer))]
public TimeSpan MeleeCooldown = TimeSpan.FromSeconds(0.528f);
[DataField]
public float MeleeCooldown = 0.528f;

/// <summary>
/// What firemodes can be selected.
Expand Down
6 changes: 4 additions & 2 deletions Content.Shared/Weapons/Ranged/Systems/SharedGunSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,11 @@ private void OnGunMelee(EntityUid uid, GunComponent component, MeleeHitEvent arg
if (component.NextFire < curTime)
component.NextFire = curTime;

component.NextFire += component.MeleeCooldown;
var meleeCooldown = TimeSpan.FromSeconds(component.MeleeCooldown);

component.NextFire += meleeCooldown;
while (component.NextFire <= curTime)
component.NextFire += component.MeleeCooldown;
component.NextFire += meleeCooldown;

Dirty(uid, component);
}
Expand Down

0 comments on commit e4710c3

Please sign in to comment.