]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Add defib event, add fields to be able to disable crit defib and do after movement...
authorDrSmugleaf <10968691+DrSmugleaf@users.noreply.github.com>
Tue, 21 May 2024 12:11:49 +0000 (05:11 -0700)
committerGitHub <noreply@github.com>
Tue, 21 May 2024 12:11:49 +0000 (14:11 +0200)
* Add defib event, add fields to be able to disable crit defib and do after movement

* Fix check

Content.Server/Medical/DefibrillatorSystem.cs
Content.Shared/Medical/DefibrillatorComponent.cs
Content.Shared/Medical/TargetDefibrillatedEvent.cs [new file with mode: 0644]

index 64861fdc515894d22ac96fd303b372a61fe25560..4373532f0186c7fe213176316409a50a0680f8c3 100644 (file)
@@ -162,6 +162,9 @@ public sealed class DefibrillatorSystem : EntitySystem
         if (_mobState.IsAlive(target, mobState))
             return false;
 
+        if (!component.CanDefibCrit && _mobState.IsCritical(target, mobState))
+            return false;
+
         return true;
     }
 
@@ -179,7 +182,8 @@ public sealed class DefibrillatorSystem : EntitySystem
             {
                 BlockDuplicate = true,
                 BreakOnHandChange = true,
-                NeedHand = true
+                NeedHand = true,
+                BreakOnMove = !component.AllowDoAfterMovement
             });
     }
 
@@ -254,6 +258,10 @@ public sealed class DefibrillatorSystem : EntitySystem
         // if we don't have enough power left for another shot, turn it off
         if (!_powerCell.HasActivatableCharge(uid))
             TryDisable(uid, component);
+
+        // TODO clean up this clown show above
+        var ev = new TargetDefibrillatedEvent(user, (uid, component));
+        RaiseLocalEvent(target, ref ev);
     }
 
     public override void Update(float frameTime)
index 2da5285285473dd31527ae15dedbd4800328e74f..61a02187d09be615be097ae1dcef5e31fa7b2721 100644 (file)
@@ -60,6 +60,12 @@ public sealed partial class DefibrillatorComponent : Component
     [DataField("doAfterDuration"), ViewVariables(VVAccess.ReadWrite)]
     public TimeSpan DoAfterDuration = TimeSpan.FromSeconds(3);
 
+    [DataField]
+    public bool AllowDoAfterMovement = true;
+
+    [DataField]
+    public bool CanDefibCrit = true;
+
     /// <summary>
     /// The sound when someone is zapped.
     /// </summary>
diff --git a/Content.Shared/Medical/TargetDefibrillatedEvent.cs b/Content.Shared/Medical/TargetDefibrillatedEvent.cs
new file mode 100644 (file)
index 0000000..60d1a21
--- /dev/null
@@ -0,0 +1,4 @@
+namespace Content.Shared.Medical;
+
+[ByRefEvent]
+public readonly record struct TargetDefibrillatedEvent(EntityUid User, Entity<DefibrillatorComponent> Defibrillator);