diff --git a/Content.Server/Strip/StrippableSystem.cs b/Content.Server/Strip/StrippableSystem.cs index 8974c8ae25..4660d4189f 100644 --- a/Content.Server/Strip/StrippableSystem.cs +++ b/Content.Server/Strip/StrippableSystem.cs @@ -174,11 +174,12 @@ namespace Content.Server.Strip return; } - var ev = new BeforeStripEvent(slotDef.StripTime); - RaiseLocalEvent(user, ev); - var finalStripTime = ev.Time + ev.Additive; + var userEv = new BeforeStripEvent(slotDef.StripTime); + RaiseLocalEvent(user, userEv); + var ev = new BeforeGettingStrippedEvent(userEv.Time, userEv.Stealth); + RaiseLocalEvent(component.Owner, ev); - var doAfterArgs = new DoAfterEventArgs(user, finalStripTime, CancellationToken.None, component.Owner) + var doAfterArgs = new DoAfterEventArgs(user, ev.Time, CancellationToken.None, component.Owner) { ExtraCheck = Check, BreakOnStun = true, @@ -298,11 +299,12 @@ namespace Content.Server.Strip return; } - var ev = new BeforeStripEvent(slotDef.StripTime); - RaiseLocalEvent(user, ev); - var finalStripTime = ev.Time + ev.Additive; + var userEv = new BeforeStripEvent(slotDef.StripTime); + RaiseLocalEvent(user, userEv); + var ev = new BeforeGettingStrippedEvent(userEv.Time, userEv.Stealth); + RaiseLocalEvent(component.Owner, ev); - var doAfterArgs = new DoAfterEventArgs(user, finalStripTime, CancellationToken.None, component.Owner) + var doAfterArgs = new DoAfterEventArgs(user, ev.Time, CancellationToken.None, component.Owner) { ExtraCheck = Check, BreakOnStun = true, @@ -365,11 +367,13 @@ namespace Content.Server.Strip return true; } - var ev = new BeforeStripEvent(component.HandStripDelay); - RaiseLocalEvent(user, ev); - var finalStripTime = ev.Time + ev.Additive; - var doAfterArgs = new DoAfterEventArgs(user, finalStripTime, CancellationToken.None, component.Owner) + var userEv = new BeforeStripEvent(component.HandStripDelay); + RaiseLocalEvent(user, userEv); + var ev = new BeforeGettingStrippedEvent(userEv.Time, userEv.Stealth); + RaiseLocalEvent(component.Owner, ev); + + var doAfterArgs = new DoAfterEventArgs(user, ev.Time, CancellationToken.None, component.Owner) { ExtraCheck = Check, BreakOnStun = true, diff --git a/Content.Shared/MobState/EntitySystems/SharedMobStateSystem.cs b/Content.Shared/MobState/EntitySystems/SharedMobStateSystem.cs index b185319226..ea0cb7518e 100644 --- a/Content.Shared/MobState/EntitySystems/SharedMobStateSystem.cs +++ b/Content.Shared/MobState/EntitySystems/SharedMobStateSystem.cs @@ -14,6 +14,7 @@ using Content.Shared.Pulling.Events; using Content.Shared.Speech; using Content.Shared.Standing; using Content.Shared.StatusEffect; +using Content.Shared.Strip.Components; using Content.Shared.Throwing; using Robust.Shared.Physics.Systems; using Robust.Shared.Serialization; @@ -36,6 +37,8 @@ namespace Content.Shared.MobState.EntitySystems SubscribeLocalEvent(OnMobShutdown); SubscribeLocalEvent(OnMobStartup); + SubscribeLocalEvent(OnGettingStripped); + SubscribeLocalEvent(OnChangeDirectionAttempt); SubscribeLocalEvent(OnUseAttempt); SubscribeLocalEvent(OnInteractAttempt); @@ -54,6 +57,15 @@ namespace Content.Shared.MobState.EntitySystems // Note that there's no check for Down attempts because if a mob's in crit or dead, they can be downed... } + private void OnGettingStripped(EntityUid uid, MobStateComponent component, BeforeGettingStrippedEvent args) + { + // Incapacitated or dead targets get stripped two or three times as fast. Makes stripping corpses less tedious. + if (IsDead(uid, component)) + args.Multiplier /= 3; + else if (IsCritical(uid, component)) + args.Multiplier /= 2; + } + private void OnMobStartup(EntityUid uid, MobStateComponent component, ComponentStartup args) { if (component.CurrentState != null && component.CurrentThreshold != null) diff --git a/Content.Shared/Strip/Components/SharedStrippableComponent.cs b/Content.Shared/Strip/Components/SharedStrippableComponent.cs index a40a015e4e..ad8f83b5d6 100644 --- a/Content.Shared/Strip/Components/SharedStrippableComponent.cs +++ b/Content.Shared/Strip/Components/SharedStrippableComponent.cs @@ -49,22 +49,36 @@ namespace Content.Shared.Strip.Components } } - /// - /// Used to modify strip times. - /// - [NetSerializable, Serializable] - public sealed class BeforeStripEvent : EntityEventArgs, IInventoryRelayEvent + public abstract class BaseBeforeStripEvent : EntityEventArgs, IInventoryRelayEvent { public readonly float InitialTime; - public float Time; + public float Time => MathF.Max(InitialTime * Multiplier + Additive, 0f); public float Additive = 0; + public float Multiplier = 1f; public bool Stealth; public SlotFlags TargetSlots { get; } = SlotFlags.GLOVES; - public BeforeStripEvent(float initialTime) + public BaseBeforeStripEvent(float initialTime, bool stealth = false) { - InitialTime = Time = initialTime; + InitialTime = initialTime; + Stealth = stealth; } } + + /// + /// Used to modify strip times. Raised directed at the user. + /// + public sealed class BeforeStripEvent : BaseBeforeStripEvent + { + public BeforeStripEvent(float initialTime, bool stealth = false) : base(initialTime, stealth) { } + } + + /// + /// Used to modify strip times. Raised directed at the target. + /// + public sealed class BeforeGettingStrippedEvent : BaseBeforeStripEvent + { + public BeforeGettingStrippedEvent(float initialTime, bool stealth = false) : base(initialTime, stealth) { } + } } diff --git a/Content.Shared/Strip/ThievingSystem.cs b/Content.Shared/Strip/ThievingSystem.cs index 4a630c5015..9203833f29 100644 --- a/Content.Shared/Strip/ThievingSystem.cs +++ b/Content.Shared/Strip/ThievingSystem.cs @@ -1,4 +1,4 @@ -using Content.Shared.Inventory; +using Content.Shared.Inventory; using Content.Shared.Strip.Components; namespace Content.Shared.Strip; @@ -15,7 +15,7 @@ public sealed class ThievingSystem : EntitySystem private void OnBeforeStrip(EntityUid uid, ThievingComponent component, BeforeStripEvent args) { - args.Stealth = component.Stealthy; + args.Stealth |= component.Stealthy; args.Additive -= component.StealTime; } }