Add docking window to shuttle consoles (#8756)
* lewd * A * Realtime * Sleepy dork * Draw radar position * Accurate infiltrator * experiments * Better drawing * Labels * I need aan adult * Cleanup * Show toggles * display I guess * A * fix * fix * cleanupsies * Bit more polish * Make sure mass scanners actually work * Remove dummy state * fren * opposite * aghost crash * comment * What's in a name * woops * Show docking ports * Dock highlighting * Drawing dock * Shitty docks * Lots of docking drawing * Autodock working * dork * More graceful shutdown * zoomies * Lines and distance change * revert * Good enough * cleanup * Fix default range * Dock UI and loc update * Update on undock * Loc fixes
This commit is contained in:
14
Content.Server/Shuttles/Components/AutoDockComponent.cs
Normal file
14
Content.Server/Shuttles/Components/AutoDockComponent.cs
Normal file
@@ -0,0 +1,14 @@
|
||||
namespace Content.Server.Shuttles.Components;
|
||||
|
||||
/// <summary>
|
||||
/// Added to entities when they are actively trying to dock with something else.
|
||||
/// We track it because checking every dock constantly would be expensive.
|
||||
/// </summary>
|
||||
[RegisterComponent]
|
||||
public sealed class AutoDockComponent : Component
|
||||
{
|
||||
/// <summary>
|
||||
/// Track who has requested autodocking so we can know when to be removed.
|
||||
/// </summary>
|
||||
public HashSet<EntityUid> Requesters = new();
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
namespace Content.Server.Shuttles.Components;
|
||||
|
||||
/// <summary>
|
||||
/// Added to <see cref="DockingComponent"/> that have recently undocked.
|
||||
/// This checks for whether they've left the specified radius before allowing them to automatically dock again.
|
||||
/// </summary>
|
||||
[RegisterComponent]
|
||||
public sealed class RecentlyDockedComponent : Component
|
||||
{
|
||||
[ViewVariables, DataField("lastDocked")]
|
||||
public EntityUid LastDocked;
|
||||
|
||||
[ViewVariables(VVAccess.ReadWrite), DataField("radius")]
|
||||
public float Radius = 1.5f;
|
||||
}
|
||||
@@ -3,8 +3,14 @@ using Content.Shared.Shuttles.Components;
|
||||
namespace Content.Server.Shuttles.Components
|
||||
{
|
||||
[RegisterComponent]
|
||||
public sealed class ShuttleComponent : SharedShuttleComponent
|
||||
public sealed class ShuttleComponent : Component
|
||||
{
|
||||
[ViewVariables]
|
||||
public bool Enabled = true;
|
||||
|
||||
[ViewVariables]
|
||||
public ShuttleMode Mode = ShuttleMode.Cruise;
|
||||
|
||||
/// <summary>
|
||||
/// The cached thrust available for each cardinal direction
|
||||
/// </summary>
|
||||
|
||||
@@ -3,17 +3,10 @@ using Content.Shared.Shuttles.Components;
|
||||
namespace Content.Server.Shuttles.Components
|
||||
{
|
||||
[RegisterComponent]
|
||||
[ComponentReference(typeof(SharedShuttleConsoleComponent))]
|
||||
internal sealed class ShuttleConsoleComponent : SharedShuttleConsoleComponent
|
||||
public sealed class ShuttleConsoleComponent : SharedShuttleConsoleComponent
|
||||
{
|
||||
[ViewVariables]
|
||||
public List<PilotComponent> SubscribedPilots = new();
|
||||
|
||||
/// <summary>
|
||||
/// Whether the console can be used to pilot. Toggled whenever it gets powered / unpowered.
|
||||
/// </summary>
|
||||
[ViewVariables]
|
||||
public bool Enabled { get; set; } = false;
|
||||
public readonly List<PilotComponent> SubscribedPilots = new();
|
||||
|
||||
/// <summary>
|
||||
/// How much should the pilot's eye be zoomed by when piloting using this console?
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using Content.Server.Shuttles.EntitySystems;
|
||||
using Content.Server.Shuttles.Systems;
|
||||
using Content.Shared.Damage;
|
||||
|
||||
namespace Content.Server.Shuttles.Components
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
using Content.Server.Administration;
|
||||
using Content.Server.Shuttles.Components;
|
||||
using Content.Server.Shuttles.EntitySystems;
|
||||
using Content.Server.Shuttles.Systems;
|
||||
using Content.Shared.Administration;
|
||||
using Robust.Shared.Console;
|
||||
|
||||
|
||||
@@ -1,250 +0,0 @@
|
||||
using Content.Server.Popups;
|
||||
using Content.Server.Power.Components;
|
||||
using Content.Server.Power.EntitySystems;
|
||||
using Content.Server.Shuttles.Components;
|
||||
using Content.Shared.ActionBlocker;
|
||||
using Content.Shared.Alert;
|
||||
using Content.Shared.Interaction;
|
||||
using Content.Shared.Popups;
|
||||
using Content.Shared.Shuttles;
|
||||
using Content.Shared.Shuttles.Components;
|
||||
using Content.Shared.Tag;
|
||||
using Content.Shared.Verbs;
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Shared.Player;
|
||||
using Robust.Shared.Utility;
|
||||
|
||||
namespace Content.Server.Shuttles.EntitySystems
|
||||
{
|
||||
internal sealed class ShuttleConsoleSystem : SharedShuttleConsoleSystem
|
||||
{
|
||||
[Dependency] private readonly IMapManager _mapManager = default!;
|
||||
[Dependency] private readonly ActionBlockerSystem _blocker = default!;
|
||||
[Dependency] private readonly AlertsSystem _alertsSystem = default!;
|
||||
[Dependency] private readonly PopupSystem _popup = default!;
|
||||
[Dependency] private readonly TagSystem _tags = default!;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
|
||||
SubscribeLocalEvent<ShuttleConsoleComponent, ComponentShutdown>(HandleConsoleShutdown);
|
||||
SubscribeLocalEvent<ShuttleConsoleComponent, ActivateInWorldEvent>(HandleConsoleInteract);
|
||||
SubscribeLocalEvent<ShuttleConsoleComponent, PowerChangedEvent>(HandlePowerChange);
|
||||
SubscribeLocalEvent<ShuttleConsoleComponent, GetVerbsEvent<InteractionVerb>>(OnConsoleInteract);
|
||||
|
||||
SubscribeLocalEvent<PilotComponent, MoveEvent>(HandlePilotMove);
|
||||
}
|
||||
|
||||
private void OnConsoleInteract(EntityUid uid, ShuttleConsoleComponent component, GetVerbsEvent<InteractionVerb> args)
|
||||
{
|
||||
if (!args.CanAccess ||
|
||||
!args.CanInteract)
|
||||
return;
|
||||
|
||||
var xform = EntityManager.GetComponent<TransformComponent>(uid);
|
||||
|
||||
// Maybe move mode onto the console instead?
|
||||
if (!_mapManager.TryGetGrid(xform.GridEntityId, out var grid) ||
|
||||
!EntityManager.TryGetComponent(grid.GridEntityId, out ShuttleComponent? shuttle)) return;
|
||||
|
||||
InteractionVerb verb = new()
|
||||
{
|
||||
Text = Loc.GetString("shuttle-mode-toggle"),
|
||||
Act = () => ToggleShuttleMode(args.User, component, shuttle),
|
||||
Disabled = !xform.Anchored || !this.IsPowered(uid, EntityManager),
|
||||
};
|
||||
|
||||
args.Verbs.Add(verb);
|
||||
}
|
||||
|
||||
private void ToggleShuttleMode(EntityUid user, ShuttleConsoleComponent consoleComponent, ShuttleComponent shuttleComponent, TransformComponent? consoleXform = null)
|
||||
{
|
||||
// Re-validate
|
||||
if (!this.IsPowered(consoleComponent.Owner, EntityManager)) return;
|
||||
|
||||
if (!Resolve(consoleComponent.Owner, ref consoleXform)) return;
|
||||
|
||||
if (!consoleXform.Anchored || consoleXform.GridEntityId != EntityManager.GetComponent<TransformComponent>(shuttleComponent.Owner).GridEntityId) return;
|
||||
|
||||
switch (shuttleComponent.Mode)
|
||||
{
|
||||
case ShuttleMode.Cruise:
|
||||
shuttleComponent.Mode = ShuttleMode.Docking;
|
||||
_popup.PopupEntity(Loc.GetString("shuttle-mode-docking"), consoleComponent.Owner, Filter.Entities(user));
|
||||
break;
|
||||
case ShuttleMode.Docking:
|
||||
shuttleComponent.Mode = ShuttleMode.Cruise;
|
||||
_popup.PopupEntity(Loc.GetString("shuttle-mode-cruise"), consoleComponent.Owner, Filter.Entities(user));
|
||||
break;
|
||||
default:
|
||||
throw new ArgumentOutOfRangeException();
|
||||
}
|
||||
}
|
||||
|
||||
public override void Update(float frameTime)
|
||||
{
|
||||
base.Update(frameTime);
|
||||
|
||||
var toRemove = new RemQueue<PilotComponent>();
|
||||
|
||||
foreach (var comp in EntityManager.EntityQuery<PilotComponent>())
|
||||
{
|
||||
if (comp.Console == null) continue;
|
||||
|
||||
if (!_blocker.CanInteract(comp.Owner, comp.Console.Owner))
|
||||
{
|
||||
toRemove.Add(comp);
|
||||
}
|
||||
}
|
||||
|
||||
foreach (var comp in toRemove)
|
||||
{
|
||||
RemovePilot(comp);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Console requires power to operate.
|
||||
/// </summary>
|
||||
private void HandlePowerChange(EntityUid uid, ShuttleConsoleComponent component, PowerChangedEvent args)
|
||||
{
|
||||
if (!args.Powered)
|
||||
{
|
||||
component.Enabled = false;
|
||||
|
||||
ClearPilots(component);
|
||||
}
|
||||
else
|
||||
{
|
||||
component.Enabled = true;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// If pilot is moved then we'll stop them from piloting.
|
||||
/// </summary>
|
||||
private void HandlePilotMove(EntityUid uid, PilotComponent component, ref MoveEvent args)
|
||||
{
|
||||
if (component.Console == null || component.Position == null)
|
||||
{
|
||||
DebugTools.Assert(component.Position == null && component.Console == null);
|
||||
EntityManager.RemoveComponent<PilotComponent>(uid);
|
||||
return;
|
||||
}
|
||||
|
||||
if (args.NewPosition.TryDistance(EntityManager, component.Position.Value, out var distance) &&
|
||||
distance < PilotComponent.BreakDistance) return;
|
||||
|
||||
RemovePilot(component);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// For now pilots just interact with the console and can start piloting with wasd.
|
||||
/// </summary>
|
||||
private void HandleConsoleInteract(EntityUid uid, ShuttleConsoleComponent component, ActivateInWorldEvent args)
|
||||
{
|
||||
if (!_tags.HasTag(args.User, "CanPilot"))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var pilotComponent = EntityManager.EnsureComponent<PilotComponent>(args.User);
|
||||
|
||||
if (!component.Enabled)
|
||||
{
|
||||
args.User.PopupMessage($"Console is not powered.");
|
||||
return;
|
||||
}
|
||||
|
||||
args.Handled = true;
|
||||
var console = pilotComponent.Console;
|
||||
|
||||
if (console != null)
|
||||
{
|
||||
RemovePilot(pilotComponent);
|
||||
|
||||
if (console == component)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
AddPilot(args.User, component);
|
||||
}
|
||||
|
||||
protected override void HandlePilotShutdown(EntityUid uid, PilotComponent component, ComponentShutdown args)
|
||||
{
|
||||
base.HandlePilotShutdown(uid, component, args);
|
||||
RemovePilot(component);
|
||||
}
|
||||
|
||||
private void HandleConsoleShutdown(EntityUid uid, ShuttleConsoleComponent component, ComponentShutdown args)
|
||||
{
|
||||
ClearPilots(component);
|
||||
}
|
||||
|
||||
public void AddPilot(EntityUid entity, ShuttleConsoleComponent component)
|
||||
{
|
||||
if (!EntityManager.TryGetComponent(entity, out PilotComponent? pilotComponent) ||
|
||||
component.SubscribedPilots.Contains(pilotComponent))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (TryComp<SharedEyeComponent>(entity, out var eye))
|
||||
{
|
||||
eye.Zoom = component.Zoom;
|
||||
}
|
||||
|
||||
component.SubscribedPilots.Add(pilotComponent);
|
||||
|
||||
_alertsSystem.ShowAlert(entity, AlertType.PilotingShuttle);
|
||||
|
||||
entity.PopupMessage(Loc.GetString("shuttle-pilot-start"));
|
||||
pilotComponent.Console = component;
|
||||
ActionBlockerSystem.UpdateCanMove(entity);
|
||||
pilotComponent.Position = EntityManager.GetComponent<TransformComponent>(entity).Coordinates;
|
||||
pilotComponent.Dirty();
|
||||
}
|
||||
|
||||
public void RemovePilot(PilotComponent pilotComponent)
|
||||
{
|
||||
var console = pilotComponent.Console;
|
||||
|
||||
if (console is not ShuttleConsoleComponent helmsman) return;
|
||||
|
||||
pilotComponent.Console = null;
|
||||
pilotComponent.Position = null;
|
||||
|
||||
if (TryComp<SharedEyeComponent>(pilotComponent.Owner, out var eye))
|
||||
{
|
||||
eye.Zoom = new(1.0f, 1.0f);
|
||||
}
|
||||
|
||||
if (!helmsman.SubscribedPilots.Remove(pilotComponent)) return;
|
||||
|
||||
_alertsSystem.ClearAlert(pilotComponent.Owner, AlertType.PilotingShuttle);
|
||||
|
||||
pilotComponent.Owner.PopupMessage(Loc.GetString("shuttle-pilot-end"));
|
||||
|
||||
if (pilotComponent.LifeStage < ComponentLifeStage.Stopping)
|
||||
EntityManager.RemoveComponent<PilotComponent>(pilotComponent.Owner);
|
||||
}
|
||||
|
||||
public void RemovePilot(EntityUid entity)
|
||||
{
|
||||
if (!EntityManager.TryGetComponent(entity, out PilotComponent? pilotComponent)) return;
|
||||
|
||||
RemovePilot(pilotComponent);
|
||||
}
|
||||
|
||||
public void ClearPilots(ShuttleConsoleComponent component)
|
||||
{
|
||||
while (component.SubscribedPilots.TryGetValue(0, out var pilot))
|
||||
{
|
||||
RemovePilot(pilot);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
15
Content.Server/Shuttles/Events/DockEvent.cs
Normal file
15
Content.Server/Shuttles/Events/DockEvent.cs
Normal file
@@ -0,0 +1,15 @@
|
||||
using Content.Server.Shuttles.Components;
|
||||
|
||||
namespace Content.Server.Shuttles.Events;
|
||||
|
||||
/// <summary>
|
||||
/// Raised whenever 2 airlocks dock.
|
||||
/// </summary>
|
||||
public sealed class DockEvent : EntityEventArgs
|
||||
{
|
||||
public DockingComponent DockA = default!;
|
||||
public DockingComponent DockB = default!;
|
||||
|
||||
public EntityUid GridAUid = default!;
|
||||
public EntityUid GridBUid = default!;
|
||||
}
|
||||
15
Content.Server/Shuttles/Events/UndockEvent.cs
Normal file
15
Content.Server/Shuttles/Events/UndockEvent.cs
Normal file
@@ -0,0 +1,15 @@
|
||||
using Content.Server.Shuttles.Components;
|
||||
|
||||
namespace Content.Server.Shuttles.Events;
|
||||
|
||||
/// <summary>
|
||||
/// Raised whenever 2 grids undock.
|
||||
/// </summary>
|
||||
public sealed class UndockEvent : EntityEventArgs
|
||||
{
|
||||
public DockingComponent DockA = default!;
|
||||
public DockingComponent DockB = default!;
|
||||
|
||||
public EntityUid GridAUid = default!;
|
||||
public EntityUid GridBUid = default!;
|
||||
}
|
||||
104
Content.Server/Shuttles/Systems/DockingSystem.AutoDock.cs
Normal file
104
Content.Server/Shuttles/Systems/DockingSystem.AutoDock.cs
Normal file
@@ -0,0 +1,104 @@
|
||||
using Content.Server.Shuttles.Components;
|
||||
using Content.Shared.Shuttles.Components;
|
||||
using Content.Shared.Shuttles.Events;
|
||||
using Robust.Shared.Players;
|
||||
using Robust.Shared.Utility;
|
||||
|
||||
namespace Content.Server.Shuttles.Systems;
|
||||
|
||||
public sealed partial class DockingSystem
|
||||
{
|
||||
private void UpdateAutodock()
|
||||
{
|
||||
// Work out what we can autodock with, what we shouldn't, and when we should stop tracking.
|
||||
// Autodocking only stops when the client closes that dock viewport OR they lose pilotcomponent.
|
||||
var dockingQuery = GetEntityQuery<DockingComponent>();
|
||||
var xformQuery = GetEntityQuery<TransformComponent>();
|
||||
var recentQuery = GetEntityQuery<RecentlyDockedComponent>();
|
||||
|
||||
foreach (var (comp, body) in EntityQuery<AutoDockComponent, PhysicsComponent>())
|
||||
{
|
||||
if (comp.Requesters.Count == 0 || !dockingQuery.TryGetComponent(comp.Owner, out var dock))
|
||||
{
|
||||
RemComp<AutoDockComponent>(comp.Owner);
|
||||
continue;
|
||||
}
|
||||
|
||||
// Don't re-dock if we're already docked or recently were.
|
||||
if (dock.Docked || recentQuery.HasComponent(comp.Owner)) continue;
|
||||
|
||||
var dockable = GetDockable(body, xformQuery.GetComponent(comp.Owner));
|
||||
|
||||
if (dockable == null) continue;
|
||||
|
||||
TryDock(dock, dockable);
|
||||
}
|
||||
|
||||
// Work out recent docks that have gone past their designated threshold.
|
||||
var checkedRecent = new HashSet<EntityUid>();
|
||||
|
||||
foreach (var (comp, xform) in EntityQuery<RecentlyDockedComponent, TransformComponent>())
|
||||
{
|
||||
if (!checkedRecent.Add(comp.Owner)) continue;
|
||||
|
||||
if (!dockingQuery.TryGetComponent(comp.Owner, out var dock))
|
||||
{
|
||||
RemComp<RecentlyDockedComponent>(comp.Owner);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!xformQuery.TryGetComponent(comp.LastDocked, out var otherXform))
|
||||
{
|
||||
RemComp<RecentlyDockedComponent>(comp.Owner);
|
||||
continue;
|
||||
}
|
||||
|
||||
var worldPos = _transformSystem.GetWorldPosition(xform, xformQuery);
|
||||
var otherWorldPos = _transformSystem.GetWorldPosition(otherXform, xformQuery);
|
||||
|
||||
if ((worldPos - otherWorldPos).Length < comp.Radius) continue;
|
||||
|
||||
_sawmill.Debug($"Removed RecentlyDocked from {ToPrettyString(comp.Owner)} and {ToPrettyString(comp.LastDocked)}");
|
||||
RemComp<RecentlyDockedComponent>(comp.Owner);
|
||||
RemComp<RecentlyDockedComponent>(comp.LastDocked);
|
||||
}
|
||||
}
|
||||
|
||||
private void OnRequestUndock(EntityUid uid, ShuttleConsoleComponent component, UndockRequestMessage args)
|
||||
{
|
||||
_sawmill.Debug($"Received undock request for {ToPrettyString(args.Entity)}");
|
||||
|
||||
// TODO: Validation
|
||||
if (!TryComp<DockingComponent>(args.Entity, out var dock) ||
|
||||
!dock.Docked) return;
|
||||
|
||||
Undock(dock);
|
||||
}
|
||||
|
||||
private void OnRequestAutodock(EntityUid uid, ShuttleConsoleComponent component, AutodockRequestMessage args)
|
||||
{
|
||||
_sawmill.Debug($"Received autodock request for {ToPrettyString(args.Entity)}");
|
||||
var player = args.Session.AttachedEntity;
|
||||
|
||||
if (player == null || !HasComp<DockingComponent>(args.Entity)) return;
|
||||
|
||||
// TODO: Validation
|
||||
var comp = EnsureComp<AutoDockComponent>(args.Entity);
|
||||
comp.Requesters.Add(player.Value);
|
||||
}
|
||||
|
||||
private void OnRequestStopAutodock(EntityUid uid, ShuttleConsoleComponent component, StopAutodockRequestMessage args)
|
||||
{
|
||||
_sawmill.Debug($"Received stop autodock request for {ToPrettyString(args.Entity)}");
|
||||
|
||||
var player = args.Session.AttachedEntity;
|
||||
|
||||
// TODO: Validation
|
||||
if (player == null || !TryComp<AutoDockComponent>(args.Entity, out var comp)) return;
|
||||
|
||||
comp.Requesters.Remove(player.Value);
|
||||
|
||||
if (comp.Requesters.Count == 0)
|
||||
RemComp<AutoDockComponent>(args.Entity);
|
||||
}
|
||||
}
|
||||
@@ -1,24 +1,30 @@
|
||||
using Content.Server.Doors.Systems;
|
||||
using Content.Server.Power.Components;
|
||||
using Content.Server.Shuttles.Components;
|
||||
using Content.Server.Shuttles.Events;
|
||||
using Content.Shared.Doors;
|
||||
using Content.Shared.Doors.Components;
|
||||
using Content.Shared.Shuttles.Events;
|
||||
using Content.Shared.Verbs;
|
||||
using Robust.Server.Player;
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Shared.Physics;
|
||||
using Robust.Shared.Physics.Collision.Shapes;
|
||||
using Robust.Shared.Physics.Dynamics;
|
||||
using Robust.Shared.Utility;
|
||||
|
||||
namespace Content.Server.Shuttles.EntitySystems
|
||||
namespace Content.Server.Shuttles.Systems
|
||||
{
|
||||
public sealed class DockingSystem : EntitySystem
|
||||
public sealed partial class DockingSystem : EntitySystem
|
||||
{
|
||||
[Dependency] private readonly IMapManager _mapManager = default!;
|
||||
[Dependency] private readonly FixtureSystem _fixtureSystem = default!;
|
||||
[Dependency] private readonly SharedJointSystem _jointSystem = default!;
|
||||
[Dependency] private readonly SharedTransformSystem _transformSystem = default!;
|
||||
[Dependency] private readonly ShuttleConsoleSystem _console = default!;
|
||||
[Dependency] private readonly DoorSystem _doorSystem = default!;
|
||||
|
||||
private ISawmill _sawmill = default!;
|
||||
private const string DockingFixture = "docking";
|
||||
private const string DockingJoint = "docking";
|
||||
private const float DockingRadius = 0.20f;
|
||||
@@ -26,14 +32,26 @@ namespace Content.Server.Shuttles.EntitySystems
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
_sawmill = Logger.GetSawmill("docking");
|
||||
SubscribeLocalEvent<DockingComponent, ComponentStartup>(OnStartup);
|
||||
SubscribeLocalEvent<DockingComponent, ComponentShutdown>(OnShutdown);
|
||||
SubscribeLocalEvent<DockingComponent, PowerChangedEvent>(OnPowerChange);
|
||||
SubscribeLocalEvent<DockingComponent, AnchorStateChangedEvent>(OnAnchorChange);
|
||||
SubscribeLocalEvent<DockingComponent, ReAnchorEvent>(OnDockingReAnchor);
|
||||
|
||||
SubscribeLocalEvent<DockingComponent, GetVerbsEvent<InteractionVerb>>(OnVerb);
|
||||
SubscribeLocalEvent<DockingComponent, BeforeDoorAutoCloseEvent>(OnAutoClose);
|
||||
|
||||
// Yes this isn't in shuttle console; it may be used by other systems technically.
|
||||
// in which case I would also add their subs here.
|
||||
SubscribeLocalEvent<ShuttleConsoleComponent, AutodockRequestMessage>(OnRequestAutodock);
|
||||
SubscribeLocalEvent<ShuttleConsoleComponent, StopAutodockRequestMessage>(OnRequestStopAutodock);
|
||||
SubscribeLocalEvent<ShuttleConsoleComponent, UndockRequestMessage>(OnRequestUndock);
|
||||
}
|
||||
|
||||
public override void Update(float frameTime)
|
||||
{
|
||||
base.Update(frameTime);
|
||||
UpdateAutodock();
|
||||
}
|
||||
|
||||
private void OnAutoClose(EntityUid uid, DockingComponent component, BeforeDoorAutoCloseEvent args)
|
||||
@@ -43,56 +61,6 @@ namespace Content.Server.Shuttles.EntitySystems
|
||||
args.Cancel();
|
||||
}
|
||||
|
||||
private void OnVerb(EntityUid uid, DockingComponent component, GetVerbsEvent<InteractionVerb> args)
|
||||
{
|
||||
if (!args.CanInteract ||
|
||||
!args.CanAccess) return;
|
||||
|
||||
InteractionVerb? verb;
|
||||
|
||||
// TODO: Have it open the UI and have the UI do this.
|
||||
if (!component.Docked &&
|
||||
TryComp(uid, out PhysicsComponent? body) &&
|
||||
TryComp(uid, out TransformComponent? xform))
|
||||
{
|
||||
DockingComponent? otherDock = null;
|
||||
|
||||
if (component.Enabled)
|
||||
otherDock = GetDockable(body, xform);
|
||||
|
||||
verb = new InteractionVerb
|
||||
{
|
||||
Disabled = otherDock == null,
|
||||
Text = Loc.GetString("docking-component-dock"),
|
||||
Act = () =>
|
||||
{
|
||||
if (otherDock == null) return;
|
||||
TryDock(component, otherDock);
|
||||
}
|
||||
};
|
||||
}
|
||||
else if (component.Docked)
|
||||
{
|
||||
verb = new InteractionVerb
|
||||
{
|
||||
Disabled = !component.Docked,
|
||||
Text = Loc.GetString("docking-component-undock"),
|
||||
Act = () =>
|
||||
{
|
||||
if (component.DockedWith == null || !component.Enabled) return;
|
||||
|
||||
Undock(component);
|
||||
}
|
||||
};
|
||||
}
|
||||
else
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
args.Verbs.Add(verb);
|
||||
}
|
||||
|
||||
private DockingComponent? GetDockable(PhysicsComponent body, TransformComponent dockingXform)
|
||||
{
|
||||
// Did you know Saltern is the most dockable station?
|
||||
@@ -105,12 +73,9 @@ namespace Content.Server.Shuttles.EntitySystems
|
||||
var transform = body.GetTransform();
|
||||
var dockingFixture = _fixtureSystem.GetFixtureOrNull(body, DockingFixture);
|
||||
|
||||
// Happens if no power or whatever
|
||||
if (dockingFixture == null)
|
||||
{
|
||||
DebugTools.Assert(false);
|
||||
Logger.ErrorS("docking", $"Found null fixture on {(body).Owner}");
|
||||
return null;
|
||||
}
|
||||
|
||||
Box2? aabb = null;
|
||||
|
||||
@@ -142,7 +107,7 @@ namespace Content.Server.Shuttles.EntitySystems
|
||||
if (otherDockingFixture == null)
|
||||
{
|
||||
DebugTools.Assert(false);
|
||||
Logger.ErrorS("docking", $"Found null docking fixture on {ent}");
|
||||
_sawmill.Error($"Found null docking fixture on {ent}");
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -181,7 +146,7 @@ namespace Content.Server.Shuttles.EntitySystems
|
||||
!TryComp(dockBUid, out DockingComponent? dockB))
|
||||
{
|
||||
DebugTools.Assert(false);
|
||||
Logger.Error("docking", $"Tried to cleanup {dockA.Owner} but not docked?");
|
||||
_sawmill.Error($"Tried to cleanup {dockA.Owner} but not docked?");
|
||||
|
||||
dockA.DockedWith = null;
|
||||
if (dockA.DockJoint != null)
|
||||
@@ -247,6 +212,8 @@ namespace Content.Server.Shuttles.EntitySystems
|
||||
{
|
||||
DisableDocking(uid, component);
|
||||
}
|
||||
|
||||
_console.RefreshShuttleConsoles();
|
||||
}
|
||||
|
||||
private void OnDockingReAnchor(EntityUid uid, DockingComponent component, ref ReAnchorEvent args)
|
||||
@@ -257,6 +224,7 @@ namespace Content.Server.Shuttles.EntitySystems
|
||||
|
||||
Undock(component);
|
||||
Dock(component, other);
|
||||
_console.RefreshShuttleConsoles();
|
||||
}
|
||||
|
||||
private void OnPowerChange(EntityUid uid, DockingComponent component, PowerChangedEvent args)
|
||||
@@ -329,12 +297,11 @@ namespace Content.Server.Shuttles.EntitySystems
|
||||
/// </summary>
|
||||
public void Dock(DockingComponent dockA, DockingComponent dockB)
|
||||
{
|
||||
Logger.DebugS("docking", $"Docking between {dockA.Owner} and {dockB.Owner}");
|
||||
_sawmill.Debug($"Docking between {dockA.Owner} and {dockB.Owner}");
|
||||
|
||||
// https://gamedev.stackexchange.com/questions/98772/b2distancejoint-with-frequency-equal-to-0-vs-b2weldjoint
|
||||
|
||||
// We could also potentially use a prismatic joint? Depending if we want clamps that can extend or whatever
|
||||
|
||||
var dockAXform = EntityManager.GetComponent<TransformComponent>(dockA.Owner);
|
||||
var dockBXform = EntityManager.GetComponent<TransformComponent>(dockB.Owner);
|
||||
|
||||
@@ -397,10 +364,7 @@ namespace Content.Server.Shuttles.EntitySystems
|
||||
EntityManager.EventBus.RaiseEvent(EventSource.Local, msg);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Attempts to dock 2 ports together and will return early if it's not possible.
|
||||
/// </summary>
|
||||
private void TryDock(DockingComponent dockA, DockingComponent dockB)
|
||||
private bool CanDock(DockingComponent dockA, DockingComponent dockB)
|
||||
{
|
||||
if (!TryComp(dockA.Owner, out PhysicsComponent? bodyA) ||
|
||||
!TryComp(dockB.Owner, out PhysicsComponent? bodyB) ||
|
||||
@@ -409,7 +373,7 @@ namespace Content.Server.Shuttles.EntitySystems
|
||||
dockA.DockedWith != null ||
|
||||
dockB.DockedWith != null)
|
||||
{
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
var fixtureA = _fixtureSystem.GetFixtureOrNull(bodyA, DockingFixture);
|
||||
@@ -417,7 +381,7 @@ namespace Content.Server.Shuttles.EntitySystems
|
||||
|
||||
if (fixtureA == null || fixtureB == null)
|
||||
{
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
var transformA = bodyA.GetTransform();
|
||||
@@ -441,7 +405,15 @@ namespace Content.Server.Shuttles.EntitySystems
|
||||
if (intersect) break;
|
||||
}
|
||||
|
||||
if (!intersect) return;
|
||||
return intersect;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Attempts to dock 2 ports together and will return early if it's not possible.
|
||||
/// </summary>
|
||||
private void TryDock(DockingComponent dockA, DockingComponent dockB)
|
||||
{
|
||||
if (!CanDock(dockA, dockB)) return;
|
||||
|
||||
Dock(dockA, dockB);
|
||||
}
|
||||
@@ -451,7 +423,7 @@ namespace Content.Server.Shuttles.EntitySystems
|
||||
if (dock.DockedWith == null)
|
||||
{
|
||||
DebugTools.Assert(false);
|
||||
Logger.ErrorS("docking", $"Tried to undock {(dock).Owner} but not docked with anything?");
|
||||
_sawmill.Error($"Tried to undock {(dock).Owner} but not docked with anything?");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -467,33 +439,12 @@ namespace Content.Server.Shuttles.EntitySystems
|
||||
_doorSystem.TryClose(doorB.Owner, doorB);
|
||||
}
|
||||
|
||||
// Could maybe give the shuttle a light push away, or at least if there's no other docks left?
|
||||
var recentlyDocked = EnsureComp<RecentlyDockedComponent>(dock.Owner);
|
||||
recentlyDocked.LastDocked = dock.DockedWith.Value;
|
||||
recentlyDocked = EnsureComp<RecentlyDockedComponent>(dock.DockedWith.Value);
|
||||
recentlyDocked.LastDocked = dock.DockedWith.Value;
|
||||
|
||||
Cleanup(dock);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Raised whenever 2 airlocks dock.
|
||||
/// </summary>
|
||||
public sealed class DockEvent : EntityEventArgs
|
||||
{
|
||||
public DockingComponent DockA = default!;
|
||||
public DockingComponent DockB = default!;
|
||||
|
||||
public EntityUid GridAUid = default!;
|
||||
public EntityUid GridBUid = default!;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Raised whenever 2 grids undock.
|
||||
/// </summary>
|
||||
public sealed class UndockEvent : EntityEventArgs
|
||||
{
|
||||
public DockingComponent DockA = default!;
|
||||
public DockingComponent DockB = default!;
|
||||
|
||||
public EntityUid GridAUid = default!;
|
||||
public EntityUid GridBUid = default!;
|
||||
}
|
||||
}
|
||||
}
|
||||
29
Content.Server/Shuttles/Systems/RadarConsoleSystem.cs
Normal file
29
Content.Server/Shuttles/Systems/RadarConsoleSystem.cs
Normal file
@@ -0,0 +1,29 @@
|
||||
using Content.Shared.Shuttles.BUIStates;
|
||||
using Content.Shared.Shuttles.Components;
|
||||
using Content.Shared.Shuttles.Systems;
|
||||
using Robust.Server.GameObjects;
|
||||
using Robust.Shared.Map;
|
||||
|
||||
namespace Content.Server.Shuttles.Systems;
|
||||
|
||||
public sealed class RadarConsoleSystem : SharedRadarConsoleSystem
|
||||
{
|
||||
[Dependency] private readonly UserInterfaceSystem _uiSystem = default!;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
SubscribeLocalEvent<RadarConsoleComponent, ComponentStartup>(OnRadarStartup);
|
||||
}
|
||||
|
||||
private void OnRadarStartup(EntityUid uid, RadarConsoleComponent component, ComponentStartup args)
|
||||
{
|
||||
UpdateState(component);
|
||||
}
|
||||
|
||||
protected override void UpdateState(RadarConsoleComponent component)
|
||||
{
|
||||
var radarState = new RadarConsoleBoundInterfaceState(component.MaxRange, component.Owner, new List<DockingInterfaceState>());
|
||||
_uiSystem.GetUiOrNull(component.Owner, RadarConsoleUiKey.Key)?.SetState(radarState);
|
||||
}
|
||||
}
|
||||
337
Content.Server/Shuttles/Systems/ShuttleConsoleSystem.cs
Normal file
337
Content.Server/Shuttles/Systems/ShuttleConsoleSystem.cs
Normal file
@@ -0,0 +1,337 @@
|
||||
using Content.Server.Power.Components;
|
||||
using Content.Server.Power.EntitySystems;
|
||||
using Content.Server.Shuttles.Components;
|
||||
using Content.Server.Shuttles.Events;
|
||||
using Content.Server.UserInterface;
|
||||
using Content.Shared.ActionBlocker;
|
||||
using Content.Shared.Alert;
|
||||
using Content.Shared.Popups;
|
||||
using Content.Shared.Shuttles.BUIStates;
|
||||
using Content.Shared.Shuttles.Components;
|
||||
using Content.Shared.Shuttles.Events;
|
||||
using Content.Shared.Shuttles.Systems;
|
||||
using Content.Shared.Tag;
|
||||
using Robust.Server.GameObjects;
|
||||
using Robust.Shared.GameStates;
|
||||
using Robust.Shared.Utility;
|
||||
|
||||
namespace Content.Server.Shuttles.Systems
|
||||
{
|
||||
public sealed class ShuttleConsoleSystem : SharedShuttleConsoleSystem
|
||||
{
|
||||
[Dependency] private readonly ActionBlockerSystem _blocker = default!;
|
||||
[Dependency] private readonly AlertsSystem _alertsSystem = default!;
|
||||
[Dependency] private readonly TagSystem _tags = default!;
|
||||
[Dependency] private readonly UserInterfaceSystem _ui = default!;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
|
||||
SubscribeLocalEvent<ShuttleConsoleComponent, ComponentShutdown>(OnConsoleShutdown);
|
||||
SubscribeLocalEvent<ShuttleConsoleComponent, PowerChangedEvent>(OnConsolePowerChange);
|
||||
SubscribeLocalEvent<ShuttleConsoleComponent, AnchorStateChangedEvent>(OnConsoleAnchorChange);
|
||||
SubscribeLocalEvent<ShuttleConsoleComponent, ActivatableUIOpenAttemptEvent>(OnConsoleUIOpenAttempt);
|
||||
SubscribeLocalEvent<ShuttleConsoleComponent, ShuttleModeRequestMessage>(OnModeRequest);
|
||||
SubscribeLocalEvent<ShuttleConsoleComponent, BoundUIClosedEvent>(OnConsoleUIClose);
|
||||
SubscribeLocalEvent<DockEvent>(OnDock);
|
||||
SubscribeLocalEvent<UndockEvent>(OnUndock);
|
||||
|
||||
SubscribeLocalEvent<PilotComponent, MoveEvent>(HandlePilotMove);
|
||||
SubscribeLocalEvent<PilotComponent, ComponentGetState>(OnGetState);
|
||||
}
|
||||
|
||||
private void OnDock(DockEvent ev)
|
||||
{
|
||||
RefreshShuttleConsoles();
|
||||
}
|
||||
|
||||
private void OnUndock(UndockEvent ev)
|
||||
{
|
||||
RefreshShuttleConsoles();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Refreshes all of the data for shuttle consoles.
|
||||
/// </summary>
|
||||
public void RefreshShuttleConsoles()
|
||||
{
|
||||
// TODO: Should really call this per shuttle in some instances.
|
||||
var docks = GetAllDocks();
|
||||
|
||||
foreach (var comp in EntityQuery<ShuttleConsoleComponent>(true))
|
||||
{
|
||||
UpdateState(comp, docks);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Stop piloting if the window is closed.
|
||||
/// </summary>
|
||||
private void OnConsoleUIClose(EntityUid uid, ShuttleConsoleComponent component, BoundUIClosedEvent args)
|
||||
{
|
||||
if ((ShuttleConsoleUiKey) args.UiKey != ShuttleConsoleUiKey.Key ||
|
||||
args.Session.AttachedEntity is not {} user) return;
|
||||
|
||||
// In case they D/C should still clean them up.
|
||||
foreach (var comp in EntityQuery<AutoDockComponent>(true))
|
||||
{
|
||||
comp.Requesters.Remove(user);
|
||||
}
|
||||
|
||||
RemovePilot(user);
|
||||
}
|
||||
|
||||
private void OnConsoleUIOpenAttempt(EntityUid uid, ShuttleConsoleComponent component, ActivatableUIOpenAttemptEvent args)
|
||||
{
|
||||
if (!TryPilot(args.User, uid))
|
||||
args.Cancel();
|
||||
}
|
||||
|
||||
private void OnConsoleAnchorChange(EntityUid uid, ShuttleConsoleComponent component, ref AnchorStateChangedEvent args)
|
||||
{
|
||||
UpdateState(component);
|
||||
}
|
||||
|
||||
private void OnConsolePowerChange(EntityUid uid, ShuttleConsoleComponent component, PowerChangedEvent args)
|
||||
{
|
||||
UpdateState(component);
|
||||
}
|
||||
|
||||
private bool TryPilot(EntityUid user, EntityUid uid)
|
||||
{
|
||||
if (!_tags.HasTag(user, "CanPilot") ||
|
||||
!TryComp<ShuttleConsoleComponent>(uid, out var component) ||
|
||||
!this.IsPowered(uid, EntityManager) ||
|
||||
!Transform(uid).Anchored ||
|
||||
!_blocker.CanInteract(user, uid))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
var pilotComponent = EntityManager.EnsureComponent<PilotComponent>(user);
|
||||
var console = pilotComponent.Console;
|
||||
|
||||
if (console != null)
|
||||
{
|
||||
RemovePilot(pilotComponent);
|
||||
|
||||
if (console == component)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
AddPilot(user, component);
|
||||
return true;
|
||||
}
|
||||
|
||||
private void OnGetState(EntityUid uid, PilotComponent component, ref ComponentGetState args)
|
||||
{
|
||||
args.State = new PilotComponentState(component.Console?.Owner);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Client is requesting a change in the shuttle's driving mode.
|
||||
/// </summary>
|
||||
private void OnModeRequest(EntityUid uid, ShuttleConsoleComponent component, ShuttleModeRequestMessage args)
|
||||
{
|
||||
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;
|
||||
|
||||
if (!console.SubscribedPilots.Contains(pilot) ||
|
||||
!TryComp<ShuttleComponent>(xform.GridEntityId, out var shuttle)) return;
|
||||
|
||||
SetShuttleMode(args.Mode, console, shuttle);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the shuttle's movement mode. Does minimal revalidation.
|
||||
/// </summary>
|
||||
private void SetShuttleMode(ShuttleMode mode, ShuttleConsoleComponent consoleComponent,
|
||||
ShuttleComponent shuttleComponent, TransformComponent? consoleXform = null)
|
||||
{
|
||||
// Re-validate
|
||||
if (!this.IsPowered(consoleComponent.Owner, EntityManager) ||
|
||||
!Resolve(consoleComponent.Owner, ref consoleXform) ||
|
||||
!consoleXform.Anchored ||
|
||||
consoleXform.GridID != Transform(shuttleComponent.Owner).GridID)
|
||||
{
|
||||
UpdateState(consoleComponent);
|
||||
return;
|
||||
}
|
||||
|
||||
shuttleComponent.Mode = mode;
|
||||
|
||||
switch (mode)
|
||||
{
|
||||
case ShuttleMode.Strafing:
|
||||
break;
|
||||
case ShuttleMode.Cruise:
|
||||
break;
|
||||
default:
|
||||
throw new ArgumentOutOfRangeException();
|
||||
}
|
||||
|
||||
UpdateState(consoleComponent);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the position and angle of all dockingcomponents.
|
||||
/// </summary>
|
||||
private List<DockingInterfaceState> GetAllDocks()
|
||||
{
|
||||
// TODO: NEED TO MAKE SURE THIS UPDATES ON ANCHORING CHANGES!
|
||||
var result = new List<DockingInterfaceState>();
|
||||
|
||||
foreach (var (comp, xform) in EntityQuery<DockingComponent, TransformComponent>(true))
|
||||
{
|
||||
if (xform.ParentUid != xform.GridUid) continue;
|
||||
|
||||
var state = new DockingInterfaceState()
|
||||
{
|
||||
Coordinates = xform.Coordinates,
|
||||
Angle = xform.LocalRotation,
|
||||
Entity = comp.Owner,
|
||||
Connected = comp.Docked,
|
||||
};
|
||||
result.Add(state);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private void UpdateState(ShuttleConsoleComponent component, List<DockingInterfaceState>? docks = null)
|
||||
{
|
||||
TryComp<RadarConsoleComponent>(component.Owner, out var radar);
|
||||
var range = radar?.MaxRange ?? 0f;
|
||||
|
||||
TryComp<ShuttleComponent>(Transform(component.Owner).GridUid, out var shuttle);
|
||||
var mode = shuttle?.Mode ?? ShuttleMode.Cruise;
|
||||
|
||||
docks ??= GetAllDocks();
|
||||
|
||||
_ui.GetUiOrNull(component.Owner, ShuttleConsoleUiKey.Key)
|
||||
?.SetState(new ShuttleConsoleBoundInterfaceState(
|
||||
mode,
|
||||
range,
|
||||
component.Owner,
|
||||
docks));
|
||||
}
|
||||
|
||||
public override void Update(float frameTime)
|
||||
{
|
||||
base.Update(frameTime);
|
||||
|
||||
var toRemove = new RemQueue<PilotComponent>();
|
||||
|
||||
foreach (var comp in EntityManager.EntityQuery<PilotComponent>())
|
||||
{
|
||||
if (comp.Console == null) continue;
|
||||
|
||||
if (!_blocker.CanInteract(comp.Owner, comp.Console.Owner))
|
||||
{
|
||||
toRemove.Add(comp);
|
||||
}
|
||||
}
|
||||
|
||||
foreach (var comp in toRemove)
|
||||
{
|
||||
RemovePilot(comp);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// If pilot is moved then we'll stop them from piloting.
|
||||
/// </summary>
|
||||
private void HandlePilotMove(EntityUid uid, PilotComponent component, ref MoveEvent args)
|
||||
{
|
||||
if (component.Console == null || component.Position == null)
|
||||
{
|
||||
DebugTools.Assert(component.Position == null && component.Console == null);
|
||||
EntityManager.RemoveComponent<PilotComponent>(uid);
|
||||
return;
|
||||
}
|
||||
|
||||
if (args.NewPosition.TryDistance(EntityManager, component.Position.Value, out var distance) &&
|
||||
distance < PilotComponent.BreakDistance) return;
|
||||
|
||||
RemovePilot(component);
|
||||
}
|
||||
|
||||
protected override void HandlePilotShutdown(EntityUid uid, PilotComponent component, ComponentShutdown args)
|
||||
{
|
||||
base.HandlePilotShutdown(uid, component, args);
|
||||
RemovePilot(component);
|
||||
}
|
||||
|
||||
private void OnConsoleShutdown(EntityUid uid, ShuttleConsoleComponent component, ComponentShutdown args)
|
||||
{
|
||||
ClearPilots(component);
|
||||
}
|
||||
|
||||
public void AddPilot(EntityUid entity, ShuttleConsoleComponent component)
|
||||
{
|
||||
if (!EntityManager.TryGetComponent(entity, out PilotComponent? pilotComponent) ||
|
||||
component.SubscribedPilots.Contains(pilotComponent))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (TryComp<SharedEyeComponent>(entity, out var eye))
|
||||
{
|
||||
eye.Zoom = component.Zoom;
|
||||
}
|
||||
|
||||
component.SubscribedPilots.Add(pilotComponent);
|
||||
|
||||
_alertsSystem.ShowAlert(entity, AlertType.PilotingShuttle);
|
||||
|
||||
pilotComponent.Console = component;
|
||||
ActionBlockerSystem.UpdateCanMove(entity);
|
||||
pilotComponent.Position = EntityManager.GetComponent<TransformComponent>(entity).Coordinates;
|
||||
Dirty(pilotComponent);
|
||||
}
|
||||
|
||||
public void RemovePilot(PilotComponent pilotComponent)
|
||||
{
|
||||
var console = pilotComponent.Console;
|
||||
|
||||
if (console is not ShuttleConsoleComponent helmsman) return;
|
||||
|
||||
pilotComponent.Console = null;
|
||||
pilotComponent.Position = null;
|
||||
|
||||
if (TryComp<SharedEyeComponent>(pilotComponent.Owner, out var eye))
|
||||
{
|
||||
eye.Zoom = new(1.0f, 1.0f);
|
||||
}
|
||||
|
||||
if (!helmsman.SubscribedPilots.Remove(pilotComponent)) return;
|
||||
|
||||
_alertsSystem.ClearAlert(pilotComponent.Owner, AlertType.PilotingShuttle);
|
||||
|
||||
pilotComponent.Owner.PopupMessage(Loc.GetString("shuttle-pilot-end"));
|
||||
|
||||
if (pilotComponent.LifeStage < ComponentLifeStage.Stopping)
|
||||
EntityManager.RemoveComponent<PilotComponent>(pilotComponent.Owner);
|
||||
}
|
||||
|
||||
public void RemovePilot(EntityUid entity)
|
||||
{
|
||||
if (!EntityManager.TryGetComponent(entity, out PilotComponent? pilotComponent)) return;
|
||||
|
||||
RemovePilot(pilotComponent);
|
||||
}
|
||||
|
||||
public void ClearPilots(ShuttleConsoleComponent component)
|
||||
{
|
||||
while (component.SubscribedPilots.TryGetValue(0, out var pilot))
|
||||
{
|
||||
RemovePilot(pilot);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4,7 +4,7 @@ using JetBrains.Annotations;
|
||||
using Robust.Shared.Configuration;
|
||||
using Robust.Shared.Physics;
|
||||
|
||||
namespace Content.Server.Shuttles.EntitySystems
|
||||
namespace Content.Server.Shuttles.Systems
|
||||
{
|
||||
[UsedImplicitly]
|
||||
public sealed class ShuttleSystem : EntitySystem
|
||||
@@ -2,7 +2,7 @@ using Content.Server.Shuttles.Components;
|
||||
using Robust.Shared.Physics;
|
||||
using Robust.Shared.Physics.Dynamics;
|
||||
|
||||
namespace Content.Server.Shuttles.EntitySystems;
|
||||
namespace Content.Server.Shuttles.Systems;
|
||||
|
||||
/// <summary>
|
||||
/// Deletes anything with <see cref="SpaceGarbageComponent"/> that has a cross-grid collision with a static body.
|
||||
@@ -9,8 +9,8 @@ using Content.Shared.Examine;
|
||||
using Content.Shared.Interaction;
|
||||
using Content.Shared.Maps;
|
||||
using Content.Shared.Physics;
|
||||
using Content.Shared.Temperature;
|
||||
using Content.Shared.Shuttles.Components;
|
||||
using Content.Shared.Temperature;
|
||||
using Robust.Server.GameObjects;
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Shared.Physics;
|
||||
@@ -18,7 +18,7 @@ using Robust.Shared.Physics.Collision.Shapes;
|
||||
using Robust.Shared.Physics.Dynamics;
|
||||
using Robust.Shared.Utility;
|
||||
|
||||
namespace Content.Server.Shuttles.EntitySystems
|
||||
namespace Content.Server.Shuttles.Systems
|
||||
{
|
||||
public sealed class ThrusterSystem : EntitySystem
|
||||
{
|
||||
Reference in New Issue
Block a user