Fix FTLToDock (#25803)
* Fix FTLToDock - Removed Enabled coz unneeded really. - Fixed SetCoordinates call that got dumped at some point oop. * Fix this docking check
This commit is contained in:
@@ -94,12 +94,12 @@ public sealed partial class DockingSystem
|
||||
EntityUid gridDockUid,
|
||||
DockingComponent gridDock)
|
||||
{
|
||||
var shuttleDocks = new List<(EntityUid, DockingComponent)>(1)
|
||||
var shuttleDocks = new List<Entity<DockingComponent>>(1)
|
||||
{
|
||||
(shuttleDockUid, shuttleDock)
|
||||
};
|
||||
|
||||
var gridDocks = new List<(EntityUid, DockingComponent)>(1)
|
||||
var gridDocks = new List<Entity<DockingComponent>>(1)
|
||||
{
|
||||
(gridDockUid, gridDock)
|
||||
};
|
||||
@@ -149,8 +149,8 @@ public sealed partial class DockingSystem
|
||||
private List<DockingConfig> GetDockingConfigs(
|
||||
EntityUid shuttleUid,
|
||||
EntityUid targetGrid,
|
||||
List<(EntityUid, DockingComponent)> shuttleDocks,
|
||||
List<(EntityUid, DockingComponent)> gridDocks)
|
||||
List<Entity<DockingComponent>> shuttleDocks,
|
||||
List<Entity<DockingComponent>> gridDocks)
|
||||
{
|
||||
var validDockConfigs = new List<DockingConfig>();
|
||||
|
||||
@@ -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<Entity<DockingComponent>> shuttleDocks,
|
||||
List<Entity<DockingComponent>> 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<Entity<DockingComponent>> GetDocks(EntityUid uid)
|
||||
{
|
||||
var result = new List<(EntityUid Uid, DockingComponent Component)>();
|
||||
var query = AllEntityQuery<DockingComponent, TransformComponent>();
|
||||
_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();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -60,10 +60,7 @@ namespace Content.Server.Shuttles.Systems
|
||||
SubscribeLocalEvent<ShuttleConsoleComponent, UndockRequestMessage>(OnRequestUndock);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the docks for the provided entity as enabled or disabled.
|
||||
/// </summary>
|
||||
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<TransformComponent>(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<DockingComponent> 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<DockingComponent> entity, ref ReAnchorEvent args)
|
||||
@@ -212,19 +200,6 @@ namespace Content.Server.Shuttles.Systems
|
||||
_console.RefreshShuttleConsoles();
|
||||
}
|
||||
|
||||
public void SetDockingEnabled(Entity<DockingComponent> entity, bool value)
|
||||
{
|
||||
if (entity.Comp.Enabled == value)
|
||||
return;
|
||||
|
||||
entity.Comp.Enabled = value;
|
||||
|
||||
if (!entity.Comp.Enabled && entity.Comp.DockedWith != null)
|
||||
{
|
||||
Undock(entity);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Docks 2 ports together and assumes it is valid.
|
||||
/// </summary>
|
||||
@@ -454,9 +429,7 @@ namespace Content.Server.Shuttles.Systems
|
||||
/// </summary>
|
||||
public bool CanDock(Entity<DockingComponent> dockA, Entity<DockingComponent> 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);
|
||||
|
||||
|
||||
@@ -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<FTLComponent>(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<MapComponent>(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
|
||||
|
||||
@@ -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; }
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user