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 IConsoleHost _console = default!;
[Dependency] private readonly IGameTiming _timing = default!;
[Dependency] private readonly IMapManager _mapManager = default!;
[Dependency] private readonly IPrototypeManager _protoManager = default!;
[Dependency] private readonly IRobustRandom _random = default!;
[Dependency] private readonly IChatManager _chat = default!;
[Dependency] private readonly SharedMapSystem _mapSystem = default!;
[Dependency] private readonly BiomeSystem _biomes = default!;
[Dependency] private readonly GameTicker _ticker = default!;
[Dependency] private readonly MapLoaderSystem _loader = default!;
@@ -496,9 +496,7 @@ public sealed class ArrivalsSystem : EntitySystem
private void SetupArrivalsStation()
{
var mapId = _mapManager.CreateMap();
var mapUid = _mapManager.GetMapEntityId(mapId);
_mapManager.AddUninitializedMap(mapId);
var mapUid = _mapSystem.CreateMap(out var mapId, false);
if (!_loader.TryLoad(mapId, _cfgManager.GetCVar(CCVars.ArrivalsMap), out var uids))
{
@@ -524,7 +522,7 @@ public sealed class ArrivalsSystem : EntitySystem
AddComp(mapUid, restricted);
}
_mapManager.DoMapInitialize(mapId);
_mapSystem.InitializeMap(mapId);
// Handle roundstart stations.
var query = AllEntityQuery<StationArrivalsComponent>();
@@ -582,10 +580,10 @@ public sealed class ArrivalsSystem : EntitySystem
return;
// 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) &&
_loader.TryLoad(dummyMap, component.ShuttlePath.ToString(), out var shuttleUids))
_loader.TryLoad(dummyMapId, component.ShuttlePath.ToString(), out var shuttleUids))
{
component.Shuttle = shuttleUids[0];
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?
var timer = AddComp<TimedDespawnComponent>(_mapManager.GetMapEntityId(dummyMap));
var timer = AddComp<TimedDespawnComponent>(dummpMapEntity);
timer.Lifetime = 15f;
}
}

View File

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

View File

@@ -220,7 +220,7 @@ public sealed partial class EmergencyShuttleSystem
ShuttlesLeft = true;
_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.

View File

