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,
|
EntityUid gridDockUid,
|
||||||
DockingComponent gridDock)
|
DockingComponent gridDock)
|
||||||
{
|
{
|
||||||
var shuttleDocks = new List<(EntityUid, DockingComponent)>(1)
|
var shuttleDocks = new List<Entity<DockingComponent>>(1)
|
||||||
{
|
{
|
||||||
(shuttleDockUid, shuttleDock)
|
(shuttleDockUid, shuttleDock)
|
||||||
};
|
};
|
||||||
|
|
||||||
var gridDocks = new List<(EntityUid, DockingComponent)>(1)
|
var gridDocks = new List<Entity<DockingComponent>>(1)
|
||||||
{
|
{
|
||||||
(gridDockUid, gridDock)
|
(gridDockUid, gridDock)
|
||||||
};
|
};
|
||||||
@@ -149,8 +149,8 @@ public sealed partial class DockingSystem
|
|||||||
private List<DockingConfig> GetDockingConfigs(
|
private List<DockingConfig> GetDockingConfigs(
|
||||||
EntityUid shuttleUid,
|
EntityUid shuttleUid,
|
||||||
EntityUid targetGrid,
|
EntityUid targetGrid,
|
||||||
List<(EntityUid, DockingComponent)> shuttleDocks,
|
List<Entity<DockingComponent>> shuttleDocks,
|
||||||
List<(EntityUid, DockingComponent)> gridDocks)
|
List<Entity<DockingComponent>> gridDocks)
|
||||||
{
|
{
|
||||||
var validDockConfigs = new List<DockingConfig>();
|
var validDockConfigs = new List<DockingConfig>();
|
||||||
|
|
||||||
@@ -274,8 +274,8 @@ public sealed partial class DockingSystem
|
|||||||
private DockingConfig? GetDockingConfigPrivate(
|
private DockingConfig? GetDockingConfigPrivate(
|
||||||
EntityUid shuttleUid,
|
EntityUid shuttleUid,
|
||||||
EntityUid targetGrid,
|
EntityUid targetGrid,
|
||||||
List<(EntityUid, DockingComponent)> shuttleDocks,
|
List<Entity<DockingComponent>> shuttleDocks,
|
||||||
List<(EntityUid, DockingComponent)> gridDocks,
|
List<Entity<DockingComponent>> gridDocks,
|
||||||
string? priorityTag = null)
|
string? priorityTag = null)
|
||||||
{
|
{
|
||||||
var validDockConfigs = GetDockingConfigs(shuttleUid, targetGrid, shuttleDocks, gridDocks);
|
var validDockConfigs = GetDockingConfigs(shuttleUid, targetGrid, shuttleDocks, gridDocks);
|
||||||
@@ -345,19 +345,11 @@ public sealed partial class DockingSystem
|
|||||||
return true;
|
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)>();
|
_dockingSet.Clear();
|
||||||
var query = AllEntityQuery<DockingComponent, TransformComponent>();
|
_lookup.GetChildEntities(uid, _dockingSet);
|
||||||
|
|
||||||
while (query.MoveNext(out var dockUid, out var dock, out var xform))
|
return _dockingSet.ToList();
|
||||||
{
|
|
||||||
if (xform.ParentUid != uid || !dock.Enabled)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
result.Add((dockUid, dock));
|
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -60,10 +60,7 @@ namespace Content.Server.Shuttles.Systems
|
|||||||
SubscribeLocalEvent<ShuttleConsoleComponent, UndockRequestMessage>(OnRequestUndock);
|
SubscribeLocalEvent<ShuttleConsoleComponent, UndockRequestMessage>(OnRequestUndock);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
public void UndockDocks(EntityUid gridUid)
|
||||||
/// Sets the docks for the provided entity as enabled or disabled.
|
|
||||||
/// </summary>
|
|
||||||
public void SetDocks(EntityUid gridUid, bool enabled)
|
|
||||||
{
|
{
|
||||||
_dockingSet.Clear();
|
_dockingSet.Clear();
|
||||||
_lookup.GetChildEntities(gridUid, _dockingSet);
|
_lookup.GetChildEntities(gridUid, _dockingSet);
|
||||||
@@ -71,7 +68,6 @@ namespace Content.Server.Shuttles.Systems
|
|||||||
foreach (var dock in _dockingSet)
|
foreach (var dock in _dockingSet)
|
||||||
{
|
{
|
||||||
Undock(dock);
|
Undock(dock);
|
||||||
dock.Comp.Enabled = enabled;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -165,8 +161,6 @@ namespace Content.Server.Shuttles.Systems
|
|||||||
if (!EntityManager.GetComponent<TransformComponent>(uid).Anchored)
|
if (!EntityManager.GetComponent<TransformComponent>(uid).Anchored)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
SetDockingEnabled((uid, component), true);
|
|
||||||
|
|
||||||
// This little gem is for docking deserialization
|
// This little gem is for docking deserialization
|
||||||
if (component.DockedWith != null)
|
if (component.DockedWith != null)
|
||||||
{
|
{
|
||||||
@@ -184,16 +178,10 @@ namespace Content.Server.Shuttles.Systems
|
|||||||
|
|
||||||
private void OnAnchorChange(Entity<DockingComponent> entity, ref AnchorStateChangedEvent args)
|
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)
|
private void OnDockingReAnchor(Entity<DockingComponent> entity, ref ReAnchorEvent args)
|
||||||
@@ -212,19 +200,6 @@ namespace Content.Server.Shuttles.Systems
|
|||||||
_console.RefreshShuttleConsoles();
|
_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>
|
/// <summary>
|
||||||
/// Docks 2 ports together and assumes it is valid.
|
/// Docks 2 ports together and assumes it is valid.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -454,9 +429,7 @@ namespace Content.Server.Shuttles.Systems
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public bool CanDock(Entity<DockingComponent> dockA, Entity<DockingComponent> dockB)
|
public bool CanDock(Entity<DockingComponent> dockA, Entity<DockingComponent> dockB)
|
||||||
{
|
{
|
||||||
if (!dockA.Comp.Enabled ||
|
if (dockA.Comp.DockedWith != null ||
|
||||||
!dockB.Comp.Enabled ||
|
|
||||||
dockA.Comp.DockedWith != null ||
|
|
||||||
dockB.Comp.DockedWith != null)
|
dockB.Comp.DockedWith != null)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
@@ -464,6 +437,10 @@ namespace Content.Server.Shuttles.Systems
|
|||||||
|
|
||||||
var xformA = Transform(dockA);
|
var xformA = Transform(dockA);
|
||||||
var xformB = Transform(dockB);
|
var xformB = Transform(dockB);
|
||||||
|
|
||||||
|
if (!xformA.Anchored || !xformB.Anchored)
|
||||||
|
return false;
|
||||||
|
|
||||||
var (worldPosA, worldRotA) = XformSystem.GetWorldPositionRotation(xformA);
|
var (worldPosA, worldRotA) = XformSystem.GetWorldPositionRotation(xformA);
|
||||||
var (worldPosB, worldRotB) = XformSystem.GetWorldPositionRotation(xformB);
|
var (worldPosB, worldRotB) = XformSystem.GetWorldPositionRotation(xformB);
|
||||||
|
|
||||||
|
|||||||
@@ -316,7 +316,7 @@ public sealed partial class ShuttleSystem
|
|||||||
_thruster.DisableLinearThrusters(shuttle);
|
_thruster.DisableLinearThrusters(shuttle);
|
||||||
_thruster.EnableLinearThrustDirection(shuttle, DirectionFlag.North);
|
_thruster.EnableLinearThrustDirection(shuttle, DirectionFlag.North);
|
||||||
_thruster.SetAngularThrust(shuttle, false);
|
_thruster.SetAngularThrust(shuttle, false);
|
||||||
_dockSystem.SetDocks(uid, false);
|
_dockSystem.UndockDocks(uid);
|
||||||
|
|
||||||
component = AddComp<FTLComponent>(uid);
|
component = AddComp<FTLComponent>(uid);
|
||||||
component.State = FTLState.Starting;
|
component.State = FTLState.Starting;
|
||||||
@@ -420,7 +420,6 @@ public sealed partial class ShuttleSystem
|
|||||||
var comp = entity.Comp1;
|
var comp = entity.Comp1;
|
||||||
DoTheDinosaur(xform);
|
DoTheDinosaur(xform);
|
||||||
_dockSystem.SetDockBolts(entity, false);
|
_dockSystem.SetDockBolts(entity, false);
|
||||||
_dockSystem.SetDocks(entity, true);
|
|
||||||
|
|
||||||
_physics.SetLinearVelocity(uid, Vector2.Zero, body: body);
|
_physics.SetLinearVelocity(uid, Vector2.Zero, body: body);
|
||||||
_physics.SetAngularVelocity(uid, 0f, body: body);
|
_physics.SetAngularVelocity(uid, 0f, body: body);
|
||||||
@@ -446,14 +445,24 @@ public sealed partial class ShuttleSystem
|
|||||||
!HasComp<MapComponent>(target.EntityId))
|
!HasComp<MapComponent>(target.EntityId))
|
||||||
{
|
{
|
||||||
var config = _dockSystem.GetDockingConfigAt(uid, target.EntityId, target, entity.Comp1.TargetAngle);
|
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.
|
// Couldn't dock somehow so just fallback to regular position FTL.
|
||||||
if (config == null)
|
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
|
// Position ftl
|
||||||
else
|
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
|
// 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.
|
// and I was too lazy to delete it.
|
||||||
|
|
||||||
[ViewVariables]
|
|
||||||
public bool Enabled = false;
|
|
||||||
|
|
||||||
public abstract bool Docked { get; }
|
public abstract bool Docked { get; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user