Files
wwdpublic/Content.Shared/Strip/ThievingSystem.cs
SimpleStation14 89a6bb3ab5 Mirror: StrippableSystem doafter overhaul (#205)
## Mirror of PR #25994: [StrippableSystem doafter
overhaul](https://github.com/space-wizards/space-station-14/pull/25994)
from <img src="https://avatars.githubusercontent.com/u/10567778?v=4"
alt="space-wizards" width="22"/>
[space-wizards](https://github.com/space-wizards)/[space-station-14](https://github.com/space-wizards/space-station-14)

###### `41ca8f3dfcb986432e1e509247bf239cac137836`

PR opened by <img
src="https://avatars.githubusercontent.com/u/42424291?v=4"
width="16"/><a href="https://github.com/Krunklehorn"> Krunklehorn</a> at
2024-03-11 12:36:28 UTC

---

PR changed 7 files with 465 additions and 305 deletions.

The PR had the following labels:
- Status: Needs Review


---

<details open="true"><summary><h1>Original Body</h1></summary>

> ## About the PR
> 
> Refactors Strippable DoAfter events to make them synchronous and
organized.
> 
> 
> ## Technical details
> 
> ### Strippable System & Component
> - Synchronous DoAfters
> - Made use of `TimeSpan`, `GetStripTimeModifiers()` and `ByRefEvent`
> - Reorganized checks, removed some redundant ones
> - Resolve pattern where useful
> - Added more asserts
> - Lots of cleanup
> 
> The DoAfters were grouped under one event to avoid copy-pasting eight
separate cancel checks, asserts and function signatures.
> 
> Let me know if this is bad for performance and I'll roll them out
instead.
> 
> 
> ## Media
> 
> - [x] I have added screenshots/videos to this PR showcasing its
changes ingame, **or** this PR does not require an ingame showcase
> 
> 
> ## Breaking changes
> 
> ### TimeSpans
> `ThievingComponent`, `InventoryTemplatePrototype` and
`ToggleableClothingSystem` use `TimeSpan` in places where they intersect
with `StrippableComponent`.
> 
> 
> **Changelog**
> 
> N/A
> 


</details>

Signed-off-by: VMSolidus <evilexecutive@gmail.com>
Co-authored-by: SimpleStation14 <Unknown>
Co-authored-by: VMSolidus <evilexecutive@gmail.com>
2024-07-01 14:37:45 -04:00

24 lines
690 B
C#

using Content.Shared.Inventory;
using Content.Shared.Strip;
using Content.Shared.Strip.Components;
namespace Content.Shared.Strip;
public sealed class ThievingSystem : EntitySystem
{
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<ThievingComponent, BeforeStripEvent>(OnBeforeStrip);
SubscribeLocalEvent<ThievingComponent, InventoryRelayedEvent<BeforeStripEvent>>((e, c, ev) => OnBeforeStrip(e, c, ev.Args));
}
private void OnBeforeStrip(EntityUid uid, ThievingComponent component, BeforeStripEvent args)
{
args.Stealth |= component.Stealthy;
args.Additive -= component.StripTimeReduction;
}
}