@@ -50,8 +50,8 @@ public sealed partial class EmergencyShuttleSystem : EntitySystem
[Dependency] private readonly IAdminManager _admin = default!;
[Dependency] private readonly IConfigurationManager _configManager = default!;
[Dependency] private readonly IGameTiming _timing = default!;
[Dependency] private readonly IMapManager _mapManager = default!;
[Dependency] private readonly IRobustRandom _random = default!;
[Dependency] private readonly SharedMapSystem _mapSystem = default!;
[Dependency] private readonly AccessReaderSystem _reader = default!;
[Dependency] private readonly ChatSystem _chatSystem = default!;
[Dependency] private readonly CommunicationsConsoleSystem _commsConsole = default!;
@@ -212,7 +212,7 @@ public sealed partial class EmergencyShuttleSystem : EntitySystem
{
[ShuttleTimerMasks.ShuttleMap] = uid,
[ShuttleTimerMasks.SourceMap] = args.FromMapUid,
[ShuttleTimerMasks.DestMap] = args.TargetCoordinates.GetMapUid(_entityManager),
[ShuttleTimerMasks.DestMap] = _transformSystem.GetMap(args.TargetCoordinates),
[ShuttleTimerMasks.ShuttleTime] = ftlTime,
[ShuttleTimerMasks.SourceTime] = 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 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);
}
@@ -320,7 +320,7 @@ public sealed partial class EmergencyShuttleSystem : EntitySystem
{
var angle = _dock.GetAngle(stationShuttle.EmergencyShuttle.Value, xform, targetGrid.Value, targetXform, xformQuery);
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);
}
@@ -401,7 +401,7 @@ public sealed partial class EmergencyShuttleSystem : EntitySystem
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)
{
Log.Warning("Attempted to re-add an existing centcomm map.");
@@ -434,12 +434,11 @@ public sealed partial class EmergencyShuttleSystem : EntitySystem
return;
}
var mapId = _mapManager.CreateMap();
var map = _mapSystem.CreateMap(out var mapId);
var grid = _map.LoadGrid(mapId, component.Map.ToString(), new MapLoadOptions()
{
LoadMap = false,
});
var map = _mapManager.GetMapEntityId(mapId);
if (!Exists(map))
{
@@ -492,7 +491,7 @@ public sealed partial class EmergencyShuttleSystem : EntitySystem
if (!_emergencyShuttleEnabled)
return;
if (ent.Comp1.EmergencyShuttle != null )
if (ent.Comp1.EmergencyShuttle != null)
{
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)
{
var mapUid = _mapManager.GetMapEntityId(args.Coordinates.MapId);
var mapUid = _mapSystem.GetMap(args.Coordinates.MapId);
// If it's beacons only block all position messages.
if (!Exists(mapUid) || _shuttle.IsBeaconMap(mapUid))

View File

@@ -26,7 +26,7 @@ namespace Content.Server.Shuttles.Systems;
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 AlertsSystem _alertsSystem = default!;
[Dependency] private readonly EntityLookupSystem _lookup = default!;
@@ -129,7 +129,7 @@ public sealed partial class ShuttleConsoleSystem : SharedShuttleConsoleSystem
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>
private void OnConsoleUIClose(EntityUid uid, ShuttleConsoleComponent component, BoundUIClosedEvent args)
{
if ((ShuttleConsoleUiKey) args.UiKey != ShuttleConsoleUiKey.Key)
if ((ShuttleConsoleUiKey)args.UiKey != ShuttleConsoleUiKey.Key)
{
return;
}

View File

@@ -134,13 +134,12 @@ public sealed partial class ShuttleSystem
return uid;
}
var mapId = _mapManager.CreateMap();
var mapUid = _mapManager.GetMapEntityId(mapId);
var mapUid = _mapSystem.CreateMap(out var mapId);
var ftlMap = AddComp<FTLMapComponent>(mapUid);
_metadata.SetEntityName(mapUid, "FTL");
Log.Debug($"Setup hyperspace map at {mapUid}");
DebugTools.Assert(!_mapManager.IsMapPaused(mapId));
DebugTools.Assert(!_mapSystem.IsPaused(mapId));
var parallax = EnsureComp<ParallaxComponent>(mapUid);
parallax.Parallax = ftlMap.Parallax;
@@ -188,7 +187,7 @@ public sealed partial class ShuttleSystem
/// </summary>
public bool TryAddFTLDestination(MapId mapId, bool enabled, [NotNullWhen(true)] out FTLDestinationComponent? component)
{
var mapUid = _mapManager.GetMapEntityId(mapId);
var mapUid = _mapSystem.GetMapOrInvalid(mapId);
component = null;
if (!Exists(mapUid))
@@ -281,8 +280,8 @@ public sealed partial class ShuttleSystem
_console.RefreshShuttleConsoles(shuttleUid);
var mapId = coordinates.GetMapId(EntityManager);
var mapUid = _mapManager.GetMapEntityId(mapId);
var mapId = _transform.GetMapId(coordinates);
var mapUid = _mapSystem.GetMap(mapId);
var ev = new FTLRequestEvent(mapUid);
RaiseLocalEvent(shuttleUid, ref ev, true);
}
@@ -388,7 +387,7 @@ public sealed partial class ShuttleSystem
if (fromMapUid != null && TryComp(comp.StartupStream, out AudioComponent? startupAudio))
{
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);
clippedAudio.Value.Component.Flags |= AudioFlags.NoOcclusion;
@@ -477,7 +476,7 @@ public sealed partial class ShuttleSystem
var map = maps.Min(o => o.GetHashCode());
mapId = new MapId(map);
TryFTLProximity(uid, _mapManager.GetMapEntityId(mapId));
TryFTLProximity(uid, _mapSystem.GetMap(mapId));
}
// Docking FTL
else if (HasComp<MapGridComponent>(target.EntityId) &&
@@ -502,7 +501,7 @@ public sealed partial class ShuttleSystem
else
{
// TODO: This should now use tryftlproximity
mapId = target.GetMapId(EntityManager);
mapId = _transform.GetMapId(target);
_transform.SetCoordinates(uid, xform, target, rotation: entity.Comp1.TargetAngle);
}
@@ -540,7 +539,7 @@ public sealed partial class ShuttleSystem
_mapManager.SetMapPaused(mapId, false);
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);
}
@@ -616,7 +615,7 @@ public sealed partial class ShuttleSystem
// If the guy we knocked down is on a spaced tile, throw them too
if (grid != null)
TossIfSpaced(grid, shuttleBody, child);
TossIfSpaced((xform.GridUid.Value, grid, shuttleBody), child);
}
}
}
@@ -637,13 +636,15 @@ public sealed partial class ShuttleSystem
/// <summary>
/// Throws people who are standing on a spaced tile, tries to throw them towards a neighbouring space tile
/// </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;
// 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))
return;
@@ -689,7 +690,7 @@ public sealed partial class ShuttleSystem
{
// Set position
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);
// Connect everything

