From f8888b09608811c1f3378a88de2837b57bf25d2c Mon Sep 17 00:00:00 2001 From: Vordenburg <114301317+Vordenburg@users.noreply.github.com> Date: Thu, 15 Jun 2023 15:18:38 -0400 Subject: [PATCH] Allow specific entities to bypass DoAfter delays (#17349) * Allow specific entities to bypass DoAfter delays This adds the InstantDoAfters tag to the admin ghost for mappers. * Add specific player prototype for InteractionTest --- .../Tests/Interaction/InteractionTest.cs | 33 +++++++++++++++++-- Content.Shared/DoAfter/SharedDoAfterSystem.cs | 5 ++- .../Entities/Mobs/Player/admin_ghost.yml | 1 + Resources/Prototypes/tags.yml | 3 ++ 4 files changed, 39 insertions(+), 3 deletions(-) diff --git a/Content.IntegrationTests/Tests/Interaction/InteractionTest.cs b/Content.IntegrationTests/Tests/Interaction/InteractionTest.cs index decaacbeea..6b8760bf59 100644 --- a/Content.IntegrationTests/Tests/Interaction/InteractionTest.cs +++ b/Content.IntegrationTests/Tests/Interaction/InteractionTest.cs @@ -38,7 +38,7 @@ namespace Content.IntegrationTests.Tests.Interaction; [FixtureLifeCycle(LifeCycle.InstancePerTestCase)] public abstract partial class InteractionTest { - protected virtual string PlayerPrototype => "AdminObserver"; + protected virtual string PlayerPrototype => "MobInteractionTestObserver"; protected PairTracker PairTracker = default!; protected TestMapData MapData = default!; @@ -118,7 +118,36 @@ public abstract partial class InteractionTest [SetUp] public virtual async Task Setup() { - PairTracker = await PoolManager.GetServerClient(new PoolSettings()); + const string TestPrototypes = @" +- type: entity + id: MobInteractionTestObserver + name: observer + noSpawn: true + save: false + description: Boo! + components: + - type: Access + groups: + - AllAccess + - type: Body + prototype: Aghost + - type: DoAfter + - type: Ghost + canInteract: true + - type: Hands + - type: Mind + - type: Stripping + - type: Tag + tags: + - CanPilot + - BypassInteractionRangeChecks + - type: Thieving + stripTimeReduction: 9999 + stealthy: true + - type: UserInterface +"; + + PairTracker = await PoolManager.GetServerClient(new PoolSettings{ExtraPrototypes = TestPrototypes}); // server dependencies SEntMan = Server.ResolveDependency(); diff --git a/Content.Shared/DoAfter/SharedDoAfterSystem.cs b/Content.Shared/DoAfter/SharedDoAfterSystem.cs index 2a045ffb0d..a6e5ceb7f2 100644 --- a/Content.Shared/DoAfter/SharedDoAfterSystem.cs +++ b/Content.Shared/DoAfter/SharedDoAfterSystem.cs @@ -4,6 +4,7 @@ using Content.Shared.ActionBlocker; using Content.Shared.Damage; using Content.Shared.Hands.Components; using Content.Shared.Mobs; +using Content.Shared.Tag; using Robust.Shared.GameStates; using Robust.Shared.Serialization; using Robust.Shared.Timing; @@ -16,6 +17,7 @@ public abstract partial class SharedDoAfterSystem : EntitySystem [Dependency] protected readonly IGameTiming GameTiming = default!; [Dependency] private readonly ActionBlockerSystem _actionBlocker = default!; [Dependency] private readonly SharedTransformSystem _transform = default!; + [Dependency] private readonly TagSystem _tag = default!; /// /// We'll use an excess time so stuff like finishing effects can show. @@ -221,7 +223,8 @@ public abstract partial class SharedDoAfterSystem : EntitySystem if (args.AttemptFrequency == AttemptFrequency.StartAndEnd && !TryAttemptEvent(doAfter)) return false; - if (args.Delay <= TimeSpan.Zero) + if (args.Delay <= TimeSpan.Zero || + _tag.HasTag(args.User, "InstantDoAfters")) { RaiseDoAfterEvents(doAfter, comp); // We don't store instant do-afters. This is just a lazy way of hiding them from client-side visuals. diff --git a/Resources/Prototypes/Entities/Mobs/Player/admin_ghost.yml b/Resources/Prototypes/Entities/Mobs/Player/admin_ghost.yml index ba06c90a7c..adde069c85 100644 --- a/Resources/Prototypes/Entities/Mobs/Player/admin_ghost.yml +++ b/Resources/Prototypes/Entities/Mobs/Player/admin_ghost.yml @@ -9,6 +9,7 @@ maxZoom: 8.916104, 8.916104 - type: Tag tags: + - InstantDoAfters - CanPilot - BypassInteractionRangeChecks - type: Input diff --git a/Resources/Prototypes/tags.yml b/Resources/Prototypes/tags.yml index 87a6d1e7a1..1c255b80a0 100644 --- a/Resources/Prototypes/tags.yml +++ b/Resources/Prototypes/tags.yml @@ -409,6 +409,9 @@ - type: Tag id: Ingot +- type: Tag + id: InstantDoAfters + - type: Tag id: IntercomElectronics