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:
@@ -4,6 +4,7 @@ using Content.Shared.ActionBlocker;
|
||||
using Content.Shared.Damage;
|
||||
using Content.Shared.Damage.Systems;
|
||||
using Content.Shared.Hands.Components;
|
||||
using Content.Shared.Interaction;
|
||||
using Content.Shared.Tag;
|
||||
using Robust.Shared.GameStates;
|
||||
using Robust.Shared.Prototypes;
|
||||
@@ -35,6 +36,7 @@ public abstract partial class SharedDoAfterSystem : EntitySystem
|
||||
SubscribeLocalEvent<DoAfterComponent, EntityUnpausedEvent>(OnUnpaused);
|
||||
SubscribeLocalEvent<DoAfterComponent, ComponentGetState>(OnDoAfterGetState);
|
||||
SubscribeLocalEvent<DoAfterComponent, ComponentHandleState>(OnDoAfterHandleState);
|
||||
SubscribeLocalEvent<GetInteractingEntitiesEvent>(OnGetInteractingEntities);
|
||||
}
|
||||
|
||||
private void OnUnpaused(EntityUid uid, DoAfterComponent component, ref EntityUnpausedEvent args)
|
||||
@@ -131,6 +133,25 @@ public abstract partial class SharedDoAfterSystem : EntitySystem
|
||||
EnsureComp<ActiveDoAfterComponent>(uid);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds entities which have an active DoAfter matching the target.
|
||||
/// </summary>
|
||||
private void OnGetInteractingEntities(ref GetInteractingEntitiesEvent args)
|
||||
{
|
||||
var enumerator = EntityQueryEnumerator<ActiveDoAfterComponent, DoAfterComponent>();
|
||||
while (enumerator.MoveNext(out _, out var comp))
|
||||
{
|
||||
foreach (var doAfter in comp.DoAfters.Values)
|
||||
{
|
||||
if (doAfter.Cancelled || doAfter.Completed)
|
||||
continue;
|
||||
|
||||
if (doAfter.Args.Target == args.Target)
|
||||
args.InteractingEntities.Add(doAfter.Args.User);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#region Creation
|
||||
/// <summary>
|
||||
/// Tasks that are delayed until the specified time has passed
|
||||
|
||||
Reference in New Issue
Block a user