CatStation/Content.Shared/Shuttles/Systems/SharedShuttleConsoleSystem.cs
Pieter-Jan Briers 5168b5f3d4
IoC source gen compatibility (#43863)
* IoC source gen compatibility

Can be merged before or after https://github.com/space-wizards/RobustToolbox/pull/6549 doesn't really matter.

* Missed a spot
2026-05-09 03:29:58 +00:00

52 lines
1.7 KiB
C#

using Content.Shared.ActionBlocker;
using Content.Shared.Movement.Events;
using Content.Shared.Shuttles.BUIStates;
using Content.Shared.Shuttles.Components;
using Robust.Shared.Serialization;
namespace Content.Shared.Shuttles.Systems
{
public abstract partial class SharedShuttleConsoleSystem : EntitySystem
{
[Dependency] protected ActionBlockerSystem ActionBlockerSystem = default!;
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<PilotComponent, UpdateCanMoveEvent>(HandleMovementBlock);
SubscribeLocalEvent<PilotComponent, ComponentStartup>(OnStartup);
SubscribeLocalEvent<PilotComponent, ComponentShutdown>(HandlePilotShutdown);
}
[Serializable, NetSerializable]
protected sealed class PilotComponentState : ComponentState
{
public NetEntity? Console { get; }
public PilotComponentState(NetEntity? uid)
{
Console = uid;
}
}
protected virtual void HandlePilotShutdown(EntityUid uid, PilotComponent component, ComponentShutdown args)
{
ActionBlockerSystem.UpdateCanMove(uid);
}
private void OnStartup(EntityUid uid, PilotComponent component, ComponentStartup args)
{
ActionBlockerSystem.UpdateCanMove(uid);
}
private void HandleMovementBlock(EntityUid uid, PilotComponent component, UpdateCanMoveEvent args)
{
if (component.LifeStage > ComponentLifeStage.Running)
return;
if (component.Console == null)
return;
args.Cancel();
}
}
}