Add cooldown to hypospray (#13953)

* added cooldown to hypospray

* moved one of the 'using's over a space

* changed all cooldowns to 0.5 seconds

* resolved suggestions

* minor comment change
This commit is contained in:
Interrobang01
2023-02-27 13:19:52 -08:00
committed by GitHub
parent 68cba24dab
commit 553a46ff90
2 changed files with 18 additions and 0 deletions

View File

@@ -11,12 +11,15 @@ using Content.Shared.Interaction;
using Content.Shared.Interaction.Events; using Content.Shared.Interaction.Events;
using Content.Shared.Mobs.Components; using Content.Shared.Mobs.Components;
using Content.Shared.Weapons.Melee.Events; using Content.Shared.Weapons.Melee.Events;
using Content.Shared.Timing;
using Robust.Shared.Player; using Robust.Shared.Player;
namespace Content.Server.Chemistry.EntitySystems namespace Content.Server.Chemistry.EntitySystems
{ {
public sealed partial class ChemistrySystem public sealed partial class ChemistrySystem
{ {
[Dependency] private readonly UseDelaySystem _useDelay = default!;
private void InitializeHypospray() private void InitializeHypospray()
{ {
SubscribeLocalEvent<HyposprayComponent, AfterInteractEvent>(OnAfterInteract); SubscribeLocalEvent<HyposprayComponent, AfterInteractEvent>(OnAfterInteract);
@@ -65,6 +68,10 @@ namespace Content.Server.Chemistry.EntitySystems
if (!EligibleEntity(target, _entMan)) if (!EligibleEntity(target, _entMan))
return false; return false;
if (TryComp(uid, out UseDelayComponent? delayComp))
if (_useDelay.ActiveDelay(uid, delayComp))
return false;
string? msgFormat = null; string? msgFormat = null;
if (target == user) if (target == user)
@@ -102,6 +109,11 @@ namespace Content.Server.Chemistry.EntitySystems
_audio.PlayPvs(component.InjectSound, user); _audio.PlayPvs(component.InjectSound, user);
// Medipens and such use this system and don't have a delay, requiring extra checks
// BeginDelay function returns if item is already on delay
if (delayComp is not null)
_useDelay.BeginDelay(uid, delayComp);
// Get transfer amount. May be smaller than component.TransferAmount if not enough room // Get transfer amount. May be smaller than component.TransferAmount if not enough room
var realTransferAmount = FixedPoint2.Min(component.TransferAmount, targetSolution.AvailableVolume); var realTransferAmount = FixedPoint2.Min(component.TransferAmount, targetSolution.AvailableVolume);

View File

@@ -18,6 +18,8 @@
- type: ExaminableSolution - type: ExaminableSolution
solution: hypospray solution: hypospray
- type: Hypospray - type: Hypospray
- type: UseDelay
delay: 0.5
- type: StaticPrice - type: StaticPrice
price: 750 price: 750
@@ -41,6 +43,8 @@
- type: ExaminableSolution - type: ExaminableSolution
solution: hypospray solution: hypospray
- type: Hypospray - type: Hypospray
- type: UseDelay
delay: 0.5
- type: entity - type: entity
name: chemical medipen name: chemical medipen
@@ -166,5 +170,7 @@
- type: ExaminableSolution - type: ExaminableSolution
solution: hypospray solution: hypospray
- type: Hypospray - type: Hypospray
- type: UseDelay
delay: 0.5
- type: StaticPrice # A new shitcurity meta - type: StaticPrice # A new shitcurity meta
price: 75 price: 75