multi-gun nerf (#20194)
This commit is contained in:
@@ -104,6 +104,12 @@ public partial class GunComponent : Component
|
||||
[AutoNetworkedField]
|
||||
public float FireRate = 8f;
|
||||
|
||||
/// <summary>
|
||||
/// Starts fire cooldown when equipped if true.
|
||||
/// </summary>
|
||||
[ViewVariables(VVAccess.ReadWrite), DataField("resetOnHandSelected")]
|
||||
public bool ResetOnHandSelected = true;
|
||||
|
||||
/// <summary>
|
||||
/// How fast the projectile moves.
|
||||
/// </summary>
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using Content.Shared.Actions;
|
||||
using Content.Shared.Examine;
|
||||
using Content.Shared.Hands;
|
||||
using Content.Shared.Verbs;
|
||||
using Content.Shared.Weapons.Ranged.Components;
|
||||
using Robust.Shared.Utility;
|
||||
@@ -103,4 +104,27 @@ public abstract partial class SharedGunSystem
|
||||
{
|
||||
SelectFire(uid, component, args.Mode, args.Performer);
|
||||
}
|
||||
|
||||
private void OnGunSelected(EntityUid uid, GunComponent component, HandSelectedEvent args)
|
||||
{
|
||||
var fireDelay = 1f / component.FireRate;
|
||||
if (fireDelay.Equals(0f))
|
||||
return;
|
||||
|
||||
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(fireDelay);
|
||||
|
||||
if (minimum < component.NextFire)
|
||||
return;
|
||||
|
||||
component.NextFire = minimum;
|
||||
Dirty(uid, component);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ using Content.Shared.Containers.ItemSlots;
|
||||
using Content.Shared.Damage;
|
||||
using Content.Shared.Examine;
|
||||
using Content.Shared.Gravity;
|
||||
using Content.Shared.Hands;
|
||||
using Content.Shared.Hands.Components;
|
||||
using Content.Shared.Popups;
|
||||
using Content.Shared.Projectiles;
|
||||
@@ -88,6 +89,7 @@ public abstract partial class SharedGunSystem : EntitySystem
|
||||
SubscribeLocalEvent<GunComponent, GetVerbsEvent<AlternativeVerb>>(OnAltVerb);
|
||||
SubscribeLocalEvent<GunComponent, ExaminedEvent>(OnExamine);
|
||||
SubscribeLocalEvent<GunComponent, CycleModeEvent>(OnCycleMode);
|
||||
SubscribeLocalEvent<GunComponent, HandSelectedEvent>(OnGunSelected);
|
||||
SubscribeLocalEvent<GunComponent, EntityUnpausedEvent>(OnGunUnpaused);
|
||||
|
||||
#if DEBUG
|
||||
|
||||
Reference in New Issue
Block a user