Add cargo shuttle (#8686)
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
using Content.Server.Cargo.Components;
|
||||
using Content.Server.Power.Components;
|
||||
using Content.Server.Power.EntitySystems;
|
||||
using Content.Server.Shuttles.Components;
|
||||
@@ -5,6 +6,7 @@ using Content.Server.Shuttles.Events;
|
||||
using Content.Server.UserInterface;
|
||||
using Content.Shared.ActionBlocker;
|
||||
using Content.Shared.Alert;
|
||||
using Content.Shared.Light;
|
||||
using Content.Shared.Popups;
|
||||
using Content.Shared.Shuttles.BUIStates;
|
||||
using Content.Shared.Shuttles.Components;
|
||||
@@ -136,15 +138,29 @@ namespace Content.Server.Shuttles.Systems
|
||||
/// </summary>
|
||||
private void OnModeRequest(EntityUid uid, ShuttleConsoleComponent component, ShuttleModeRequestMessage args)
|
||||
{
|
||||
var consoleUid = uid;
|
||||
|
||||
if (TryComp<CargoPilotConsoleComponent>(uid, out var cargoPilot) && cargoPilot.Entity != null)
|
||||
{
|
||||
consoleUid = cargoPilot.Entity.Value;
|
||||
}
|
||||
|
||||
if (args.Session.AttachedEntity is not { } player ||
|
||||
!TryComp<PilotComponent>(player, out var pilot) ||
|
||||
!TryComp<TransformComponent>(player, out var xform) ||
|
||||
pilot.Console is not ShuttleConsoleComponent console) return;
|
||||
!TryComp<ShuttleConsoleComponent>(consoleUid, out var console) ||
|
||||
!TryComp<TransformComponent>(consoleUid, out var consoleXform)) return;
|
||||
|
||||
if (!console.SubscribedPilots.Contains(pilot) ||
|
||||
!TryComp<ShuttleComponent>(xform.GridUid, out var shuttle)) return;
|
||||
// Can't check console pilots as it may be remotely piloted!
|
||||
if (!component.SubscribedPilots.Contains(pilot) ||
|
||||
!TryComp<ShuttleComponent>(consoleXform.GridUid, out var shuttle)) return;
|
||||
|
||||
SetShuttleMode(args.Mode, console, shuttle);
|
||||
UpdateState(component);
|
||||
|
||||
if (uid != consoleUid)
|
||||
{
|
||||
UpdateState(console);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -159,7 +175,6 @@ namespace Content.Server.Shuttles.Systems
|
||||
!consoleXform.Anchored ||
|
||||
consoleXform.GridID != Transform(shuttleComponent.Owner).GridID)
|
||||
{
|
||||
UpdateState(consoleComponent);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -174,8 +189,6 @@ namespace Content.Server.Shuttles.Systems
|
||||
default:
|
||||
throw new ArgumentOutOfRangeException();
|
||||
}
|
||||
|
||||
UpdateState(consoleComponent);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -205,10 +218,21 @@ namespace Content.Server.Shuttles.Systems
|
||||
|
||||
private void UpdateState(ShuttleConsoleComponent component, List<DockingInterfaceState>? docks = null)
|
||||
{
|
||||
TryComp<RadarConsoleComponent>(component.Owner, out var radar);
|
||||
EntityUid? entity = component.Owner;
|
||||
|
||||
var getShuttleEv = new ConsoleShuttleEvent
|
||||
{
|
||||
Console = entity,
|
||||
};
|
||||
|
||||
RaiseLocalEvent(entity.Value, ref getShuttleEv, false);
|
||||
entity = getShuttleEv.Console;
|
||||
|
||||
TryComp<TransformComponent>(entity, out var consoleXform);
|
||||
TryComp<RadarConsoleComponent>(entity, out var radar);
|
||||
var range = radar?.MaxRange ?? 0f;
|
||||
|
||||
TryComp<ShuttleComponent>(Transform(component.Owner).GridUid, out var shuttle);
|
||||
TryComp<ShuttleComponent>(consoleXform?.GridUid, out var shuttle);
|
||||
var mode = shuttle?.Mode ?? ShuttleMode.Cruise;
|
||||
|
||||
docks ??= GetAllDocks();
|
||||
@@ -217,7 +241,8 @@ namespace Content.Server.Shuttles.Systems
|
||||
?.SetState(new ShuttleConsoleBoundInterfaceState(
|
||||
mode,
|
||||
range,
|
||||
component.Owner,
|
||||
consoleXform?.Coordinates,
|
||||
consoleXform?.LocalRotation,
|
||||
docks));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user