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 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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ public sealed partial class DockingSystem
|
|||||||
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,
|
||||||
@@ -75,7 +75,7 @@ public sealed partial class DockingSystem
|
|||||||
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);
|
||||||
@@ -183,7 +183,7 @@ public sealed partial class DockingSystem
|
|||||||
shuttleAABB,
|
shuttleAABB,
|
||||||
targetGridAngle,
|
targetGridAngle,
|
||||||
shuttleFixturesComp,
|
shuttleFixturesComp,
|
||||||
targetGridGrid,
|
(targetGrid, targetGridGrid),
|
||||||
isMap,
|
isMap,
|
||||||
out var matty,
|
out var matty,
|
||||||
out var dockedAABB,
|
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.
|
// 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);
|
||||||
@@ -235,7 +235,8 @@ public sealed partial class DockingSystem
|
|||||||
_xformQuery.GetComponent(otherGridUid),
|
_xformQuery.GetComponent(otherGridUid),
|
||||||
shuttleAABB,
|
shuttleAABB,
|
||||||
targetGridAngle,
|
targetGridAngle,
|
||||||
shuttleFixturesComp, targetGridGrid,
|
shuttleFixturesComp,
|
||||||
|
(targetGrid, targetGridGrid),
|
||||||
isMap,
|
isMap,
|
||||||
out _,
|
out _,
|
||||||
out var otherdockedAABB,
|
out var otherdockedAABB,
|
||||||
@@ -303,23 +304,23 @@ public sealed partial class DockingSystem
|
|||||||
/// <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))
|
||||||
{
|
{
|
||||||
@@ -337,7 +338,7 @@ public sealed partial class DockingSystem
|
|||||||
// 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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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;
|
||||||
|
|||||||
@@ -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.
|
||||||
|
|||||||
@@ -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))
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -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))
|
||||||
|
|||||||
@@ -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;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
@@ -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);
|
||||||
|
|
||||||
|
|||||||
@@ -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);
|
||||||
|
|||||||
@@ -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!;
|
||||||
|
|||||||
@@ -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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user