Replace obsolete code in shuttle systems. (#31408)

* Format DockingSystem.Shuttle

* arrivals system

* docking system

* shuttle console system

* emergency shuttle system

* shuttle system

* thruster system

* Fix compile error

---------

Co-authored-by: Pieter-Jan Briers <pieterjan.briers+git@gmail.com>
This commit is contained in:
Mervill
2024-08-26 08:48:37 -07:00
committed by GitHub
parent 6c66e8fe1f
commit c6d291968f
12 changed files with 298 additions and 297 deletions

View File

@@ -45,10 +45,10 @@ public sealed class ArrivalsSystem : EntitySystem
[Dependency] private readonly IConfigurationManager _cfgManager = default!; [Dependency] private readonly IConfigurationManager _cfgManager = default!;
[Dependency] private readonly IConsoleHost _console = default!; [Dependency] private readonly IConsoleHost _console = default!;
[Dependency] private readonly IGameTiming _timing = default!; [Dependency] private readonly IGameTiming _timing = default!;
[Dependency] private readonly IMapManager _mapManager = default!;
[Dependency] private readonly IPrototypeManager _protoManager = default!; [Dependency] private readonly IPrototypeManager _protoManager = default!;
[Dependency] private readonly IRobustRandom _random = default!; [Dependency] private readonly IRobustRandom _random = default!;
[Dependency] private readonly IChatManager _chat = default!; [Dependency] private readonly IChatManager _chat = default!;
[Dependency] private readonly SharedMapSystem _mapSystem = default!;
[Dependency] private readonly BiomeSystem _biomes = default!; [Dependency] private readonly BiomeSystem _biomes = default!;
[Dependency] private readonly GameTicker _ticker = default!; [Dependency] private readonly GameTicker _ticker = default!;
[Dependency] private readonly MapLoaderSystem _loader = default!; [Dependency] private readonly MapLoaderSystem _loader = default!;
@@ -496,9 +496,7 @@ public sealed class ArrivalsSystem : EntitySystem
private void SetupArrivalsStation() private void SetupArrivalsStation()
{ {
var mapId = _mapManager.CreateMap(); var mapUid = _mapSystem.CreateMap(out var mapId, false);
var mapUid = _mapManager.GetMapEntityId(mapId);
_mapManager.AddUninitializedMap(mapId);
if (!_loader.TryLoad(mapId, _cfgManager.GetCVar(CCVars.ArrivalsMap), out var uids)) if (!_loader.TryLoad(mapId, _cfgManager.GetCVar(CCVars.ArrivalsMap), out var uids))
{ {
@@ -524,7 +522,7 @@ public sealed class ArrivalsSystem : EntitySystem
AddComp(mapUid, restricted); AddComp(mapUid, restricted);
} }
_mapManager.DoMapInitialize(mapId); _mapSystem.InitializeMap(mapId);
// Handle roundstart stations. // Handle roundstart stations.
var query = AllEntityQuery<StationArrivalsComponent>(); var query = AllEntityQuery<StationArrivalsComponent>();
@@ -582,10 +580,10 @@ public sealed class ArrivalsSystem : EntitySystem
return; return;
// Spawn arrivals on a dummy map then dock it to the source. // Spawn arrivals on a dummy map then dock it to the source.
var dummyMap = _mapManager.CreateMap(); var dummpMapEntity = _mapSystem.CreateMap(out var dummyMapId);
if (TryGetArrivals(out var arrivals) && if (TryGetArrivals(out var arrivals) &&
_loader.TryLoad(dummyMap, component.ShuttlePath.ToString(), out var shuttleUids)) _loader.TryLoad(dummyMapId, component.ShuttlePath.ToString(), out var shuttleUids))
{ {
component.Shuttle = shuttleUids[0]; component.Shuttle = shuttleUids[0];
var shuttleComp = Comp<ShuttleComponent>(component.Shuttle); var shuttleComp = Comp<ShuttleComponent>(component.Shuttle);
@@ -597,7 +595,7 @@ public sealed class ArrivalsSystem : EntitySystem
} }
// Don't start the arrivals shuttle immediately docked so power has a time to stabilise? // Don't start the arrivals shuttle immediately docked so power has a time to stabilise?
var timer = AddComp<TimedDespawnComponent>(_mapManager.GetMapEntityId(dummyMap)); var timer = AddComp<TimedDespawnComponent>(dummpMapEntity);
timer.Lifetime = 15f; timer.Lifetime = 15f;
} }
} }

View File

