diff --git a/Content.Server/Shuttles/Systems/DockingSystem.Shuttle.cs b/Content.Server/Shuttles/Systems/DockingSystem.Shuttle.cs index 4ce5294736..7bc1be02e3 100644 --- a/Content.Server/Shuttles/Systems/DockingSystem.Shuttle.cs +++ b/Content.Server/Shuttles/Systems/DockingSystem.Shuttle.cs @@ -94,12 +94,12 @@ public sealed partial class DockingSystem EntityUid gridDockUid, DockingComponent gridDock) { - var shuttleDocks = new List<(EntityUid, DockingComponent)>(1) + var shuttleDocks = new List>(1) { (shuttleDockUid, shuttleDock) }; - var gridDocks = new List<(EntityUid, DockingComponent)>(1) + var gridDocks = new List>(1) { (gridDockUid, gridDock) }; @@ -149,8 +149,8 @@ public sealed partial class DockingSystem private List GetDockingConfigs( EntityUid shuttleUid, EntityUid targetGrid, - List<(EntityUid, DockingComponent)> shuttleDocks, - List<(EntityUid, DockingComponent)> gridDocks) + List> shuttleDocks, + List> gridDocks) { var validDockConfigs = new List(); @@ -274,8 +274,8 @@ public sealed partial class DockingSystem private DockingConfig? GetDockingConfigPrivate( EntityUid shuttleUid, EntityUid targetGrid, - List<(EntityUid, DockingComponent)> shuttleDocks, - List<(EntityUid, DockingComponent)> gridDocks, + List> shuttleDocks, + List> gridDocks, string? priorityTag = null) { var validDockConfigs = GetDockingConfigs(shuttleUid, targetGrid, shuttleDocks, gridDocks); @@ -345,19 +345,11 @@ public sealed partial class DockingSystem return true; } - public List<(EntityUid Uid, DockingComponent Component)> GetDocks(EntityUid uid) + public List> GetDocks(EntityUid uid) { - var result = new List<(EntityUid Uid, DockingComponent Component)>(); - var query = AllEntityQuery(); + _dockingSet.Clear(); + _lookup.GetChildEntities(uid, _dockingSet); - while (query.MoveNext(out var dockUid, out var dock, out var xform)) - { - if (xform.ParentUid != uid || !dock.Enabled) - continue; - - result.Add((dockUid, dock)); - } - - return result; + return _dockingSet.ToList(); } } diff --git a/Content.Server/Shuttles/Systems/DockingSystem.cs b/Content.Server/Shuttles/Systems/DockingSystem.cs index afe03af1bb..8220818b23 100644 --- a/Content.Server/Shuttles/Systems/DockingSystem.cs +++ b/Content.Server/Shuttles/Systems/DockingSystem.cs @@ -60,10 +60,7 @@ namespace Content.Server.Shuttles.Systems SubscribeLocalEvent(OnRequestUndock); } - /// - /// Sets the docks for the provided entity as enabled or disabled. - /// - public void SetDocks(EntityUid gridUid, bool enabled) + public void UndockDocks(EntityUid gridUid) { _dockingSet.Clear(); _lookup.GetChildEntities(gridUid, _dockingSet); @@ -71,7 +68,6 @@ namespace Content.Server.Shuttles.Systems foreach (var dock in _dockingSet) { Undock(dock); - dock.Comp.Enabled = enabled; } } @@ -165,8 +161,6 @@ namespace Content.Server.Shuttles.Systems if (!EntityManager.GetComponent(uid).Anchored) return; - SetDockingEnabled((uid, component), true); - // This little gem is for docking deserialization if (component.DockedWith != null) { @@ -184,16 +178,10 @@ namespace Content.Server.Shuttles.Systems private void OnAnchorChange(Entity entity, ref AnchorStateChangedEvent args) { - if (args.Anchored) + if (!args.Anchored) { - SetDockingEnabled(entity, true); + Undock(entity); } - else - { - SetDockingEnabled(entity, false); - } - - _console.RefreshShuttleConsoles(); } private void OnDockingReAnchor(Entity entity, ref ReAnchorEvent args) @@ -212,19 +200,6 @@ namespace Content.Server.Shuttles.Systems _console.RefreshShuttleConsoles(); } - public void SetDockingEnabled(Entity entity, bool value) - { - if (entity.Comp.Enabled == value) - return; - - entity.Comp.Enabled = value; - - if (!entity.Comp.Enabled && entity.Comp.DockedWith != null) - { - Undock(entity); - } - } - /// /// Docks 2 ports together and assumes it is valid. /// @@ -454,9 +429,7 @@ namespace Content.Server.Shuttles.Systems /// public bool CanDock(Entity dockA, Entity dockB) { - if (!dockA.Comp.Enabled || - !dockB.Comp.Enabled || - dockA.Comp.DockedWith != null || + if (dockA.Comp.DockedWith != null || dockB.Comp.DockedWith != null) { return false; @@ -464,6 +437,10 @@ namespace Content.Server.Shuttles.Systems var xformA = Transform(dockA); var xformB = Transform(dockB); + + if (!xformA.Anchored || !xformB.Anchored) + return false; + var (worldPosA, worldRotA) = XformSystem.GetWorldPositionRotation(xformA); var (worldPosB, worldRotB) = XformSystem.GetWorldPositionRotation(xformB); diff --git a/Content.Server/Shuttles/Systems/ShuttleSystem.FasterThanLight.cs b/Content.Server/Shuttles/Systems/ShuttleSystem.FasterThanLight.cs index 8a93563765..fc01a5d36f 100644 --- a/Content.Server/Shuttles/Systems/ShuttleSystem.FasterThanLight.cs +++ b/Content.Server/Shuttles/Systems/ShuttleSystem.FasterThanLight.cs @@ -316,7 +316,7 @@ public sealed partial class ShuttleSystem _thruster.DisableLinearThrusters(shuttle); _thruster.EnableLinearThrustDirection(shuttle, DirectionFlag.North); _thruster.SetAngularThrust(shuttle, false); - _dockSystem.SetDocks(uid, false); + _dockSystem.UndockDocks(uid); component = AddComp(uid); component.State = FTLState.Starting; @@ -420,7 +420,6 @@ public sealed partial class ShuttleSystem var comp = entity.Comp1; DoTheDinosaur(xform); _dockSystem.SetDockBolts(entity, false); - _dockSystem.SetDocks(entity, true); _physics.SetLinearVelocity(uid, Vector2.Zero, body: body); _physics.SetAngularVelocity(uid, 0f, body: body); @@ -446,14 +445,24 @@ public sealed partial class ShuttleSystem !HasComp(target.EntityId)) { var config = _dockSystem.GetDockingConfigAt(uid, target.EntityId, target, entity.Comp1.TargetAngle); + MapCoordinates mapCoordinates; + Angle targetAngle; // Couldn't dock somehow so just fallback to regular position FTL. if (config == null) { - _transform.SetCoordinates(uid, xform, target, rotation: entity.Comp1.TargetAngle); + mapCoordinates = _transform.ToMapCoordinates(target); + targetAngle = entity.Comp1.TargetAngle; + } + else + { + mapCoordinates = _transform.ToMapCoordinates(config.Coordinates); + targetAngle = config.Angle; } - mapId = target.GetMapId(EntityManager); + target = new EntityCoordinates(_mapManager.GetMapEntityId(mapCoordinates.MapId), mapCoordinates.Position); + _transform.SetCoordinates(uid, xform, target, rotation: targetAngle); + mapId = mapCoordinates.MapId; } // Position ftl else diff --git a/Content.Shared/Shuttles/Components/SharedDockingComponent.cs b/Content.Shared/Shuttles/Components/SharedDockingComponent.cs index 501132f804..15af045cc4 100644 --- a/Content.Shared/Shuttles/Components/SharedDockingComponent.cs +++ b/Content.Shared/Shuttles/Components/SharedDockingComponent.cs @@ -5,9 +5,6 @@ namespace Content.Shared.Shuttles.Components // Yes I left this in for now because there's no overhead and we'll need a client one later anyway // and I was too lazy to delete it. - [ViewVariables] - public bool Enabled = false; - public abstract bool Docked { get; } } }