Make stripping corpses faster. (#11945)

This commit is contained in:
Leon Friedrich
2022-10-16 18:26:28 +13:00
committed by GitHub
parent fce7a3bc67
commit 1c013f826d
4 changed files with 52 additions and 22 deletions

View File

@@ -49,22 +49,36 @@ namespace Content.Shared.Strip.Components
}
}
/// <summary>
/// Used to modify strip times.
/// </summary>
[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;
}
}
/// <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) { }
}
}

View File

@@ -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;
}
}