Defib fixes (#16031)

This commit is contained in:
metalgearsloth
2023-05-03 11:32:06 +10:00
committed by GitHub
parent b9b74eaff9
commit c7c083e9c8
5 changed files with 24 additions and 33 deletions

View File

@@ -56,7 +56,10 @@ public sealed class DefibrillatorSystem : EntitySystem
private void OnUnpaused(EntityUid uid, DefibrillatorComponent component, ref EntityUnpausedEvent args) 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) private void OnUseInHand(EntityUid uid, DefibrillatorComponent component, UseInHandEvent args)
@@ -115,7 +118,7 @@ public sealed class DefibrillatorSystem : EntitySystem
if (component.Enabled) if (component.Enabled)
return false; return false;
if (_powerCell.HasActivatableCharge(uid)) if (!_powerCell.HasActivatableCharge(uid))
return false; return false;
component.Enabled = true; component.Enabled = true;
@@ -248,10 +251,12 @@ public sealed class DefibrillatorSystem : EntitySystem
var query = EntityQueryEnumerator<DefibrillatorComponent>(); var query = EntityQueryEnumerator<DefibrillatorComponent>();
while (query.MoveNext(out var uid, out var defib)) while (query.MoveNext(out var uid, out var defib))
{ {
if (_timing.CurTime < defib.NextZapTime) if (defib.NextZapTime == null || _timing.CurTime < defib.NextZapTime)
continue; continue;
_audio.PlayPvs(defib.ReadySound, uid); _audio.PlayPvs(defib.ReadySound, uid);
_appearance.SetData(uid, DefibrillatorVisuals.Ready, true); _appearance.SetData(uid, DefibrillatorVisuals.Ready, true);
defib.NextZapTime = null;
} }
} }
} }

View File

@@ -24,7 +24,7 @@ public sealed class DefibrillatorComponent : Component
/// The time at which the zap cooldown will be completed /// The time at which the zap cooldown will be completed
/// </summary> /// </summary>
[DataField("nextZapTime", customTypeSerializer: typeof(TimeOffsetSerializer)), ViewVariables(VVAccess.ReadWrite)] [DataField("nextZapTime", customTypeSerializer: typeof(TimeOffsetSerializer)), ViewVariables(VVAccess.ReadWrite)]
public TimeSpan NextZapTime = TimeSpan.Zero; public TimeSpan? NextZapTime;
/// <summary> /// <summary>
/// The minimum time between zaps /// The minimum time between zaps
@@ -62,29 +62,29 @@ public sealed class DefibrillatorComponent : Component
/// <summary> /// <summary>
/// The sound when someone is zapped. /// The sound when someone is zapped.
/// </summary> /// </summary>
[DataField("zapSound")] [ViewVariables(VVAccess.ReadWrite), DataField("zapSound")]
public SoundSpecifier? ZapSound; public SoundSpecifier? ZapSound = new SoundPathSpecifier("/Audio/Items/Defib/defib_zap.ogg");
/// <summary> /// <summary>
/// The sound when the defib is powered on. /// The sound when the defib is powered on.
/// </summary> /// </summary>
[DataField("powerOnSound")] [ViewVariables(VVAccess.ReadWrite), DataField("powerOnSound")]
public SoundSpecifier? PowerOnSound; public SoundSpecifier? PowerOnSound = new SoundPathSpecifier("/Audio/Items/Defib/defib_safety_on.ogg");
[DataField("powerOffSound")] [ViewVariables(VVAccess.ReadWrite), DataField("powerOffSound")]
public SoundSpecifier? PowerOffSound; public SoundSpecifier? PowerOffSound = new SoundPathSpecifier("/Audio/Items/Defib/defib_safety_off.ogg");
[DataField("chargeSound")] [ViewVariables(VVAccess.ReadWrite), DataField("chargeSound")]
public SoundSpecifier? ChargeSound; public SoundSpecifier? ChargeSound = new SoundPathSpecifier("/Audio/Items/Defib/defib_charge.ogg");
[DataField("failureSound")] [ViewVariables(VVAccess.ReadWrite), DataField("failureSound")]
public SoundSpecifier? FailureSound; public SoundSpecifier? FailureSound = new SoundPathSpecifier("/Audio/Items/Defib/defib_failed.ogg");
[DataField("successSound")] [ViewVariables(VVAccess.ReadWrite), DataField("successSound")]
public SoundSpecifier? SuccessSound; public SoundSpecifier? SuccessSound = new SoundPathSpecifier("/Audio/Items/Defib/defib_success.ogg");
[DataField("readySound")] [ViewVariables(VVAccess.ReadWrite), DataField("readySound")]
public SoundSpecifier? ReadySound; public SoundSpecifier? ReadySound = new SoundPathSpecifier("/Audio/Items/Defib/defib_ready.ogg");
} }
[Serializable, NetSerializable] [Serializable, NetSerializable]

View File

@@ -34,20 +34,6 @@
zapHeal: zapHeal:
types: types:
Asphyxiation: -40 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 - type: PowerCellDraw
useRate: 100 useRate: 100
- type: Appearance - type: Appearance