]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Defib fixes (#16031)
authormetalgearsloth <31366439+metalgearsloth@users.noreply.github.com>
Wed, 3 May 2023 01:32:06 +0000 (11:32 +1000)
committerGitHub <noreply@github.com>
Wed, 3 May 2023 01:32:06 +0000 (11:32 +1000)
Content.Server/Medical/DefibrillatorSystem.cs
Content.Shared/Medical/DefibrillatorComponent.cs
Resources/Audio/Items/Defib/defib_safety_off.ogg [moved from Resources/Audio/Items/Defib/defib_saftyOff.ogg with 100% similarity]
Resources/Audio/Items/Defib/defib_safety_on.ogg [moved from Resources/Audio/Items/Defib/defib_SaftyOn.ogg with 100% similarity]
Resources/Prototypes/Entities/Objects/Specific/Medical/defib.yml

index d2dde73b5f64396bbf850c0e210af7a89e5f6c29..2beb0fe1d59977c45c49968306e95b71bf18fdda 100644 (file)
@@ -56,7 +56,10 @@ public sealed class DefibrillatorSystem : EntitySystem
 
     private void OnUnpaused(EntityUid uid, DefibrillatorComponent component, ref EntityUnpausedEvent args)
     {
-        component.NextZapTime += args.PausedTime;
+        if (component.NextZapTime == null)
+            return;
+
+        component.NextZapTime = component.NextZapTime.Value + args.PausedTime;
     }
 
     private void OnUseInHand(EntityUid uid, DefibrillatorComponent component, UseInHandEvent args)
@@ -115,7 +118,7 @@ public sealed class DefibrillatorSystem : EntitySystem
         if (component.Enabled)
             return false;
 
-        if (_powerCell.HasActivatableCharge(uid))
+        if (!_powerCell.HasActivatableCharge(uid))
             return false;
 
         component.Enabled = true;
@@ -248,10 +251,12 @@ public sealed class DefibrillatorSystem : EntitySystem
         var query = EntityQueryEnumerator<DefibrillatorComponent>();
         while (query.MoveNext(out var uid, out var defib))
         {
-            if (_timing.CurTime < defib.NextZapTime)
+            if (defib.NextZapTime == null || _timing.CurTime < defib.NextZapTime)
                 continue;
+
             _audio.PlayPvs(defib.ReadySound, uid);
             _appearance.SetData(uid, DefibrillatorVisuals.Ready, true);
+            defib.NextZapTime = null;
         }
     }
 }
index 05652cb3ed3145d92461328aa4ea5a528300f52e..983c63bc141efba63b0066c0e520746fd69c2cf1 100644 (file)
@@ -24,7 +24,7 @@ public sealed class DefibrillatorComponent : Component
     /// The time at which the zap cooldown will be completed
     /// </summary>
     [DataField("nextZapTime", customTypeSerializer: typeof(TimeOffsetSerializer)), ViewVariables(VVAccess.ReadWrite)]
-    public TimeSpan NextZapTime = TimeSpan.Zero;
+    public TimeSpan? NextZapTime;
 
     /// <summary>
     /// The minimum time between zaps
@@ -62,29 +62,29 @@ public sealed class DefibrillatorComponent : Component
     /// <summary>
     /// The sound when someone is zapped.
     /// </summary>
-    [DataField("zapSound")]
-    public SoundSpecifier? ZapSound;
+    [ViewVariables(VVAccess.ReadWrite), DataField("zapSound")]
+    public SoundSpecifier? ZapSound = new SoundPathSpecifier("/Audio/Items/Defib/defib_zap.ogg");
 
     /// <summary>
     /// The sound when the defib is powered on.
     /// </summary>
-    [DataField("powerOnSound")]
-    public SoundSpecifier? PowerOnSound;
+    [ViewVariables(VVAccess.ReadWrite), DataField("powerOnSound")]
+    public SoundSpecifier? PowerOnSound = new SoundPathSpecifier("/Audio/Items/Defib/defib_safety_on.ogg");
 
-    [DataField("powerOffSound")]
-    public SoundSpecifier? PowerOffSound;
+    [ViewVariables(VVAccess.ReadWrite), DataField("powerOffSound")]
+    public SoundSpecifier? PowerOffSound = new SoundPathSpecifier("/Audio/Items/Defib/defib_safety_off.ogg");
 
-    [DataField("chargeSound")]
-    public SoundSpecifier? ChargeSound;
+    [ViewVariables(VVAccess.ReadWrite), DataField("chargeSound")]
+    public SoundSpecifier? ChargeSound = new SoundPathSpecifier("/Audio/Items/Defib/defib_charge.ogg");
 
-    [DataField("failureSound")]
-    public SoundSpecifier? FailureSound;
+    [ViewVariables(VVAccess.ReadWrite), DataField("failureSound")]
+    public SoundSpecifier? FailureSound = new SoundPathSpecifier("/Audio/Items/Defib/defib_failed.ogg");
 
-    [DataField("successSound")]
-    public SoundSpecifier? SuccessSound;
+    [ViewVariables(VVAccess.ReadWrite), DataField("successSound")]
+    public SoundSpecifier? SuccessSound = new SoundPathSpecifier("/Audio/Items/Defib/defib_success.ogg");
 
-    [DataField("readySound")]
-    public SoundSpecifier? ReadySound;
+    [ViewVariables(VVAccess.ReadWrite), DataField("readySound")]
+    public SoundSpecifier? ReadySound = new SoundPathSpecifier("/Audio/Items/Defib/defib_ready.ogg");
 }
 
 [Serializable, NetSerializable]
index 16e3fa7a22d6bf6cd3840db28e638acad59727b0..09367a5ad69806f2c53dc5592e7ba7be18a471ec 100644 (file)
     zapHeal:
       types:
         Asphyxiation: -40
-    zapSound:
-      path: /Audio/Items/Defib/defib_zap.ogg
-    powerOnSound:
-      path: /Audio/Items/Defib/defib_SaftyOn.ogg
-    powerOffSound:
-      path: /Audio/Items/Defib/defib_saftyOff.ogg
-    chargeSound:
-      path: /Audio/Items/Defib/defib_charge.ogg
-    failureSound:
-      path: /Audio/Items/Defib/defib_failed.ogg
-    successSound:
-      path: /Audio/Items/Defib/defib_success.ogg
-    readySound:
-      path: /Audio/Items/Defib/defib_ready.ogg
   - type: PowerCellDraw
     useRate: 100
   - type: Appearance
@@ -64,4 +50,4 @@
   - type: ItemSlots
     slots:
       cell_slot:
-        name: power-cell-slot-component-slot-name-default 
+        name: power-cell-slot-component-slot-name-default