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:
metalgearsloth
2024-03-03 21:14:16 +11:00
committed by GitHub
parent a72373e408
commit 92872e546a
4 changed files with 31 additions and 56 deletions

View File

@@ -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);