Adds the Central Command outpost for Roundend and ERT to spawn at. (#9146)
* Adds Reach II * Updated Reach II to work after refactor * removing old map * Adding the Central Command outpost * Reachii isn't meant to be in here at all. * updated possible error in .yml * updating .yml * Updated CentComm, fixed some issues like lighting. * Imagine if we also docked at centcomm * a Co-authored-by: metalgearsloth <comedian_vs_clown@hotmail.com>
This commit is contained in:
committed by
GitHub
parent
5e316afe86
commit
6325a10a43
@@ -38,6 +38,7 @@ public sealed partial class ShuttleSystem
|
||||
[Dependency] private readonly StationSystem _station = default!;
|
||||
|
||||
private MapId? _centcommMap;
|
||||
private EntityUid? _centcomm;
|
||||
|
||||
/// <summary>
|
||||
/// Used for multiple shuttle spawn offsets.
|
||||
@@ -91,18 +92,19 @@ public sealed partial class ShuttleSystem
|
||||
var player = args.SenderSession.AttachedEntity;
|
||||
|
||||
if (player == null ||
|
||||
!TryComp<StationDataComponent>(_station.GetOwningStation(player.Value), out var stationData)) return;
|
||||
!TryComp<StationDataComponent>(_station.GetOwningStation(player.Value), out var stationData) ||
|
||||
!TryComp<ShuttleComponent>(stationData.EmergencyShuttle, out var shuttle)) return;
|
||||
|
||||
var config = GetDockingConfig(stationData);
|
||||
var targetGrid = GetLargestGrid(stationData);
|
||||
if (targetGrid == null) return;
|
||||
var config = GetDockingConfig(shuttle, targetGrid.Value);
|
||||
if (config == null) return;
|
||||
|
||||
if (config != null)
|
||||
RaiseNetworkEvent(new EmergencyShuttlePositionMessage()
|
||||
{
|
||||
RaiseNetworkEvent(new EmergencyShuttlePositionMessage()
|
||||
{
|
||||
StationUid = config.TargetGrid,
|
||||
Position = config.Area,
|
||||
});
|
||||
}
|
||||
StationUid = targetGrid,
|
||||
Position = config.Area,
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -113,38 +115,23 @@ public sealed partial class ShuttleSystem
|
||||
return !grid.Grid.GetLocalTilesIntersecting(area).Any();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Tries to find the most valid docking config for the station.
|
||||
/// </summary>
|
||||
private DockingConfig? GetDockingConfig(StationDataComponent dataComponent)
|
||||
private DockingConfig? GetDockingConfig(ShuttleComponent component, EntityUid targetGrid)
|
||||
{
|
||||
// Find the largest grid associated with the station, then try all combinations of docks on it with
|
||||
// all of them on the shuttle and try to find the most appropriate.
|
||||
if (dataComponent.EmergencyShuttle == null) return null;
|
||||
|
||||
var targetGrid = GetLargestGrid(dataComponent);
|
||||
|
||||
if (targetGrid == null) return null;
|
||||
var gridDocks = GetDocks(targetGrid.Value);
|
||||
var gridDocks = GetDocks(targetGrid);
|
||||
|
||||
if (gridDocks.Count <= 0) return null;
|
||||
|
||||
var xformQuery = GetEntityQuery<TransformComponent>();
|
||||
var targetGridGrid = Comp<IMapGridComponent>(targetGrid.Value);
|
||||
var targetGridXform = xformQuery.GetComponent(targetGrid.Value);
|
||||
var targetGridMatrix = targetGridXform.WorldMatrix;
|
||||
var targetGridGrid = Comp<IMapGridComponent>(targetGrid);
|
||||
var targetGridXform = xformQuery.GetComponent(targetGrid);
|
||||
var targetGridAngle = targetGridXform.WorldRotation.Reduced();
|
||||
var targetGridRotation = targetGridAngle.ToVec();
|
||||
|
||||
var shuttleDocks = GetDocks(dataComponent.EmergencyShuttle.Value);
|
||||
var shuttleAABB = Comp<IMapGridComponent>(dataComponent.EmergencyShuttle.Value).Grid.LocalAABB;
|
||||
var shuttleDocks = GetDocks(component.Owner);
|
||||
var shuttleAABB = Comp<IMapGridComponent>(component.Owner).Grid.LocalAABB;
|
||||
|
||||
var validDockConfigs = new List<DockingConfig>();
|
||||
|
||||
if (TryComp<ShuttleComponent>(dataComponent.EmergencyShuttle, out var shuttle))
|
||||
{
|
||||
SetPilotable(shuttle, false);
|
||||
}
|
||||
SetPilotable(component, false);
|
||||
|
||||
if (shuttleDocks.Count > 0)
|
||||
{
|
||||
@@ -168,7 +155,7 @@ public sealed partial class ShuttleSystem
|
||||
out var targetAngle)) continue;
|
||||
|
||||
// Can't just use the AABB as we want to get bounds as tight as possible.
|
||||
var spawnPosition = new EntityCoordinates(targetGrid.Value, matty.Transform(Vector2.Zero));
|
||||
var spawnPosition = new EntityCoordinates(targetGrid, matty.Transform(Vector2.Zero));
|
||||
spawnPosition = new EntityCoordinates(targetGridXform.MapUid!.Value, spawnPosition.ToMapPos(EntityManager));
|
||||
|
||||
var dockedBounds = new Box2Rotated(shuttleAABB.Translated(spawnPosition.Position), targetGridAngle, spawnPosition.Position);
|
||||
@@ -240,7 +227,7 @@ public sealed partial class ShuttleSystem
|
||||
.ThenBy(x => Math.Abs(Angle.ShortestDistance(x.Angle.Reduced(), targetGridAngle).Theta)).ToList();
|
||||
|
||||
var location = validDockConfigs.First();
|
||||
location.TargetGrid = targetGrid.Value;
|
||||
location.TargetGrid = targetGrid;
|
||||
// TODO: Ideally do a hyperspace warpin, just have it run on like a 10 second timer.
|
||||
|
||||
return location;
|
||||
@@ -249,72 +236,33 @@ public sealed partial class ShuttleSystem
|
||||
/// <summary>
|
||||
/// Calls the emergency shuttle for the station.
|
||||
/// </summary>
|
||||
/// <param name="stationUid"></param>
|
||||
/// <param name="dryRun">Should we show the debug data and not actually call it.</param>
|
||||
public void CallEmergencyShuttle(EntityUid? stationUid)
|
||||
{
|
||||
if (!TryComp<StationDataComponent>(stationUid, out var stationData) ||
|
||||
!TryComp<TransformComponent>(stationData.EmergencyShuttle, out var xform)) return;
|
||||
!TryComp<TransformComponent>(stationData.EmergencyShuttle, out var xform) ||
|
||||
!TryComp<ShuttleComponent>(stationData.EmergencyShuttle, out var shuttle)) return;
|
||||
|
||||
var config = GetDockingConfig(stationData);
|
||||
var targetGrid = GetLargestGrid(stationData);
|
||||
|
||||
if (config != null)
|
||||
// UHH GOOD LUCK
|
||||
if (targetGrid == null)
|
||||
{
|
||||
// Set position
|
||||
xform.Coordinates = config.Coordinates;
|
||||
xform.WorldRotation = config.Angle;
|
||||
|
||||
// Connect everything
|
||||
foreach (var (dockA, dockB) in config.Docks)
|
||||
{
|
||||
_dockSystem.Dock(dockA, dockB);
|
||||
}
|
||||
_logger.Add(LogType.EmergencyShuttle, LogImpact.High, $"Emergency shuttle {ToPrettyString(stationUid.Value)} unable to dock with station {ToPrettyString(stationUid.Value)}");
|
||||
_chatSystem.DispatchStationAnnouncement(stationUid.Value, Loc.GetString("emergency-shuttle-good-luck"), playDefaultSound: false);
|
||||
// TODO: Need filter extensions or something don't blame me.
|
||||
SoundSystem.Play("/Audio/Misc/notice1.ogg", Filter.Broadcast());
|
||||
return;
|
||||
}
|
||||
|
||||
if (TryHyperspaceDock(shuttle, targetGrid.Value))
|
||||
{
|
||||
_logger.Add(LogType.EmergencyShuttle, LogImpact.High, $"Emergency shuttle {ToPrettyString(stationUid.Value)} docked with stations");
|
||||
_chatSystem.DispatchStationAnnouncement(stationUid.Value, Loc.GetString("emergency-shuttle-docked", ("time", $"{_consoleAccumulator:0}")), playDefaultSound: false);
|
||||
// TODO: Need filter extensions or something don't blame me.
|
||||
SoundSystem.Play("/Audio/Announcements/shuttle_dock.ogg", Filter.Broadcast());
|
||||
|
||||
// Bolt all the airlocks so they don't stuff around with them.
|
||||
SetDockBolts(stationData.EmergencyShuttle.Value, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
var shuttleAABB = Comp<IMapGridComponent>(stationData.EmergencyShuttle.Value).Grid.WorldAABB;
|
||||
Box2? aabb = null;
|
||||
|
||||
// Spawn nearby.
|
||||
foreach (var gridUid in stationData.Grids)
|
||||
{
|
||||
var grid = Comp<IMapGridComponent>(gridUid).Grid;
|
||||
var gridAABB = grid.WorldAABB;
|
||||
aabb = aabb?.Union(gridAABB) ?? gridAABB;
|
||||
}
|
||||
|
||||
// UHH GOOD LUCK
|
||||
if (aabb == null)
|
||||
{
|
||||
_logger.Add(LogType.EmergencyShuttle, LogImpact.High, $"Emergency shuttle {ToPrettyString(stationUid.Value)} unable to dock with station {ToPrettyString(stationUid.Value)}");
|
||||
_chatSystem.DispatchStationAnnouncement(stationUid.Value, Loc.GetString("emergency-shuttle-good-luck"), playDefaultSound: false);
|
||||
// TODO: Need filter extensions or something don't blame me.
|
||||
SoundSystem.Play("/Audio/Misc/notice1.ogg", Filter.Broadcast());
|
||||
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
var minRadius = MathF.Max(aabb.Value.Width, aabb.Value.Height) + MathF.Max(shuttleAABB.Width, shuttleAABB.Height);
|
||||
var spawnPos = aabb.Value.Center + _random.NextVector2(minRadius, minRadius + 10f);
|
||||
|
||||
if (TryComp<PhysicsComponent>(stationData.EmergencyShuttle, out var shuttleBody))
|
||||
{
|
||||
shuttleBody.LinearVelocity = Vector2.Zero;
|
||||
shuttleBody.AngularVelocity = 0f;
|
||||
}
|
||||
|
||||
xform.WorldPosition = spawnPos;
|
||||
xform.WorldRotation = _random.NextAngle();
|
||||
|
||||
_logger.Add(LogType.EmergencyShuttle, LogImpact.High, $"Emergency shuttle {ToPrettyString(stationUid.Value)} unable to find a valid docking port for {ToPrettyString(stationUid.Value)}");
|
||||
_chatSystem.DispatchStationAnnouncement(stationUid.Value, Loc.GetString("emergency-shuttle-nearby"), playDefaultSound: false);
|
||||
// TODO: Need filter extensions or something don't blame me.
|
||||
@@ -443,9 +391,18 @@ public sealed partial class ShuttleSystem
|
||||
_centcommMap = _mapManager.CreateMap();
|
||||
_mapManager.SetMapPaused(_centcommMap.Value, true);
|
||||
|
||||
// Load Centcomm, when we get it!
|
||||
// var (_, centcomm) = _loader.LoadBlueprint(_centcommMap.Value, "/Maps/Salvage/saltern.yml", new MapLoadOptions());
|
||||
// _centcomm = centcomm;
|
||||
// Load Centcomm
|
||||
var centcommPath = _configManager.GetCVar(CCVars.CentcommMap);
|
||||
|
||||
if (!string.IsNullOrEmpty(centcommPath))
|
||||
{
|
||||
var (_, centcomm) = _loader.LoadBlueprint(_centcommMap.Value, "/Maps/centcomm.yml");
|
||||
_centcomm = centcomm;
|
||||
}
|
||||
else
|
||||
{
|
||||
_sawmill.Info("No centcomm map found, skipping setup.");
|
||||
}
|
||||
|
||||
foreach (var comp in EntityQuery<StationDataComponent>(true))
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user