]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Add cooldown to hypospray (#13953)
authorInterrobang01 <113810873+Interrobang01@users.noreply.github.com>
Mon, 27 Feb 2023 21:19:52 +0000 (13:19 -0800)
committerGitHub <noreply@github.com>
Mon, 27 Feb 2023 21:19:52 +0000 (13:19 -0800)
* 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

Content.Server/Chemistry/EntitySystems/ChemistrySystemHypospray.cs
Resources/Prototypes/Entities/Objects/Specific/Medical/hypospray.yml

index 06fd29813bd8983bab973b80ffc1d9466d608596..2e0593ecf1992bcca858c16a51df09c484743602 100644 (file)
@@ -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<HyposprayComponent, AfterInteractEvent>(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);
 
index 7f77b8f6ddb9600d87b396cc2423069e9e4bd058..e871c29775326a2e98adc3c9f6f6b45e7e20dce6 100644 (file)
@@ -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
   - type: ExaminableSolution
     solution: hypospray
   - type: Hypospray
+  - type: UseDelay
+    delay: 0.5
   - type: StaticPrice # A new shitcurity meta
     price: 75