Files
OldThink/Content.Shared/Shuttles/Systems/SharedShuttleConsoleSystem.cs

53 lines
1.7 KiB
C#
Raw Normal View History

2022-04-10 16:48:11 +12:00
using Content.Shared.ActionBlocker;
using Content.Shared.Movement.Events;
using Content.Shared.Shuttles.BUIStates;
2021-11-21 17:09:49 +11:00
using Content.Shared.Shuttles.Components;
2022-05-21 14:51:49 +10:00
using Robust.Shared.Serialization;
namespace Content.Shared.Shuttles.Systems
{
public abstract class SharedShuttleConsoleSystem : EntitySystem
{
2022-04-10 16:48:11 +12:00
[Dependency] protected readonly ActionBlockerSystem ActionBlockerSystem = default!;
public override void Initialize()
{
base.Initialize();
2022-04-10 16:48:11 +12:00
SubscribeLocalEvent<PilotComponent, UpdateCanMoveEvent>(HandleMovementBlock);
SubscribeLocalEvent<PilotComponent, ComponentStartup>(OnStartup);
SubscribeLocalEvent<PilotComponent, ComponentShutdown>(HandlePilotShutdown);
2022-05-21 14:51:49 +10:00
}
[Serializable, NetSerializable]
protected sealed class PilotComponentState : ComponentState
2022-05-21 14:51:49 +10:00
{
public NetEntity? Console { get; }
2022-05-21 14:51:49 +10:00
public PilotComponentState(NetEntity? uid)
2022-05-21 14:51:49 +10:00
{
Console = uid;
}
2022-04-10 16:48:11 +12:00
}
protected virtual void HandlePilotShutdown(EntityUid uid, PilotComponent component, ComponentShutdown args)
{
ActionBlockerSystem.UpdateCanMove(uid);
}
2022-04-10 16:48:11 +12:00
private void OnStartup(EntityUid uid, PilotComponent component, ComponentStartup args)
{
2022-04-10 16:48:11 +12:00
ActionBlockerSystem.UpdateCanMove(uid);
}
private void HandleMovementBlock(EntityUid uid, PilotComponent component, UpdateCanMoveEvent args)
{
if (component.LifeStage > ComponentLifeStage.Running)
return;
2023-07-08 09:02:17 -07:00
if (component.Console == null)
return;
2022-04-10 16:48:11 +12:00
args.Cancel();
}
}
}