Files
tbd-station-14/Content.Shared/Movement/Systems/WormSystem.cs
Princess Cheeseballs dec2d42a1d Crawling Part 1: The Knockdownening (#36881)
Co-authored-by: slarticodefast <161409025+slarticodefast@users.noreply.github.com>
Co-authored-by: metalgearsloth <comedian_vs_clown@hotmail.com>
Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com>
Co-authored-by: Princess Cheeseballs <66055347+Pronana@users.noreply.github.com>
Co-authored-by: ScarKy0 <scarky0@onet.eu>
2025-07-20 01:54:42 +02:00

54 lines
1.8 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 SharedPopupSystem _popup = 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, 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;
}
}