Defibs will now also shock anyone still interacting with the target. (#35998)
* Defibs will now also shock anyone still interacting with the target. * Improvements to test readability * Apply fixes to other tests * Refactor the interacting entities query to use an event. * Include pullers as interacting with the entity they are pulling * Broadcast event * Use a constant * Convert new test to InteractionTest * Convert existing test * Add behaviour note * Revert "Convert existing test" This reverts commit b8a8f2f68e3733bdb6ec254faf955a42096d47d7. * Move new test into separate (InteractionTest) test file * Use ToServer * Use a constant for prototype id * Use ToServer * Add EntProtoId constructor * Add assertion failure messages * Manual cleanup of test entities * Remove obsolete flag * Add test summaries * Remove tuple constructor * Wrap entity deletion in WaitPost * Extend DoAfter interacting test with an extra mob
This commit is contained in:
@@ -18,6 +18,8 @@ using Content.Shared.Mind;
|
||||
using Content.Shared.Mobs;
|
||||
using Content.Shared.Mobs.Components;
|
||||
using Content.Shared.Mobs.Systems;
|
||||
using Content.Shared.Movement.Pulling.Components;
|
||||
using Content.Shared.PowerCell;
|
||||
using Content.Shared.Timing;
|
||||
using Robust.Shared.Audio.Systems;
|
||||
using Robust.Shared.Player;
|
||||
@@ -44,6 +46,7 @@ public sealed class DefibrillatorSystem : EntitySystem
|
||||
[Dependency] private readonly SharedAudioSystem _audio = default!;
|
||||
[Dependency] private readonly SharedMindSystem _mind = default!;
|
||||
[Dependency] private readonly UseDelaySystem _useDelay = default!;
|
||||
[Dependency] private readonly SharedInteractionSystem _interactionSystem = default!;
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override void Initialize()
|
||||
@@ -179,6 +182,18 @@ public sealed class DefibrillatorSystem : EntitySystem
|
||||
|
||||
_audio.PlayPvs(component.ZapSound, uid);
|
||||
_electrocution.TryDoElectrocution(target, null, component.ZapDamage, component.WritheDuration, true, ignoreInsulation: true);
|
||||
|
||||
var interacters = new HashSet<EntityUid>();
|
||||
_interactionSystem.GetEntitiesInteractingWithTarget(target, interacters);
|
||||
foreach (var other in interacters)
|
||||
{
|
||||
if (other == user)
|
||||
continue;
|
||||
|
||||
// Anyone else still operating on the target gets zapped too
|
||||
_electrocution.TryDoElectrocution(other, null, component.ZapDamage, component.WritheDuration, true);
|
||||
}
|
||||
|
||||
if (!TryComp<UseDelayComponent>(uid, out var useDelay))
|
||||
return;
|
||||
_useDelay.SetLength((uid, useDelay), component.ZapDelay, component.DelayId);
|
||||
|
||||
Reference in New Issue
Block a user