Add defib event, add fields to be able to disable crit defib and do after movement (#28174)
* Add defib event, add fields to be able to disable crit defib and do after movement * Fix check
This commit is contained in:
@@ -162,6 +162,9 @@ public sealed class DefibrillatorSystem : EntitySystem
|
|||||||
if (_mobState.IsAlive(target, mobState))
|
if (_mobState.IsAlive(target, mobState))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
if (!component.CanDefibCrit && _mobState.IsCritical(target, mobState))
|
||||||
|
return false;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -179,7 +182,8 @@ public sealed class DefibrillatorSystem : EntitySystem
|
|||||||
{
|
{
|
||||||
BlockDuplicate = true,
|
BlockDuplicate = true,
|
||||||
BreakOnHandChange = 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 we don't have enough power left for another shot, turn it off
|
||||||
if (!_powerCell.HasActivatableCharge(uid))
|
if (!_powerCell.HasActivatableCharge(uid))
|
||||||
TryDisable(uid, component);
|
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)
|
public override void Update(float frameTime)
|
||||||
|
|||||||
@@ -60,6 +60,12 @@ public sealed partial class DefibrillatorComponent : Component
|
|||||||
[DataField("doAfterDuration"), ViewVariables(VVAccess.ReadWrite)]
|
[DataField("doAfterDuration"), ViewVariables(VVAccess.ReadWrite)]
|
||||||
public TimeSpan DoAfterDuration = TimeSpan.FromSeconds(3);
|
public TimeSpan DoAfterDuration = TimeSpan.FromSeconds(3);
|
||||||
|
|
||||||
|
[DataField]
|
||||||
|
public bool AllowDoAfterMovement = true;
|
||||||
|
|
||||||
|
[DataField]
|
||||||
|
public bool CanDefibCrit = true;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The sound when someone is zapped.
|
/// The sound when someone is zapped.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
4
Content.Shared/Medical/TargetDefibrillatedEvent.cs
Normal file
4
Content.Shared/Medical/TargetDefibrillatedEvent.cs
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
namespace Content.Shared.Medical;
|
||||||
|
|
||||||
|
[ByRefEvent]
|
||||||
|
public readonly record struct TargetDefibrillatedEvent(EntityUid User, Entity<DefibrillatorComponent> Defibrillator);
|
||||||
Reference in New Issue
Block a user