@@ -18,143 +18,143 @@ public sealed partial class DockingSystem
private const int DockRoundingDigits = 2; private const int DockRoundingDigits = 2;
public Angle GetAngle(EntityUid uid, TransformComponent xform, EntityUid targetUid, TransformComponent targetXform, EntityQuery<TransformComponent> xformQuery) public Angle GetAngle(EntityUid uid, TransformComponent xform, EntityUid targetUid, TransformComponent targetXform, EntityQuery<TransformComponent> xformQuery)
{ {
var (shuttlePos, shuttleRot) = _transform.GetWorldPositionRotation(xform); var (shuttlePos, shuttleRot) = _transform.GetWorldPositionRotation(xform);
var (targetPos, targetRot) = _transform.GetWorldPositionRotation(targetXform); var (targetPos, targetRot) = _transform.GetWorldPositionRotation(targetXform);
var shuttleCOM = Robust.Shared.Physics.Transform.Mul(new Transform(shuttlePos, shuttleRot), var shuttleCOM = Robust.Shared.Physics.Transform.Mul(new Transform(shuttlePos, shuttleRot),
_physicsQuery.GetComponent(uid).LocalCenter); _physicsQuery.GetComponent(uid).LocalCenter);
var targetCOM = Robust.Shared.Physics.Transform.Mul(new Transform(targetPos, targetRot), var targetCOM = Robust.Shared.Physics.Transform.Mul(new Transform(targetPos, targetRot),
_physicsQuery.GetComponent(targetUid).LocalCenter); _physicsQuery.GetComponent(targetUid).LocalCenter);
var mapDiff = shuttleCOM - targetCOM; var mapDiff = shuttleCOM - targetCOM;
var angle = mapDiff.ToWorldAngle(); var angle = mapDiff.ToWorldAngle();
angle -= targetRot; angle -= targetRot;
return angle; return angle;
} }
/// <summary> /// <summary>
/// Checks if 2 docks can be connected by moving the shuttle directly onto docks. /// Checks if 2 docks can be connected by moving the shuttle directly onto docks.
/// </summary> /// </summary>
private bool CanDock( private bool CanDock(
DockingComponent shuttleDock, DockingComponent shuttleDock,
TransformComponent shuttleDockXform, TransformComponent shuttleDockXform,
DockingComponent gridDock, DockingComponent gridDock,
TransformComponent gridDockXform, TransformComponent gridDockXform,
Box2 shuttleAABB, Box2 shuttleAABB,
Angle targetGridRotation, Angle targetGridRotation,
FixturesComponent shuttleFixtures, FixturesComponent shuttleFixtures,
MapGridComponent grid, Entity<MapGridComponent> gridEntity,
bool isMap, bool isMap,
out Matrix3x2 matty, out Matrix3x2 matty,
out Box2 shuttleDockedAABB, out Box2 shuttleDockedAABB,
out Angle gridRotation) out Angle gridRotation)
{ {
shuttleDockedAABB = Box2.UnitCentered; shuttleDockedAABB = Box2.UnitCentered;
gridRotation = Angle.Zero; gridRotation = Angle.Zero;
matty = Matrix3x2.Identity; matty = Matrix3x2.Identity;
if (shuttleDock.Docked || if (shuttleDock.Docked ||
gridDock.Docked || gridDock.Docked ||
!shuttleDockXform.Anchored || !shuttleDockXform.Anchored ||
!gridDockXform.Anchored) !gridDockXform.Anchored)
{ {
return false; return false;
} }
// First, get the station dock's position relative to the shuttle, this is where we rotate it around // First, get the station dock's position relative to the shuttle, this is where we rotate it around
var stationDockPos = shuttleDockXform.LocalPosition + var stationDockPos = shuttleDockXform.LocalPosition +
shuttleDockXform.LocalRotation.RotateVec(new Vector2(0f, -1f)); shuttleDockXform.LocalRotation.RotateVec(new Vector2(0f, -1f));
// Need to invert the grid's angle. // Need to invert the grid's angle.
var shuttleDockAngle = shuttleDockXform.LocalRotation; var shuttleDockAngle = shuttleDockXform.LocalRotation;
var gridDockAngle = gridDockXform.LocalRotation.Opposite(); var gridDockAngle = gridDockXform.LocalRotation.Opposite();
var offsetAngle = gridDockAngle - shuttleDockAngle; var offsetAngle = gridDockAngle - shuttleDockAngle;
var stationDockMatrix = Matrix3Helpers.CreateInverseTransform(stationDockPos, shuttleDockAngle); var stationDockMatrix = Matrix3Helpers.CreateInverseTransform(stationDockPos, shuttleDockAngle);
var gridXformMatrix = Matrix3Helpers.CreateTransform(gridDockXform.LocalPosition, gridDockAngle); var gridXformMatrix = Matrix3Helpers.CreateTransform(gridDockXform.LocalPosition, gridDockAngle);
matty = Matrix3x2.Multiply(stationDockMatrix, gridXformMatrix); matty = Matrix3x2.Multiply(stationDockMatrix, gridXformMatrix);
if (!ValidSpawn(grid, matty, offsetAngle, shuttleFixtures, isMap)) if (!ValidSpawn(gridEntity, matty, offsetAngle, shuttleFixtures, isMap))
return false; return false;
shuttleDockedAABB = matty.TransformBox(shuttleAABB); shuttleDockedAABB = matty.TransformBox(shuttleAABB);
gridRotation = (targetGridRotation + offsetAngle).Reduced(); gridRotation = (targetGridRotation + offsetAngle).Reduced();
return true; return true;
} }
/// <summary> /// <summary>
/// Gets docking config between 2 specific docks. /// Gets docking config between 2 specific docks.
/// </summary> /// </summary>
public DockingConfig? GetDockingConfig( public DockingConfig? GetDockingConfig(
EntityUid shuttleUid, EntityUid shuttleUid,
EntityUid targetGrid, EntityUid targetGrid,
EntityUid shuttleDockUid, EntityUid shuttleDockUid,
DockingComponent shuttleDock, DockingComponent shuttleDock,
EntityUid gridDockUid, EntityUid gridDockUid,
DockingComponent gridDock) DockingComponent gridDock)
{ {
var shuttleDocks = new List<Entity<DockingComponent>>(1) var shuttleDocks = new List<Entity<DockingComponent>>(1)
{ {
(shuttleDockUid, shuttleDock) (shuttleDockUid, shuttleDock)
}; };
var gridDocks = new List<Entity<DockingComponent>>(1) var gridDocks = new List<Entity<DockingComponent>>(1)
{ {
(gridDockUid, gridDock) (gridDockUid, gridDock)
}; };
return GetDockingConfigPrivate(shuttleUid, targetGrid, shuttleDocks, gridDocks); return GetDockingConfigPrivate(shuttleUid, targetGrid, shuttleDocks, gridDocks);
} }
/// <summary> /// <summary>
/// Tries to get a valid docking configuration for the shuttle to the target grid. /// Tries to get a valid docking configuration for the shuttle to the target grid.
/// </summary> /// </summary>
/// <param name="priorityTag">Priority docking tag to prefer, e.g. for emergency shuttle</param> /// <param name="priorityTag">Priority docking tag to prefer, e.g. for emergency shuttle</param>
public DockingConfig? GetDockingConfig(EntityUid shuttleUid, EntityUid targetGrid, string? priorityTag = null) public DockingConfig? GetDockingConfig(EntityUid shuttleUid, EntityUid targetGrid, string? priorityTag = null)
{ {
var gridDocks = GetDocks(targetGrid); var gridDocks = GetDocks(targetGrid);
var shuttleDocks = GetDocks(shuttleUid); var shuttleDocks = GetDocks(shuttleUid);
return GetDockingConfigPrivate(shuttleUid, targetGrid, shuttleDocks, gridDocks, priorityTag); return GetDockingConfigPrivate(shuttleUid, targetGrid, shuttleDocks, gridDocks, priorityTag);
} }
/// <summary> /// <summary>
/// Tries to get a docking config at the specified coordinates and angle. /// Tries to get a docking config at the specified coordinates and angle.
/// </summary> /// </summary>
public DockingConfig? GetDockingConfigAt(EntityUid shuttleUid, public DockingConfig? GetDockingConfigAt(EntityUid shuttleUid,
EntityUid targetGrid, EntityUid targetGrid,
EntityCoordinates coordinates, EntityCoordinates coordinates,
Angle angle) Angle angle)
{ {
var gridDocks = GetDocks(targetGrid); var gridDocks = GetDocks(targetGrid);
var shuttleDocks = GetDocks(shuttleUid); var shuttleDocks = GetDocks(shuttleUid);
var configs = GetDockingConfigs(shuttleUid, targetGrid, shuttleDocks, gridDocks); var configs = GetDockingConfigs(shuttleUid, targetGrid, shuttleDocks, gridDocks);
foreach (var config in configs) foreach (var config in configs)
{ {
if (config.Coordinates.Equals(coordinates) && config.Angle.EqualsApprox(angle, 0.15)) if (config.Coordinates.Equals(coordinates) && config.Angle.EqualsApprox(angle, 0.15))
{ {
return config; return config;
} }
} }
return null; return null;
} }
/// <summary> /// <summary>
/// Gets all docking configs between the 2 grids. /// Gets all docking configs between the 2 grids.
/// </summary> /// </summary>
private List<DockingConfig> GetDockingConfigs( private List<DockingConfig> GetDockingConfigs(
EntityUid shuttleUid, EntityUid shuttleUid,
EntityUid targetGrid, EntityUid targetGrid,
List<Entity<DockingComponent>> shuttleDocks, List<Entity<DockingComponent>> shuttleDocks,
List<Entity<DockingComponent>> gridDocks) List<Entity<DockingComponent>> gridDocks)
{ {
var validDockConfigs = new List<DockingConfig>(); var validDockConfigs = new List<DockingConfig>();
if (gridDocks.Count <= 0) if (gridDocks.Count <= 0)
return validDockConfigs; return validDockConfigs;
var targetGridGrid = _gridQuery.GetComponent(targetGrid); var targetGridGrid = _gridQuery.GetComponent(targetGrid);
@@ -168,117 +168,118 @@ public sealed partial class DockingSystem
var grids = new List<Entity<MapGridComponent>>(); var grids = new List<Entity<MapGridComponent>>();
if (shuttleDocks.Count > 0) if (shuttleDocks.Count > 0)
{ {
// We'll try all combinations of shuttle docks and see which one is most suitable // We'll try all combinations of shuttle docks and see which one is most suitable
foreach (var (dockUid, shuttleDock) in shuttleDocks) foreach (var (dockUid, shuttleDock) in shuttleDocks)
{ {
var shuttleDockXform = _xformQuery.GetComponent(dockUid); var shuttleDockXform = _xformQuery.GetComponent(dockUid);
foreach (var (gridDockUid, gridDock) in gridDocks) foreach (var (gridDockUid, gridDock) in gridDocks)
{ {
var gridXform = _xformQuery.GetComponent(gridDockUid); var gridXform = _xformQuery.GetComponent(gridDockUid);
if (!CanDock( if (!CanDock(
shuttleDock, shuttleDockXform, shuttleDock, shuttleDockXform,
gridDock, gridXform, gridDock, gridXform,
shuttleAABB, shuttleAABB,
targetGridAngle, targetGridAngle,
shuttleFixturesComp, shuttleFixturesComp,
targetGridGrid, (targetGrid, targetGridGrid),
isMap, isMap,
out var matty, out var matty,
out var dockedAABB, out var dockedAABB,
out var targetAngle)) out var targetAngle))
{ {
continue; continue;
} }
// Can't just use the AABB as we want to get bounds as tight as possible. // Can't just use the AABB as we want to get bounds as tight as possible.
var gridPosition = new EntityCoordinates(targetGrid, Vector2.Transform(Vector2.Zero, matty)); var gridPosition = new EntityCoordinates(targetGrid, Vector2.Transform(Vector2.Zero, matty));
var spawnPosition = new EntityCoordinates(targetGridXform.MapUid!.Value, gridPosition.ToMapPos(EntityManager, _transform)); var spawnPosition = new EntityCoordinates(targetGridXform.MapUid!.Value, _transform.ToMapCoordinates(gridPosition).Position);
// TODO: use tight bounds // TODO: use tight bounds
var dockedBounds = new Box2Rotated(shuttleAABB.Translated(spawnPosition.Position), targetAngle, spawnPosition.Position); var dockedBounds = new Box2Rotated(shuttleAABB.Translated(spawnPosition.Position), targetAngle, spawnPosition.Position);
// Check if there's no intersecting grids (AKA oh god it's docking at cargo). // Check if there's no intersecting grids (AKA oh god it's docking at cargo).
grids.Clear(); grids.Clear();
_mapManager.FindGridsIntersecting(targetGridXform.MapID, dockedBounds, ref grids, includeMap: false); _mapManager.FindGridsIntersecting(targetGridXform.MapID, dockedBounds, ref grids, includeMap: false);
if (grids.Any(o => o.Owner != targetGrid && o.Owner != targetGridXform.MapUid)) if (grids.Any(o => o.Owner != targetGrid && o.Owner != targetGridXform.MapUid))
{ {
continue; continue;
} }
// Alright well the spawn is valid now to check how many we can connect // Alright well the spawn is valid now to check how many we can connect
// Get the matrix for each shuttle dock and test it against the grid docks to see // Get the matrix for each shuttle dock and test it against the grid docks to see
// if the connected position / direction matches. // if the connected position / direction matches.
var dockedPorts = new List<(EntityUid DockAUid, EntityUid DockBUid, DockingComponent DockA, DockingComponent DockB)>() var dockedPorts = new List<(EntityUid DockAUid, EntityUid DockBUid, DockingComponent DockA, DockingComponent DockB)>()
{ {
(dockUid, gridDockUid, shuttleDock, gridDock), (dockUid, gridDockUid, shuttleDock, gridDock),
}; };
dockedAABB = dockedAABB.Rounded(DockRoundingDigits); dockedAABB = dockedAABB.Rounded(DockRoundingDigits);
foreach (var (otherUid, other) in shuttleDocks) foreach (var (otherUid, other) in shuttleDocks)
{ {
if (other == shuttleDock) if (other == shuttleDock)
continue; continue;
foreach (var (otherGridUid, otherGrid) in gridDocks) foreach (var (otherGridUid, otherGrid) in gridDocks)
{ {
if (otherGrid == gridDock) if (otherGrid == gridDock)
continue; continue;
if (!CanDock( if (!CanDock(
other, other,
_xformQuery.GetComponent(otherUid), _xformQuery.GetComponent(otherUid),
otherGrid, otherGrid,
_xformQuery.GetComponent(otherGridUid), _xformQuery.GetComponent(otherGridUid),
shuttleAABB, shuttleAABB,
targetGridAngle, targetGridAngle,
shuttleFixturesComp, targetGridGrid, shuttleFixturesComp,
isMap, (targetGrid, targetGridGrid),
out _, isMap,
out var otherdockedAABB, out _,
out var otherTargetAngle)) out var otherdockedAABB,
{ out var otherTargetAngle))
continue; {
} continue;
}
otherdockedAABB = otherdockedAABB.Rounded(DockRoundingDigits); otherdockedAABB = otherdockedAABB.Rounded(DockRoundingDigits);
// Different setup. // Different setup.
if (!targetAngle.Equals(otherTargetAngle) || if (!targetAngle.Equals(otherTargetAngle) ||
!dockedAABB.Equals(otherdockedAABB)) !dockedAABB.Equals(otherdockedAABB))
{ {
continue; continue;
} }
dockedPorts.Add((otherUid, otherGridUid, other, otherGrid)); dockedPorts.Add((otherUid, otherGridUid, other, otherGrid));
} }
} }
validDockConfigs.Add(new DockingConfig() validDockConfigs.Add(new DockingConfig()
{ {
Docks = dockedPorts, Docks = dockedPorts,
Coordinates = gridPosition, Coordinates = gridPosition,
Area = dockedAABB, Area = dockedAABB,
Angle = targetAngle, Angle = targetAngle,
}); });
} }
} }
} }
return validDockConfigs; return validDockConfigs;
} }
private DockingConfig? GetDockingConfigPrivate( private DockingConfig? GetDockingConfigPrivate(
EntityUid shuttleUid, EntityUid shuttleUid,
EntityUid targetGrid, EntityUid targetGrid,
List<Entity<DockingComponent>> shuttleDocks, List<Entity<DockingComponent>> shuttleDocks,
List<Entity<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);
if (validDockConfigs.Count <= 0) if (validDockConfigs.Count <= 0)
return null; return null;
@@ -300,56 +301,56 @@ public sealed partial class DockingSystem
return location; return location;
} }
/// <summary> /// <summary>
/// Checks whether the shuttle can warp to the specified position. /// Checks whether the shuttle can warp to the specified position.
/// </summary> /// </summary>
private bool ValidSpawn(MapGridComponent grid, Matrix3x2 matty, Angle angle, FixturesComponent shuttleFixturesComp, bool isMap) private bool ValidSpawn(Entity<MapGridComponent> gridEntity, Matrix3x2 matty, Angle angle, FixturesComponent shuttleFixturesComp, bool isMap)
{ {
var transform = new Transform(Vector2.Transform(Vector2.Zero, matty), angle); var transform = new Transform(Vector2.Transform(Vector2.Zero, matty), angle);
// Because some docking bounds are tight af need to check each chunk individually // Because some docking bounds are tight af need to check each chunk individually
foreach (var fix in shuttleFixturesComp.Fixtures.Values) foreach (var fix in shuttleFixturesComp.Fixtures.Values)
{ {
var polyShape = (PolygonShape) fix.Shape; var polyShape = (PolygonShape)fix.Shape;
var aabb = polyShape.ComputeAABB(transform, 0); var aabb = polyShape.ComputeAABB(transform, 0);
aabb = aabb.Enlarged(-0.01f); aabb = aabb.Enlarged(-0.01f);
// If it's a map check no hard collidable anchored entities overlap // If it's a map check no hard collidable anchored entities overlap
if (isMap) if (isMap)
{ {
foreach (var tile in grid.GetLocalTilesIntersecting(aabb)) foreach (var tile in _mapSystem.GetLocalTilesIntersecting(gridEntity.Owner, gridEntity.Comp, aabb))
{ {
var anchoredEnumerator = grid.GetAnchoredEntitiesEnumerator(tile.GridIndices); var anchoredEnumerator = _mapSystem.GetAnchoredEntitiesEnumerator(gridEntity.Owner, gridEntity.Comp, tile.GridIndices);
while (anchoredEnumerator.MoveNext(out var anc)) while (anchoredEnumerator.MoveNext(out var anc))
{ {
if (!_physicsQuery.TryGetComponent(anc, out var physics) || if (!_physicsQuery.TryGetComponent(anc, out var physics) ||
!physics.CanCollide || !physics.CanCollide ||
!physics.Hard) !physics.Hard)
{ {
continue; continue;
} }
return false; return false;
} }
} }
} }
// If it's not a map check it doesn't overlap the grid. // If it's not a map check it doesn't overlap the grid.
else else
{ {
if (grid.GetLocalTilesIntersecting(aabb).Any()) if (_mapSystem.GetLocalTilesIntersecting(gridEntity.Owner, gridEntity.Comp, aabb).Any())
return false; return false;
} }
} }
return true; return true;
} }
public List<Entity<DockingComponent>> GetDocks(EntityUid uid) public List<Entity<DockingComponent>> GetDocks(EntityUid uid)
{ {
_dockingSet.Clear(); _dockingSet.Clear();
_lookup.GetChildEntities(uid, _dockingSet); _lookup.GetChildEntities(uid, _dockingSet);
return _dockingSet.ToList(); return _dockingSet.ToList();
} }
} }

