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:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,7 +44,7 @@ public sealed partial class DockingSystem
|
||||
Box2 shuttleAABB,
|
||||
Angle targetGridRotation,
|
||||
FixturesComponent shuttleFixtures,
|
||||
MapGridComponent grid,
|
||||
Entity<MapGridComponent> gridEntity,
|
||||
bool isMap,
|
||||
out Matrix3x2 matty,
|
||||
out Box2 shuttleDockedAABB,
|
||||
@@ -75,7 +75,7 @@ public sealed partial class DockingSystem
|
||||
var gridXformMatrix = Matrix3Helpers.CreateTransform(gridDockXform.LocalPosition, gridDockAngle);
|
||||
matty = Matrix3x2.Multiply(stationDockMatrix, gridXformMatrix);
|
||||
|
||||
if (!ValidSpawn(grid, matty, offsetAngle, shuttleFixtures, isMap))
|
||||
if (!ValidSpawn(gridEntity, matty, offsetAngle, shuttleFixtures, isMap))
|
||||
return false;
|
||||
|
||||
shuttleDockedAABB = matty.TransformBox(shuttleAABB);
|
||||
@@ -183,7 +183,7 @@ public sealed partial class DockingSystem
|
||||
shuttleAABB,
|
||||
targetGridAngle,
|
||||
shuttleFixturesComp,
|
||||
targetGridGrid,
|
||||
(targetGrid, targetGridGrid),
|
||||
isMap,
|
||||
out var matty,
|
||||
out var dockedAABB,
|
||||
@@ -194,7 +194,7 @@ public sealed partial class DockingSystem
|
||||
|
||||
// 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));
|
||||
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);
|
||||
@@ -235,7 +235,8 @@ public sealed partial class DockingSystem
|
||||
_xformQuery.GetComponent(otherGridUid),
|
||||
shuttleAABB,
|
||||
targetGridAngle,
|
||||
shuttleFixturesComp, targetGridGrid,
|
||||
shuttleFixturesComp,
|
||||
(targetGrid, targetGridGrid),
|
||||
isMap,
|
||||
out _,
|
||||
out var otherdockedAABB,
|
||||
@@ -303,7 +304,7 @@ public sealed partial class DockingSystem
|
||||
/// <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)
|
||||
private bool ValidSpawn(Entity<MapGridComponent> gridEntity, Matrix3x2 matty, Angle angle, FixturesComponent shuttleFixturesComp, bool isMap)
|
||||
{
|
||||
var transform = new Transform(Vector2.Transform(Vector2.Zero, matty), angle);
|
||||
|
||||
@@ -317,9 +318,9 @@ public sealed partial class DockingSystem
|
||||
// If it's a map check no hard collidable anchored entities overlap
|
||||
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))
|
||||
{
|
||||
@@ -337,7 +338,7 @@ public sealed partial class DockingSystem
|
||||
// If it's not a map check it doesn't overlap the grid.
|
||||
else
|
||||
{
|
||||
if (grid.GetLocalTilesIntersecting(aabb).Any())
|
||||
if (_mapSystem.GetLocalTilesIntersecting(gridEntity.Owner, gridEntity.Comp, aabb).Any())
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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!;
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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))
|
||||
{
|
||||
|
||||
@@ -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))
|
||||
|
||||
@@ -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!;
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
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
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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!;
|
||||
|
||||
@@ -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))
|
||||
{
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user