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;
///
/// This handles the worm component
///
public sealed class WormSystem : EntitySystem
{
[Dependency] private readonly AlertsSystem _alerts = default!;
[Dependency] private readonly SharedPopupSystem _popup = default!;
[Dependency] private readonly SharedStunSystem _stun = default!;
public override void Initialize()
{
SubscribeLocalEvent(OnStandAttempt);
SubscribeLocalEvent(OnKnockedDownRefresh);
SubscribeLocalEvent(OnRejuvenate);
SubscribeLocalEvent(OnMapInit);
}
private void OnMapInit(Entity ent, ref MapInitEvent args)
{
EnsureComp(ent, out var knocked);
_alerts.ShowAlert(ent, SharedStunSystem.KnockdownAlert);
_stun.SetAutoStand((ent, knocked));
}
private void OnRejuvenate(Entity ent, ref RejuvenateEvent args)
{
RemComp(ent);
}
private void OnStandAttempt(Entity 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 ent, ref KnockedDownRefreshEvent args)
{
args.FrictionModifier *= ent.Comp.FrictionModifier;
args.SpeedModifier *= ent.Comp.SpeedModifier;
}
}