Make stripping corpses faster. (#11945)
This commit is contained in:
@@ -174,11 +174,12 @@ namespace Content.Server.Strip
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var ev = new BeforeStripEvent(slotDef.StripTime);
|
var userEv = new BeforeStripEvent(slotDef.StripTime);
|
||||||
RaiseLocalEvent(user, ev);
|
RaiseLocalEvent(user, userEv);
|
||||||
var finalStripTime = ev.Time + ev.Additive;
|
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,
|
ExtraCheck = Check,
|
||||||
BreakOnStun = true,
|
BreakOnStun = true,
|
||||||
@@ -298,11 +299,12 @@ namespace Content.Server.Strip
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var ev = new BeforeStripEvent(slotDef.StripTime);
|
var userEv = new BeforeStripEvent(slotDef.StripTime);
|
||||||
RaiseLocalEvent(user, ev);
|
RaiseLocalEvent(user, userEv);
|
||||||
var finalStripTime = ev.Time + ev.Additive;
|
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,
|
ExtraCheck = Check,
|
||||||
BreakOnStun = true,
|
BreakOnStun = true,
|
||||||
@@ -365,11 +367,13 @@ namespace Content.Server.Strip
|
|||||||
return true;
|
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,
|
ExtraCheck = Check,
|
||||||
BreakOnStun = true,
|
BreakOnStun = true,
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ using Content.Shared.Pulling.Events;
|
|||||||
using Content.Shared.Speech;
|
using Content.Shared.Speech;
|
||||||
using Content.Shared.Standing;
|
using Content.Shared.Standing;
|
||||||
using Content.Shared.StatusEffect;
|
using Content.Shared.StatusEffect;
|
||||||
|
using Content.Shared.Strip.Components;
|
||||||
using Content.Shared.Throwing;
|
using Content.Shared.Throwing;
|
||||||
using Robust.Shared.Physics.Systems;
|
using Robust.Shared.Physics.Systems;
|
||||||
using Robust.Shared.Serialization;
|
using Robust.Shared.Serialization;
|
||||||
@@ -36,6 +37,8 @@ namespace Content.Shared.MobState.EntitySystems
|
|||||||
SubscribeLocalEvent<MobStateComponent, ComponentShutdown>(OnMobShutdown);
|
SubscribeLocalEvent<MobStateComponent, ComponentShutdown>(OnMobShutdown);
|
||||||
SubscribeLocalEvent<MobStateComponent, ComponentStartup>(OnMobStartup);
|
SubscribeLocalEvent<MobStateComponent, ComponentStartup>(OnMobStartup);
|
||||||
|
|
||||||
|
SubscribeLocalEvent<MobStateComponent, BeforeGettingStrippedEvent>(OnGettingStripped);
|
||||||
|
|
||||||
SubscribeLocalEvent<MobStateComponent, ChangeDirectionAttemptEvent>(OnChangeDirectionAttempt);
|
SubscribeLocalEvent<MobStateComponent, ChangeDirectionAttemptEvent>(OnChangeDirectionAttempt);
|
||||||
SubscribeLocalEvent<MobStateComponent, UseAttemptEvent>(OnUseAttempt);
|
SubscribeLocalEvent<MobStateComponent, UseAttemptEvent>(OnUseAttempt);
|
||||||
SubscribeLocalEvent<MobStateComponent, InteractionAttemptEvent>(OnInteractAttempt);
|
SubscribeLocalEvent<MobStateComponent, InteractionAttemptEvent>(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...
|
// 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)
|
private void OnMobStartup(EntityUid uid, MobStateComponent component, ComponentStartup args)
|
||||||
{
|
{
|
||||||
if (component.CurrentState != null && component.CurrentThreshold != null)
|
if (component.CurrentState != null && component.CurrentThreshold != null)
|
||||||
|
|||||||
@@ -49,22 +49,36 @@ namespace Content.Shared.Strip.Components
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
public abstract class BaseBeforeStripEvent : EntityEventArgs, IInventoryRelayEvent
|
||||||
/// Used to modify strip times.
|
|
||||||
/// </summary>
|
|
||||||
[NetSerializable, Serializable]
|
|
||||||
public sealed class BeforeStripEvent : EntityEventArgs, IInventoryRelayEvent
|
|
||||||
{
|
{
|
||||||
public readonly float InitialTime;
|
public readonly float InitialTime;
|
||||||
public float Time;
|
public float Time => MathF.Max(InitialTime * Multiplier + Additive, 0f);
|
||||||
public float Additive = 0;
|
public float Additive = 0;
|
||||||
|
public float Multiplier = 1f;
|
||||||
public bool Stealth;
|
public bool Stealth;
|
||||||
|
|
||||||
public SlotFlags TargetSlots { get; } = SlotFlags.GLOVES;
|
public SlotFlags TargetSlots { get; } = SlotFlags.GLOVES;
|
||||||
|
|
||||||
public BeforeStripEvent(float initialTime)
|
public BaseBeforeStripEvent(float initialTime, bool stealth = false)
|
||||||
{
|
{
|
||||||
InitialTime = Time = initialTime;
|
InitialTime = initialTime;
|
||||||
|
Stealth = stealth;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Used to modify strip times. Raised directed at the user.
|
||||||
|
/// </summary>
|
||||||
|
public sealed class BeforeStripEvent : BaseBeforeStripEvent
|
||||||
|
{
|
||||||
|
public BeforeStripEvent(float initialTime, bool stealth = false) : base(initialTime, stealth) { }
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Used to modify strip times. Raised directed at the target.
|
||||||
|
/// </summary>
|
||||||
|
public sealed class BeforeGettingStrippedEvent : BaseBeforeStripEvent
|
||||||
|
{
|
||||||
|
public BeforeGettingStrippedEvent(float initialTime, bool stealth = false) : base(initialTime, stealth) { }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
using Content.Shared.Inventory;
|
using Content.Shared.Inventory;
|
||||||
using Content.Shared.Strip.Components;
|
using Content.Shared.Strip.Components;
|
||||||
|
|
||||||
namespace Content.Shared.Strip;
|
namespace Content.Shared.Strip;
|
||||||
@@ -15,7 +15,7 @@ public sealed class ThievingSystem : EntitySystem
|
|||||||
|
|
||||||
private void OnBeforeStrip(EntityUid uid, ThievingComponent component, BeforeStripEvent args)
|
private void OnBeforeStrip(EntityUid uid, ThievingComponent component, BeforeStripEvent args)
|
||||||
{
|
{
|
||||||
args.Stealth = component.Stealthy;
|
args.Stealth |= component.Stealthy;
|
||||||
args.Additive -= component.StealTime;
|
args.Additive -= component.StealTime;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user