From: Interrobang01 <113810873+Interrobang01@users.noreply.github.com> Date: Mon, 27 Feb 2023 21:19:52 +0000 (-0800) Subject: Add cooldown to hypospray (#13953) X-Git-Url: https://git.smokeofanarchy.ru/gitweb.cgi?a=commitdiff_plain;h=553a46ff908d2a66341460707503badddff274bc;p=space-station-14.git 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 --- diff --git a/Content.Server/Chemistry/EntitySystems/ChemistrySystemHypospray.cs b/Content.Server/Chemistry/EntitySystems/ChemistrySystemHypospray.cs index 06fd29813b..2e0593ecf1 100644 --- a/Content.Server/Chemistry/EntitySystems/ChemistrySystemHypospray.cs +++ b/Content.Server/Chemistry/EntitySystems/ChemistrySystemHypospray.cs @@ -11,12 +11,15 @@ using Content.Shared.Interaction; using Content.Shared.Interaction.Events; using Content.Shared.Mobs.Components; using Content.Shared.Weapons.Melee.Events; +using Content.Shared.Timing; using Robust.Shared.Player; namespace Content.Server.Chemistry.EntitySystems { public sealed partial class ChemistrySystem { + [Dependency] private readonly UseDelaySystem _useDelay = default!; + private void InitializeHypospray() { SubscribeLocalEvent(OnAfterInteract); @@ -65,6 +68,10 @@ namespace Content.Server.Chemistry.EntitySystems if (!EligibleEntity(target, _entMan)) return false; + if (TryComp(uid, out UseDelayComponent? delayComp)) + if (_useDelay.ActiveDelay(uid, delayComp)) + return false; + string? msgFormat = null; if (target == user) @@ -102,6 +109,11 @@ namespace Content.Server.Chemistry.EntitySystems _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 var realTransferAmount = FixedPoint2.Min(component.TransferAmount, targetSolution.AvailableVolume); diff --git a/Resources/Prototypes/Entities/Objects/Specific/Medical/hypospray.yml b/Resources/Prototypes/Entities/Objects/Specific/Medical/hypospray.yml index 7f77b8f6dd..e871c29775 100644 --- a/Resources/Prototypes/Entities/Objects/Specific/Medical/hypospray.yml +++ b/Resources/Prototypes/Entities/Objects/Specific/Medical/hypospray.yml @@ -18,6 +18,8 @@ - type: ExaminableSolution solution: hypospray - type: Hypospray + - type: UseDelay + delay: 0.5 - type: StaticPrice price: 750 @@ -41,6 +43,8 @@ - type: ExaminableSolution solution: hypospray - type: Hypospray + - type: UseDelay + delay: 0.5 - type: entity name: chemical medipen @@ -166,5 +170,7 @@ - type: ExaminableSolution solution: hypospray - type: Hypospray + - type: UseDelay + delay: 0.5 - type: StaticPrice # A new shitcurity meta price: 75