View File

@@ -23,6 +23,7 @@ namespace Content.Server.Shuttles.Systems
public sealed partial class DockingSystem : SharedDockingSystem public sealed partial class DockingSystem : SharedDockingSystem
{ {
[Dependency] private readonly IMapManager _mapManager = default!; [Dependency] private readonly IMapManager _mapManager = default!;
[Dependency] private readonly SharedMapSystem _mapSystem = default!;
[Dependency] private readonly DoorSystem _doorSystem = default!; [Dependency] private readonly DoorSystem _doorSystem = default!;
[Dependency] private readonly EntityLookupSystem _lookup = default!; [Dependency] private readonly EntityLookupSystem _lookup = default!;
[Dependency] private readonly PathfindingSystem _pathfinding = default!; [Dependency] private readonly PathfindingSystem _pathfinding = default!;
@@ -262,7 +263,7 @@ namespace Content.Server.Shuttles.Systems
joint.LocalAnchorA = anchorA; joint.LocalAnchorA = anchorA;
joint.LocalAnchorB = anchorB; joint.LocalAnchorB = anchorB;
joint.ReferenceAngle = (float) (_transform.GetWorldRotation(gridBXform) - _transform.GetWorldRotation(gridAXform)); joint.ReferenceAngle = (float)(_transform.GetWorldRotation(gridBXform) - _transform.GetWorldRotation(gridAXform));
joint.CollideConnected = true; joint.CollideConnected = true;
joint.Stiffness = stiffness; joint.Stiffness = stiffness;
joint.Damping = damping; joint.Damping = damping;

View File

@@ -220,7 +220,7 @@ public sealed partial class EmergencyShuttleSystem
ShuttlesLeft = true; ShuttlesLeft = true;
_chatSystem.DispatchGlobalAnnouncement(Loc.GetString("emergency-shuttle-left", ("transitTime", $"{TransitTime:0}"))); _chatSystem.DispatchGlobalAnnouncement(Loc.GetString("emergency-shuttle-left", ("transitTime", $"{TransitTime:0}")));
Timer.Spawn((int) (TransitTime * 1000) + _bufferTime.Milliseconds, () => _roundEnd.EndRound(), _roundEndCancelToken?.Token ?? default); Timer.Spawn((int)(TransitTime * 1000) + _bufferTime.Milliseconds, () => _roundEnd.EndRound(), _roundEndCancelToken?.Token ?? default);
} }
// All the others. // All the others.

