* 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>
53 lines
1.7 KiB
C#
53 lines
1.7 KiB
C#
using Content.Shared.Alert;
|
|
using Content.Shared.Movement.Components;
|
|
using Content.Shared.Popups;
|
|
using Content.Shared.Rejuvenate;
|
|
using Content.Shared.Stunnable;
|
|
|
|
namespace Content.Shared.Movement.Systems;
|
|
|
|
/// <summary>
|
|
/// This handles the worm component
|
|
/// </summary>
|
|
public sealed class WormSystem : EntitySystem
|
|
{
|
|
[Dependency] private readonly AlertsSystem _alerts = default!;
|
|
[Dependency] private readonly SharedStunSystem _stun = default!;
|
|
|
|
public override void Initialize()
|
|
{
|
|
SubscribeLocalEvent<WormComponent, StandUpAttemptEvent>(OnStandAttempt);
|
|
SubscribeLocalEvent<WormComponent, KnockedDownRefreshEvent>(OnKnockedDownRefresh);
|
|
SubscribeLocalEvent<WormComponent, RejuvenateEvent>(OnRejuvenate);
|
|
SubscribeLocalEvent<WormComponent, MapInitEvent>(OnMapInit);
|
|
}
|
|
|
|
private void OnMapInit(Entity<WormComponent> ent, ref MapInitEvent args)
|
|
{
|
|
EnsureComp<KnockedDownComponent>(ent, out var knocked);
|
|
_alerts.ShowAlert(ent.Owner, SharedStunSystem.KnockdownAlert);
|
|
_stun.SetAutoStand((ent, knocked));
|
|
}
|
|
|
|
private void OnRejuvenate(Entity<WormComponent> ent, ref RejuvenateEvent args)
|
|
{
|
|
RemComp<WormComponent>(ent);
|
|
}
|
|
|
|
private void OnStandAttempt(Entity<WormComponent> ent, ref StandUpAttemptEvent args)
|
|
{
|
|
if (args.Cancelled)
|
|
return;
|
|
|
|
args.Cancelled = true;
|
|
args.Message = (Loc.GetString("worm-component-stand-attempt"), PopupType.SmallCaution);
|
|
args.Autostand = false;
|
|
}
|
|
|
|
private void OnKnockedDownRefresh(Entity<WormComponent> ent, ref KnockedDownRefreshEvent args)
|
|
{
|
|
args.FrictionModifier *= ent.Comp.FrictionModifier;
|
|
args.SpeedModifier *= ent.Comp.SpeedModifier;
|
|
}
|
|
}
|