2022-04-10 16:48:11 +12:00
|
|
|
using Content.Shared.ActionBlocker;
|
2022-06-24 17:44:30 +10:00
|
|
|
using Content.Shared.Movement.Events;
|
2024-03-03 18:39:19 +11:00
|
|
|
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;
|
2021-07-21 21:15:12 +10:00
|
|
|
|
2022-06-16 15:28:16 +10:00
|
|
|
namespace Content.Shared.Shuttles.Systems
|
2021-07-21 21:15:12 +10:00
|
|
|
{
|
|
|
|
|
public abstract class SharedShuttleConsoleSystem : EntitySystem
|
|
|
|
|
{
|
2022-04-10 16:48:11 +12:00
|
|
|
[Dependency] protected readonly ActionBlockerSystem ActionBlockerSystem = default!;
|
|
|
|
|
|
2021-07-21 21:15:12 +10:00
|
|
|
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]
|
2022-06-16 15:28:16 +10:00
|
|
|
protected sealed class PilotComponentState : ComponentState
|
2022-05-21 14:51:49 +10:00
|
|
|
{
|
2023-09-11 09:42:41 +10:00
|
|
|
public NetEntity? Console { get; }
|
2022-05-21 14:51:49 +10:00
|
|
|
|
2023-09-11 09:42:41 +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);
|
2021-07-21 21:15:12 +10:00
|
|
|
}
|
|
|
|
|
|
2022-04-10 16:48:11 +12:00
|
|
|
private void OnStartup(EntityUid uid, PilotComponent component, ComponentStartup args)
|
2021-07-21 21:15:12 +10:00
|
|
|
{
|
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
|
|
|
|
2021-07-21 21:15:12 +10:00
|
|
|
args.Cancel();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|