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 08b0647
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
6 changes: 3 additions & 3 deletions Content.Shared/Weapons/Ranged/Components/GunComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -209,10 +209,10 @@ public sealed partial class GunComponent : Component
public TimeSpan NextFire = TimeSpan.Zero;

/// <summary>
/// After dealing a melee attack with this gun, the minimum cooldown before the gun can shoot again.
/// After dealing a melee attack with this gun, the minimum cooldown in seconds 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 08b0647

Please sign in to comment.