View File

@@ -50,8 +50,8 @@ public sealed partial class EmergencyShuttleSystem : EntitySystem
[Dependency] private readonly IAdminManager _admin = default!; [Dependency] private readonly IAdminManager _admin = default!;
[Dependency] private readonly IConfigurationManager _configManager = default!; [Dependency] private readonly IConfigurationManager _configManager = default!;
[Dependency] private readonly IGameTiming _timing = default!; [Dependency] private readonly IGameTiming _timing = default!;
[Dependency] private readonly IMapManager _mapManager = default!;
[Dependency] private readonly IRobustRandom _random = default!; [Dependency] private readonly IRobustRandom _random = default!;
[Dependency] private readonly SharedMapSystem _mapSystem = default!;
[Dependency] private readonly AccessReaderSystem _reader = default!; [Dependency] private readonly AccessReaderSystem _reader = default!;
[Dependency] private readonly ChatSystem _chatSystem = default!; [Dependency] private readonly ChatSystem _chatSystem = default!;
[Dependency] private readonly CommunicationsConsoleSystem _commsConsole = default!; [Dependency] private readonly CommunicationsConsoleSystem _commsConsole = default!;
@@ -212,7 +212,7 @@ public sealed partial class EmergencyShuttleSystem : EntitySystem
{ {
[ShuttleTimerMasks.ShuttleMap] = uid, [ShuttleTimerMasks.ShuttleMap] = uid,
[ShuttleTimerMasks.SourceMap] = args.FromMapUid, [ShuttleTimerMasks.SourceMap] = args.FromMapUid,
[ShuttleTimerMasks.DestMap] = args.TargetCoordinates.GetMapUid(_entityManager), [ShuttleTimerMasks.DestMap] = _transformSystem.GetMap(args.TargetCoordinates),
[ShuttleTimerMasks.ShuttleTime] = ftlTime, [ShuttleTimerMasks.ShuttleTime] = ftlTime,
[ShuttleTimerMasks.SourceTime] = ftlTime, [ShuttleTimerMasks.SourceTime] = ftlTime,
[ShuttleTimerMasks.DestTime] = ftlTime [ShuttleTimerMasks.DestTime] = ftlTime
@@ -289,7 +289,7 @@ public sealed partial class EmergencyShuttleSystem : EntitySystem
{ {
var angle = _dock.GetAngle(stationShuttle.EmergencyShuttle.Value, xform, targetGrid.Value, targetXform, xformQuery); var angle = _dock.GetAngle(stationShuttle.EmergencyShuttle.Value, xform, targetGrid.Value, targetXform, xformQuery);
var direction = ContentLocalizationManager.FormatDirection(angle.GetDir()); var direction = ContentLocalizationManager.FormatDirection(angle.GetDir());
var location = FormattedMessage.RemoveMarkup(_navMap.GetNearestBeaconString((stationShuttle.EmergencyShuttle.Value, xform))); var location = FormattedMessage.RemoveMarkupPermissive(_navMap.GetNearestBeaconString((stationShuttle.EmergencyShuttle.Value, xform)));
_chatSystem.DispatchStationAnnouncement(stationUid, Loc.GetString("emergency-shuttle-docked", ("time", $"{_consoleAccumulator:0}"), ("direction", direction), ("location", location)), playDefaultSound: false); _chatSystem.DispatchStationAnnouncement(stationUid, Loc.GetString("emergency-shuttle-docked", ("time", $"{_consoleAccumulator:0}"), ("direction", direction), ("location", location)), playDefaultSound: false);
} }
@@ -320,7 +320,7 @@ public sealed partial class EmergencyShuttleSystem : EntitySystem
{ {
var angle = _dock.GetAngle(stationShuttle.EmergencyShuttle.Value, xform, targetGrid.Value, targetXform, xformQuery); var angle = _dock.GetAngle(stationShuttle.EmergencyShuttle.Value, xform, targetGrid.Value, targetXform, xformQuery);
var direction = ContentLocalizationManager.FormatDirection(angle.GetDir()); var direction = ContentLocalizationManager.FormatDirection(angle.GetDir());
var location = FormattedMessage.RemoveMarkup(_navMap.GetNearestBeaconString((stationShuttle.EmergencyShuttle.Value, xform))); var location = FormattedMessage.RemoveMarkupPermissive(_navMap.GetNearestBeaconString((stationShuttle.EmergencyShuttle.Value, xform)));
_chatSystem.DispatchStationAnnouncement(stationUid, Loc.GetString("emergency-shuttle-nearby", ("time", $"{_consoleAccumulator:0}"), ("direction", direction), ("location", location)), playDefaultSound: false); _chatSystem.DispatchStationAnnouncement(stationUid, Loc.GetString("emergency-shuttle-nearby", ("time", $"{_consoleAccumulator:0}"), ("direction", direction), ("location", location)), playDefaultSound: false);
} }
@@ -401,7 +401,7 @@ public sealed partial class EmergencyShuttleSystem : EntitySystem
private void AddCentcomm(EntityUid station, StationCentcommComponent component) private void AddCentcomm(EntityUid station, StationCentcommComponent component)
{ {
DebugTools.Assert(LifeStage(station)>= EntityLifeStage.MapInitialized); DebugTools.Assert(LifeStage(station) >= EntityLifeStage.MapInitialized);
if (component.MapEntity != null || component.Entity != null) if (component.MapEntity != null || component.Entity != null)
{ {
Log.Warning("Attempted to re-add an existing centcomm map."); Log.Warning("Attempted to re-add an existing centcomm map.");
@@ -434,12 +434,11 @@ public sealed partial class EmergencyShuttleSystem : EntitySystem
return; return;
} }
var mapId = _mapManager.CreateMap(); var map = _mapSystem.CreateMap(out var mapId);
var grid = _map.LoadGrid(mapId, component.Map.ToString(), new MapLoadOptions() var grid = _map.LoadGrid(mapId, component.Map.ToString(), new MapLoadOptions()
{ {
LoadMap = false, LoadMap = false,
}); });
var map = _mapManager.GetMapEntityId(mapId);
if (!Exists(map)) if (!Exists(map))
{ {
@@ -492,7 +491,7 @@ public sealed partial class EmergencyShuttleSystem : EntitySystem
if (!_emergencyShuttleEnabled) if (!_emergencyShuttleEnabled)
return; return;
if (ent.Comp1.EmergencyShuttle != null ) if (ent.Comp1.EmergencyShuttle != null)
{ {
if (Exists(ent.Comp1.EmergencyShuttle)) if (Exists(ent.Comp1.EmergencyShuttle))
{ {

View File

@@ -63,7 +63,7 @@ public sealed partial class ShuttleConsoleSystem
private void OnPositionFTLMessage(Entity<ShuttleConsoleComponent> entity, ref ShuttleConsoleFTLPositionMessage args) private void OnPositionFTLMessage(Entity<ShuttleConsoleComponent> entity, ref ShuttleConsoleFTLPositionMessage args)
{ {
var mapUid = _mapManager.GetMapEntityId(args.Coordinates.MapId); var mapUid = _mapSystem.GetMap(args.Coordinates.MapId);
// If it's beacons only block all position messages. // If it's beacons only block all position messages.
if (!Exists(mapUid) || _shuttle.IsBeaconMap(mapUid)) if (!Exists(mapUid) || _shuttle.IsBeaconMap(mapUid))

View File

@@ -26,7 +26,7 @@ namespace Content.Server.Shuttles.Systems;
public sealed partial class ShuttleConsoleSystem : SharedShuttleConsoleSystem public sealed partial class ShuttleConsoleSystem : SharedShuttleConsoleSystem
{ {
[Dependency] private readonly IMapManager _mapManager = default!; [Dependency] private readonly SharedMapSystem _mapSystem = default!;
[Dependency] private readonly ActionBlockerSystem _blocker = default!; [Dependency] private readonly ActionBlockerSystem _blocker = default!;
[Dependency] private readonly AlertsSystem _alertsSystem = default!; [Dependency] private readonly AlertsSystem _alertsSystem = default!;
[Dependency] private readonly EntityLookupSystem _lookup = default!; [Dependency] private readonly EntityLookupSystem _lookup = default!;
@@ -129,7 +129,7 @@ public sealed partial class ShuttleConsoleSystem : SharedShuttleConsoleSystem
while (query.MoveNext(out var uid, out _)) while (query.MoveNext(out var uid, out _))
{ {
UpdateState(uid,ref dockState); UpdateState(uid, ref dockState);
} }
} }
@@ -138,7 +138,7 @@ public sealed partial class ShuttleConsoleSystem : SharedShuttleConsoleSystem
/// </summary> /// </summary>
private void OnConsoleUIClose(EntityUid uid, ShuttleConsoleComponent component, BoundUIClosedEvent args) private void OnConsoleUIClose(EntityUid uid, ShuttleConsoleComponent component, BoundUIClosedEvent args)
{ {
if ((ShuttleConsoleUiKey) args.UiKey != ShuttleConsoleUiKey.Key) if ((ShuttleConsoleUiKey)args.UiKey != ShuttleConsoleUiKey.Key)
{ {
return; return;
} }

View File

@@ -134,13 +134,12 @@ public sealed partial class ShuttleSystem
return uid; return uid;
} }
var mapId = _mapManager.CreateMap(); var mapUid = _mapSystem.CreateMap(out var mapId);
var mapUid = _mapManager.GetMapEntityId(mapId);
var ftlMap = AddComp<FTLMapComponent>(mapUid); var ftlMap = AddComp<FTLMapComponent>(mapUid);
_metadata.SetEntityName(mapUid, "FTL"); _metadata.SetEntityName(mapUid, "FTL");
Log.Debug($"Setup hyperspace map at {mapUid}"); Log.Debug($"Setup hyperspace map at {mapUid}");
DebugTools.Assert(!_mapManager.IsMapPaused(mapId)); DebugTools.Assert(!_mapSystem.IsPaused(mapId));
var parallax = EnsureComp<ParallaxComponent>(mapUid); var parallax = EnsureComp<ParallaxComponent>(mapUid);
parallax.Parallax = ftlMap.Parallax; parallax.Parallax = ftlMap.Parallax;
@@ -188,7 +187,7 @@ public sealed partial class ShuttleSystem
/// </summary> /// </summary>
public bool TryAddFTLDestination(MapId mapId, bool enabled, [NotNullWhen(true)] out FTLDestinationComponent? component) public bool TryAddFTLDestination(MapId mapId, bool enabled, [NotNullWhen(true)] out FTLDestinationComponent? component)
{ {
var mapUid = _mapManager.GetMapEntityId(mapId); var mapUid = _mapSystem.GetMapOrInvalid(mapId);
component = null; component = null;
if (!Exists(mapUid)) if (!Exists(mapUid))
@@ -281,8 +280,8 @@ public sealed partial class ShuttleSystem
_console.RefreshShuttleConsoles(shuttleUid); _console.RefreshShuttleConsoles(shuttleUid);
var mapId = coordinates.GetMapId(EntityManager); var mapId = _transform.GetMapId(coordinates);
var mapUid = _mapManager.GetMapEntityId(mapId); var mapUid = _mapSystem.GetMap(mapId);
var ev = new FTLRequestEvent(mapUid); var ev = new FTLRequestEvent(mapUid);
RaiseLocalEvent(shuttleUid, ref ev, true); RaiseLocalEvent(shuttleUid, ref ev, true);
} }
@@ -388,7 +387,7 @@ public sealed partial class ShuttleSystem
if (fromMapUid != null && TryComp(comp.StartupStream, out AudioComponent? startupAudio)) if (fromMapUid != null && TryComp(comp.StartupStream, out AudioComponent? startupAudio))
{ {
var clippedAudio = _audio.PlayStatic(_startupSound, Filter.Broadcast(), var clippedAudio = _audio.PlayStatic(_startupSound, Filter.Broadcast(),
new EntityCoordinates(fromMapUid.Value, _maps.GetGridPosition(entity.Owner)), true, startupAudio.Params); new EntityCoordinates(fromMapUid.Value, _mapSystem.GetGridPosition(entity.Owner)), true, startupAudio.Params);
_audio.SetPlaybackPosition(clippedAudio, entity.Comp1.StartupTime); _audio.SetPlaybackPosition(clippedAudio, entity.Comp1.StartupTime);
clippedAudio.Value.Component.Flags |= AudioFlags.NoOcclusion; clippedAudio.Value.Component.Flags |= AudioFlags.NoOcclusion;
@@ -477,7 +476,7 @@ public sealed partial class ShuttleSystem
var map = maps.Min(o => o.GetHashCode()); var map = maps.Min(o => o.GetHashCode());
mapId = new MapId(map); mapId = new MapId(map);
TryFTLProximity(uid, _mapManager.GetMapEntityId(mapId)); TryFTLProximity(uid, _mapSystem.GetMap(mapId));
} }
// Docking FTL // Docking FTL
else if (HasComp<MapGridComponent>(target.EntityId) && else if (HasComp<MapGridComponent>(target.EntityId) &&
@@ -502,7 +501,7 @@ public sealed partial class ShuttleSystem
else else
{ {
// TODO: This should now use tryftlproximity // TODO: This should now use tryftlproximity
mapId = target.GetMapId(EntityManager); mapId = _transform.GetMapId(target);
_transform.SetCoordinates(uid, xform, target, rotation: entity.Comp1.TargetAngle); _transform.SetCoordinates(uid, xform, target, rotation: entity.Comp1.TargetAngle);
} }
@@ -540,7 +539,7 @@ public sealed partial class ShuttleSystem
_mapManager.SetMapPaused(mapId, false); _mapManager.SetMapPaused(mapId, false);
Smimsh(uid, xform: xform); Smimsh(uid, xform: xform);
var ftlEvent = new FTLCompletedEvent(uid, _mapManager.GetMapEntityId(mapId)); var ftlEvent = new FTLCompletedEvent(uid, _mapSystem.GetMap(mapId));
RaiseLocalEvent(uid, ref ftlEvent, true); RaiseLocalEvent(uid, ref ftlEvent, true);
} }
@@ -616,7 +615,7 @@ public sealed partial class ShuttleSystem
// If the guy we knocked down is on a spaced tile, throw them too // If the guy we knocked down is on a spaced tile, throw them too
if (grid != null) if (grid != null)
TossIfSpaced(grid, shuttleBody, child); TossIfSpaced((xform.GridUid.Value, grid, shuttleBody), child);
} }
} }
} }
@@ -637,13 +636,15 @@ public sealed partial class ShuttleSystem
/// <summary> /// <summary>
/// Throws people who are standing on a spaced tile, tries to throw them towards a neighbouring space tile /// Throws people who are standing on a spaced tile, tries to throw them towards a neighbouring space tile
/// </summary> /// </summary>
private void TossIfSpaced(MapGridComponent shuttleGrid, PhysicsComponent shuttleBody, EntityUid tossed) private void TossIfSpaced(Entity<MapGridComponent, PhysicsComponent> shuttleEntity, EntityUid tossed)
{ {
if (!_xformQuery.TryGetComponent(tossed, out var childXform) ) var shuttleGrid = shuttleEntity.Comp1;
var shuttleBody = shuttleEntity.Comp2;
if (!_xformQuery.TryGetComponent(tossed, out var childXform))
return; return;
// only toss if its on lattice/space // only toss if its on lattice/space
var tile = shuttleGrid.GetTileRef(childXform.Coordinates); var tile = _mapSystem.GetTileRef(shuttleEntity, shuttleGrid, childXform.Coordinates);
if (!tile.IsSpace(_tileDefManager)) if (!tile.IsSpace(_tileDefManager))
return; return;
@@ -689,7 +690,7 @@ public sealed partial class ShuttleSystem
{ {
// Set position // Set position
var mapCoordinates = _transform.ToMapCoordinates(config.Coordinates); var mapCoordinates = _transform.ToMapCoordinates(config.Coordinates);
var mapUid = _mapManager.GetMapEntityId(mapCoordinates.MapId); var mapUid = _mapSystem.GetMap(mapCoordinates.MapId);
_transform.SetCoordinates(shuttle.Owner, shuttle.Comp, new EntityCoordinates(mapUid, mapCoordinates.Position), rotation: config.Angle); _transform.SetCoordinates(shuttle.Owner, shuttle.Comp, new EntityCoordinates(mapUid, mapCoordinates.Position), rotation: config.Angle);
// Connect everything // Connect everything

View File

@@ -110,7 +110,7 @@ public sealed partial class ShuttleSystem
spawnCoords = spawnCoords.Offset(_random.NextVector2(distancePadding + group.MinimumDistance, distancePadding + group.MaximumDistance)); spawnCoords = spawnCoords.Offset(_random.NextVector2(distancePadding + group.MinimumDistance, distancePadding + group.MaximumDistance));
} }
_maps.CreateMap(out var mapId); _mapSystem.CreateMap(out var mapId);
var spawnedGrid = _mapManager.CreateGridEntity(mapId); var spawnedGrid = _mapManager.CreateGridEntity(mapId);

View File

@@ -39,8 +39,8 @@ public sealed partial class ShuttleSystem
var otherXform = Transform(args.OtherEntity); var otherXform = Transform(args.OtherEntity);
var ourPoint = Vector2.Transform(args.WorldPoint, ourXform.InvWorldMatrix); var ourPoint = Vector2.Transform(args.WorldPoint, _transform.GetInvWorldMatrix(ourXform));
var otherPoint = Vector2.Transform(args.WorldPoint, otherXform.InvWorldMatrix); var otherPoint = Vector2.Transform(args.WorldPoint, _transform.GetInvWorldMatrix(otherXform));
var ourVelocity = _physics.GetLinearVelocity(uid, ourPoint, ourBody, ourXform); var ourVelocity = _physics.GetLinearVelocity(uid, ourPoint, ourBody, ourXform);
var otherVelocity = _physics.GetLinearVelocity(args.OtherEntity, otherPoint, otherBody, otherXform); var otherVelocity = _physics.GetLinearVelocity(args.OtherEntity, otherPoint, otherBody, otherXform);

View File

@@ -49,7 +49,6 @@ public sealed partial class ShuttleSystem : SharedShuttleSystem
[Dependency] private readonly MetaDataSystem _metadata = default!; [Dependency] private readonly MetaDataSystem _metadata = default!;
[Dependency] private readonly PvsOverrideSystem _pvs = default!; [Dependency] private readonly PvsOverrideSystem _pvs = default!;
[Dependency] private readonly SharedAudioSystem _audio = default!; [Dependency] private readonly SharedAudioSystem _audio = default!;
[Dependency] private readonly SharedMapSystem _maps = default!;
[Dependency] private readonly SharedPhysicsSystem _physics = default!; [Dependency] private readonly SharedPhysicsSystem _physics = default!;
[Dependency] private readonly SharedTransformSystem _transform = default!; [Dependency] private readonly SharedTransformSystem _transform = default!;
[Dependency] private readonly ShuttleConsoleSystem _console = default!; [Dependency] private readonly ShuttleConsoleSystem _console = default!;

View File

@@ -27,6 +27,7 @@ public sealed class ThrusterSystem : EntitySystem
{ {
[Dependency] private readonly IGameTiming _timing = default!; [Dependency] private readonly IGameTiming _timing = default!;
[Dependency] private readonly ITileDefinitionManager _tileDefManager = default!; [Dependency] private readonly ITileDefinitionManager _tileDefManager = default!;
[Dependency] private readonly SharedMapSystem _mapSystem = default!;
[Dependency] private readonly AmbientSoundSystem _ambient = default!; [Dependency] private readonly AmbientSoundSystem _ambient = default!;
[Dependency] private readonly FixtureSystem _fixtureSystem = default!; [Dependency] private readonly FixtureSystem _fixtureSystem = default!;
[Dependency] private readonly DamageableSystem _damageable = default!; [Dependency] private readonly DamageableSystem _damageable = default!;
@@ -109,7 +110,7 @@ public sealed class ThrusterSystem : EntitySystem
continue; continue;
var checkPos = tilePos + new Vector2i(x, y); var checkPos = tilePos + new Vector2i(x, y);
var enumerator = grid.GetAnchoredEntitiesEnumerator(checkPos); var enumerator = _mapSystem.GetAnchoredEntitiesEnumerator(uid, grid, checkPos);
while (enumerator.MoveNext(out var ent)) while (enumerator.MoveNext(out var ent))
{ {
@@ -120,7 +121,7 @@ public sealed class ThrusterSystem : EntitySystem
var xform = xformQuery.GetComponent(ent.Value); var xform = xformQuery.GetComponent(ent.Value);
var direction = xform.LocalRotation.ToWorldVec(); var direction = xform.LocalRotation.ToWorldVec();
if (new Vector2i((int) direction.X, (int) direction.Y) != new Vector2i(x, y)) if (new Vector2i((int)direction.X, (int)direction.Y) != new Vector2i(x, y))
continue; continue;
DisableThruster(ent.Value, thruster, xform.GridUid); DisableThruster(ent.Value, thruster, xform.GridUid);
@@ -183,8 +184,8 @@ public sealed class ThrusterSystem : EntitySystem
return; return;
} }
var oldDirection = (int) args.OldRotation.GetCardinalDir() / 2; var oldDirection = (int)args.OldRotation.GetCardinalDir() / 2;
var direction = (int) args.NewRotation.GetCardinalDir() / 2; var direction = (int)args.NewRotation.GetCardinalDir() / 2;
var oldShuttleComponent = shuttleComponent; var oldShuttleComponent = shuttleComponent;
if (args.ParentChanged) if (args.ParentChanged)
@@ -282,7 +283,7 @@ public sealed class ThrusterSystem : EntitySystem
switch (component.Type) switch (component.Type)
{ {
case ThrusterType.Linear: case ThrusterType.Linear:
var direction = (int) xform.LocalRotation.GetCardinalDir() / 2; var direction = (int)xform.LocalRotation.GetCardinalDir() / 2;
shuttleComponent.LinearThrust[direction] += component.Thrust; shuttleComponent.LinearThrust[direction] += component.Thrust;
DebugTools.Assert(!shuttleComponent.LinearThrusters[direction].Contains(uid)); DebugTools.Assert(!shuttleComponent.LinearThrusters[direction].Contains(uid));
@@ -294,7 +295,7 @@ public sealed class ThrusterSystem : EntitySystem
{ {
var shape = new PolygonShape(); var shape = new PolygonShape();
shape.Set(component.BurnPoly); shape.Set(component.BurnPoly);
_fixtureSystem.TryCreateFixture(uid, shape, BurnFixture, hard: false, collisionLayer: (int) CollisionGroup.FullTileMask, body: physicsComponent); _fixtureSystem.TryCreateFixture(uid, shape, BurnFixture, hard: false, collisionLayer: (int)CollisionGroup.FullTileMask, body: physicsComponent);
} }
break; break;
@@ -334,7 +335,7 @@ public sealed class ThrusterSystem : EntitySystem
foreach (var dir in new[] foreach (var dir in new[]
{ Direction.South, Direction.East, Direction.North, Direction.West }) { Direction.South, Direction.East, Direction.North, Direction.West })
{ {
var index = (int) dir / 2; var index = (int)dir / 2;
var pop = shuttle.LinearThrusters[index]; var pop = shuttle.LinearThrusters[index];
var totalThrust = 0f; var totalThrust = 0f;
@@ -380,7 +381,7 @@ public sealed class ThrusterSystem : EntitySystem
{ {
case ThrusterType.Linear: case ThrusterType.Linear:
angle ??= xform.LocalRotation; angle ??= xform.LocalRotation;
var direction = (int) angle.Value.GetCardinalDir() / 2; var direction = (int)angle.Value.GetCardinalDir() / 2;
shuttleComponent.LinearThrust[direction] -= component.Thrust; shuttleComponent.LinearThrust[direction] -= component.Thrust;
DebugTools.Assert(shuttleComponent.LinearThrusters[direction].Contains(uid)); DebugTools.Assert(shuttleComponent.LinearThrusters[direction].Contains(uid));
@@ -426,7 +427,7 @@ public sealed class ThrusterSystem : EntitySystem
var xform = Transform(uid); var xform = Transform(uid);
if (!xform.Anchored ||!this.IsPowered(uid, EntityManager)) if (!xform.Anchored || !this.IsPowered(uid, EntityManager))
{ {
return false; return false;
} }
@@ -443,7 +444,8 @@ public sealed class ThrusterSystem : EntitySystem
return true; return true;
var (x, y) = xform.LocalPosition + xform.LocalRotation.Opposite().ToWorldVec(); var (x, y) = xform.LocalPosition + xform.LocalRotation.Opposite().ToWorldVec();
var tile = Comp<MapGridComponent>(xform.GridUid.Value).GetTileRef(new Vector2i((int) Math.Floor(x), (int) Math.Floor(y))); var mapGrid = Comp<MapGridComponent>(xform.GridUid.Value);
var tile = _mapSystem.GetTileRef(xform.GridUid.Value, mapGrid, new Vector2i((int)Math.Floor(x), (int)Math.Floor(y)));
return tile.Tile.IsSpace(); return tile.Tile.IsSpace();
} }
@@ -582,6 +584,6 @@ public sealed class ThrusterSystem : EntitySystem
private int GetFlagIndex(DirectionFlag flag) private int GetFlagIndex(DirectionFlag flag)
{ {
return (int) Math.Log2((int) flag); return (int)Math.Log2((int)flag);
} }
} }