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>
This commit is contained in:
committed by
GitHub
parent
cfb0a95035
commit
dec2d42a1d
53
Content.Shared/Movement/Systems/WormSystem.cs
Normal file
53
Content.Shared/Movement/Systems/WormSystem.cs
Normal file
@@ -0,0 +1,53 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user