View File

@@ -110,7 +110,7 @@ public sealed partial class ShuttleSystem
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);

View File

@@ -39,8 +39,8 @@ public sealed partial class ShuttleSystem
var otherXform = Transform(args.OtherEntity);
var ourPoint = Vector2.Transform(args.WorldPoint, ourXform.InvWorldMatrix);
var otherPoint = Vector2.Transform(args.WorldPoint, otherXform.InvWorldMatrix);
var ourPoint = Vector2.Transform(args.WorldPoint, _transform.GetInvWorldMatrix(ourXform));
var otherPoint = Vector2.Transform(args.WorldPoint, _transform.GetInvWorldMatrix(otherXform));
var ourVelocity = _physics.GetLinearVelocity(uid, ourPoint, ourBody, ourXform);
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 PvsOverrideSystem _pvs = default!;
[Dependency] private readonly SharedAudioSystem _audio = default!;
[Dependency] private readonly SharedMapSystem _maps = default!;
[Dependency] private readonly SharedPhysicsSystem _physics = default!;
[Dependency] private readonly SharedTransformSystem _transform = 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 ITileDefinitionManager _tileDefManager = default!;
[Dependency] private readonly SharedMapSystem _mapSystem = default!;
[Dependency] private readonly AmbientSoundSystem _ambient = default!;
[Dependency] private readonly FixtureSystem _fixtureSystem = default!;
[Dependency] private readonly DamageableSystem _damageable = default!;
@@ -109,7 +110,7 @@ public sealed class ThrusterSystem : EntitySystem
continue;
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))
{
@@ -120,7 +121,7 @@ public sealed class ThrusterSystem : EntitySystem
var xform = xformQuery.GetComponent(ent.Value);
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;
DisableThruster(ent.Value, thruster, xform.GridUid);
@@ -183,8 +184,8 @@ public sealed class ThrusterSystem : EntitySystem
return;
}
var oldDirection = (int) args.OldRotation.GetCardinalDir() / 2;
var direction = (int) args.NewRotation.GetCardinalDir() / 2;
var oldDirection = (int)args.OldRotation.GetCardinalDir() / 2;
var direction = (int)args.NewRotation.GetCardinalDir() / 2;
var oldShuttleComponent = shuttleComponent;
if (args.ParentChanged)
@@ -282,7 +283,7 @@ public sealed class ThrusterSystem : EntitySystem
switch (component.Type)
{
case ThrusterType.Linear:
var direction = (int) xform.LocalRotation.GetCardinalDir() / 2;
var direction = (int)xform.LocalRotation.GetCardinalDir() / 2;
shuttleComponent.LinearThrust[direction] += component.Thrust;
DebugTools.Assert(!shuttleComponent.LinearThrusters[direction].Contains(uid));
@@ -294,7 +295,7 @@ public sealed class ThrusterSystem : EntitySystem
{
var shape = new PolygonShape();
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;
@@ -334,7 +335,7 @@ public sealed class ThrusterSystem : EntitySystem
foreach (var dir in new[]
{ Direction.South, Direction.East, Direction.North, Direction.West })
{
var index = (int) dir / 2;
var index = (int)dir / 2;
var pop = shuttle.LinearThrusters[index];
var totalThrust = 0f;
@@ -380,7 +381,7 @@ public sealed class ThrusterSystem : EntitySystem
{
case ThrusterType.Linear:
angle ??= xform.LocalRotation;
var direction = (int) angle.Value.GetCardinalDir() / 2;
var direction = (int)angle.Value.GetCardinalDir() / 2;
shuttleComponent.LinearThrust[direction] -= component.Thrust;
DebugTools.Assert(shuttleComponent.LinearThrusters[direction].Contains(uid));
@@ -426,7 +427,7 @@ public sealed class ThrusterSystem : EntitySystem
var xform = Transform(uid);
if (!xform.Anchored ||!this.IsPowered(uid, EntityManager))
if (!xform.Anchored || !this.IsPowered(uid, EntityManager))
{
return false;
}
@@ -443,7 +444,8 @@ public sealed class ThrusterSystem : EntitySystem
return true;
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();
}
@@ -582,6 +584,6 @@ public sealed class ThrusterSystem : EntitySystem
private int GetFlagIndex(DirectionFlag flag)
{
return (int) Math.Log2((int) flag);
return (int)Math.Log2((int)flag);
}
}