* alert cleanup and API * I expect update loops to be at the top. * Address review * Address review x 2 * Merg my PR * Fix * Update Content.Shared/Alert/AlertsSystem.cs webedit Co-authored-by: Perry Fraser <perryprog@users.noreply.github.com> * FIX THAT TEST FAIL!!!! * Me when I forget to actually give you alerts * Hammedborgar --------- Co-authored-by: Princess Cheeseballs <66055347+Pronana@users.noreply.github.com> Co-authored-by: Perry Fraser <perryprog@users.noreply.github.com>
55 lines
1.8 KiB
C#
55 lines
1.8 KiB
C#
using Content.Shared.Alert;
|
|
using Content.Shared.Inventory;
|
|
using Content.Shared.Strip.Components;
|
|
using Robust.Shared.GameStates;
|
|
|
|
namespace Content.Shared.Strip;
|
|
|
|
public sealed partial class ThievingSystem : EntitySystem
|
|
{
|
|
[Dependency] private readonly AlertsSystem _alertsSystem = default!;
|
|
|
|
public override void Initialize()
|
|
{
|
|
base.Initialize();
|
|
|
|
SubscribeLocalEvent<ThievingComponent, BeforeStripEvent>(OnBeforeStrip);
|
|
SubscribeLocalEvent<ThievingComponent, InventoryRelayedEvent<BeforeStripEvent>>((e, c, ev) =>
|
|
OnBeforeStrip(e, c, ev.Args));
|
|
SubscribeLocalEvent<ThievingComponent, ToggleThievingEvent>(OnToggleStealthy);
|
|
SubscribeLocalEvent<ThievingComponent, ComponentInit>(OnCompInit);
|
|
SubscribeLocalEvent<ThievingComponent, ComponentRemove>(OnCompRemoved);
|
|
}
|
|
|
|
private void OnBeforeStrip(EntityUid uid, ThievingComponent component, BeforeStripEvent args)
|
|
{
|
|
args.Stealth |= component.Stealthy;
|
|
if (args.Stealth)
|
|
{
|
|
args.Additive -= component.StripTimeReduction;
|
|
}
|
|
}
|
|
|
|
private void OnCompInit(Entity<ThievingComponent> entity, ref ComponentInit args)
|
|
{
|
|
_alertsSystem.ShowAlert(entity.Owner, entity.Comp.StealthyAlertProtoId, 1);
|
|
}
|
|
|
|
private void OnCompRemoved(Entity<ThievingComponent> entity, ref ComponentRemove args)
|
|
{
|
|
_alertsSystem.ClearAlert(entity.Owner, entity.Comp.StealthyAlertProtoId);
|
|
}
|
|
|
|
private void OnToggleStealthy(Entity<ThievingComponent> ent, ref ToggleThievingEvent args)
|
|
{
|
|
if (args.Handled)
|
|
return;
|
|
|
|
ent.Comp.Stealthy = !ent.Comp.Stealthy;
|
|
_alertsSystem.ShowAlert(ent.Owner, ent.Comp.StealthyAlertProtoId, (short)(ent.Comp.Stealthy ? 1 : 0));
|
|
DirtyField(ent.AsNullable(), nameof(ent.Comp.Stealthy), null);
|
|
|
|
args.Handled = true;
|
|
}
|
|
}
|