Add more centcomm spawning logs (#22726)

This commit is contained in:
Leon Friedrich
2023-12-18 20:35:31 -05:00
committed by GitHub
parent 59c1798835
commit ca90a2819f
5 changed files with 84 additions and 52 deletions

View File

@@ -455,9 +455,7 @@ namespace Content.Server.Atmos.EntitySystems
|| TerminatingOrDeleted(x.MapUid.Value) || TerminatingOrDeleted(x.MapUid.Value)
|| x.MapID == MapId.Nullspace) || x.MapID == MapId.Nullspace)
{ {
Log.Error($"Attempting to process atmos without a map? Entity: {ToPrettyString(owner)}"); Log.Error($"Attempted to process atmos without a map? Entity: {ToPrettyString(owner)}. Map: {ToPrettyString(x?.MapUid)}. MapId: {x?.MapID}");
_simulationPaused = false;
_currentRunAtmosphere.Clear();
continue; continue;
} }

View File

@@ -383,7 +383,7 @@ public sealed class NukeopsRuleSystem : GameRuleSystem<NukeopsRuleComponent>
continue; continue;
// UH OH // UH OH
if (centcomms.Contains(nukeTransform.MapID)) if (nukeTransform.MapUid != null && centcomms.Contains(nukeTransform.MapUid.Value))
{ {
component.WinConditions.Add(WinCondition.NukeActiveAtCentCom); component.WinConditions.Add(WinCondition.NukeActiveAtCentCom);
SetWinType(uid, WinType.OpsMajor, component); SetWinType(uid, WinType.OpsMajor, component);
@@ -447,8 +447,7 @@ public sealed class NukeopsRuleSystem : GameRuleSystem<NukeopsRuleComponent>
while (diskQuery.MoveNext(out _, out var transform)) while (diskQuery.MoveNext(out _, out var transform))
{ {
var diskMapId = transform.MapID; diskAtCentCom = transform.MapUid != null && centcomms.Contains(transform.MapUid.Value);
diskAtCentCom = centcomms.Contains(diskMapId);
// TODO: The target station should be stored, and the nuke disk should store its original station. // TODO: The target station should be stored, and the nuke disk should store its original station.
// This is fine for now, because we can assume a single station in base SS14. // This is fine for now, because we can assume a single station in base SS14.

View File

@@ -12,17 +12,18 @@ public sealed partial class StationCentcommComponent : Component
/// <summary> /// <summary>
/// Crude shuttle offset spawning. /// Crude shuttle offset spawning.
/// </summary> /// </summary>
[DataField("shuttleIndex")] [DataField]
public float ShuttleIndex; public float ShuttleIndex;
[DataField("map")] [DataField]
public ResPath Map = new("/Maps/centcomm.yml"); public ResPath Map = new("/Maps/centcomm.yml");
/// <summary> /// <summary>
/// Centcomm entity that was loaded. /// Centcomm entity that was loaded.
/// </summary> /// </summary>
[DataField("entity")] [DataField]
public EntityUid Entity = EntityUid.Invalid; public EntityUid? Entity;
public MapId MapId = MapId.Nullspace; [DataField]
public EntityUid? MapEntity;
} }

View File

@@ -166,19 +166,20 @@ public sealed partial class EmergencyShuttleSystem
continue; continue;
} }
if (Deleted(centcomm.Entity)) if (!Deleted(centcomm.Entity))
{
_shuttle.FTLTravel(comp.EmergencyShuttle.Value, shuttle,
centcomm.Entity.Value, _consoleAccumulator, TransitTime, true);
continue;
}
if (!Deleted(centcomm.MapEntity))
{ {
// TODO: Need to get non-overlapping positions. // TODO: Need to get non-overlapping positions.
_shuttle.FTLTravel(comp.EmergencyShuttle.Value, shuttle, _shuttle.FTLTravel(comp.EmergencyShuttle.Value, shuttle,
new EntityCoordinates( new EntityCoordinates(centcomm.MapEntity.Value,
_mapManager.GetMapEntityId(centcomm.MapId),
_random.NextVector2(1000f)), _consoleAccumulator, TransitTime); _random.NextVector2(1000f)), _consoleAccumulator, TransitTime);
} }
else
{
_shuttle.FTLTravel(comp.EmergencyShuttle.Value, shuttle,
centcomm.Entity, _consoleAccumulator, TransitTime, true);
}
} }
var podQuery = AllEntityQuery<EscapePodComponent>(); var podQuery = AllEntityQuery<EscapePodComponent>();
@@ -205,7 +206,7 @@ public sealed partial class EmergencyShuttleSystem
} }
// Don't dock them. If you do end up doing this then stagger launch. // Don't dock them. If you do end up doing this then stagger launch.
_shuttle.FTLTravel(uid, shuttle, centcomm.Entity, hyperspaceTime: TransitTime); _shuttle.FTLTravel(uid, shuttle, centcomm.Entity.Value, hyperspaceTime: TransitTime);
RemCompDeferred<EscapePodComponent>(uid); RemCompDeferred<EscapePodComponent>(uid);
} }
@@ -229,7 +230,7 @@ public sealed partial class EmergencyShuttleSystem
if (Deleted(comp.Entity)) if (Deleted(comp.Entity))
continue; continue;
_shuttle.AddFTLDestination(comp.Entity, true); _shuttle.AddFTLDestination(comp.Entity.Value, true);
} }
} }
} }

View File

@@ -20,8 +20,6 @@ using Content.Shared.Tag;
using Content.Shared.Tiles; using Content.Shared.Tiles;
using Robust.Server.GameObjects; using Robust.Server.GameObjects;
using Robust.Server.Maps; using Robust.Server.Maps;
using Robust.Server.Player;
using Robust.Shared.Audio;
using Robust.Shared.Audio.Systems; using Robust.Shared.Audio.Systems;
using Robust.Shared.Configuration; using Robust.Shared.Configuration;
using Robust.Shared.Map; using Robust.Shared.Map;
@@ -88,14 +86,16 @@ public sealed partial class EmergencyShuttleSystem : EntitySystem
} }
private void OnCentcommShutdown(EntityUid uid, StationCentcommComponent component, ComponentShutdown args) private void OnCentcommShutdown(EntityUid uid, StationCentcommComponent component, ComponentShutdown args)
{
ClearCentcomm(component);
}
private void ClearCentcomm(StationCentcommComponent component)
{ {
QueueDel(component.Entity); QueueDel(component.Entity);
component.Entity = EntityUid.Invalid; QueueDel(component.MapEntity);
component.Entity = null;
if (_mapManager.MapExists(component.MapId)) component.MapEntity = null;
_mapManager.DeleteMap(component.MapId);
component.MapId = MapId.Nullspace;
} }
private void SetEmergencyShuttleEnabled(bool value) private void SetEmergencyShuttleEnabled(bool value)
@@ -232,7 +232,7 @@ public sealed partial class EmergencyShuttleSystem : EntitySystem
// Post mapinit? fancy // Post mapinit? fancy
if (TryComp<TransformComponent>(component.Entity, out var xform)) if (TryComp<TransformComponent>(component.Entity, out var xform))
{ {
component.MapId = xform.MapID; component.MapEntity = xform.MapUid;
return; return;
} }
@@ -293,46 +293,78 @@ public sealed partial class EmergencyShuttleSystem : EntitySystem
private void AddCentcomm(StationCentcommComponent component) private void AddCentcomm(StationCentcommComponent component)
{ {
if (component.MapEntity != null || component.Entity != null)
{
_sawmill.Warning("Attempted to re-add an existing centcomm map.");
return;
}
// Check for existing centcomms and just point to that // Check for existing centcomms and just point to that
var query = AllEntityQuery<StationCentcommComponent>(); var query = AllEntityQuery<StationCentcommComponent>();
while (query.MoveNext(out var otherComp)) while (query.MoveNext(out var otherComp))
{ {
if (otherComp == component) if (otherComp == component)
continue; continue;
component.MapId = otherComp.MapId; if (!Exists(otherComp.MapEntity) || !Exists(otherComp.Entity))
{
Log.Error($"Disconvered invalid centcomm component?");
ClearCentcomm(otherComp);
continue;
}
component.MapEntity = otherComp.MapEntity;
component.ShuttleIndex = otherComp.ShuttleIndex; component.ShuttleIndex = otherComp.ShuttleIndex;
return; return;
} }
var mapId = _mapManager.CreateMap(); if (string.IsNullOrEmpty(component.Map.ToString()))
component.MapId = mapId;
if (!string.IsNullOrEmpty(component.Map.ToString()))
{
var ent = _map.LoadGrid(mapId, component.Map.ToString());
if (ent != null)
{
component.Entity = ent.Value;
_shuttle.AddFTLDestination(ent.Value, false);
}
}
else
{ {
_sawmill.Warning("No CentComm map found, skipping setup."); _sawmill.Warning("No CentComm map found, skipping setup.");
return;
} }
var mapId = _mapManager.CreateMap();
var grid = _map.LoadGrid(mapId, component.Map.ToString());
var map = _mapManager.GetMapEntityId(mapId);
if (!Exists(map))
{
Log.Error($"Failed to set up centcomm map!");
QueueDel(grid);
return;
}
if (!Exists(grid))
{
Log.Error($"Failed to set up centcomm grid!");
QueueDel(map);
return;
}
var xform = Transform(grid.Value);
if (xform.ParentUid != map || xform.MapUid != map)
{
Log.Error($"Centcomm grid is not parented to its own map?");
QueueDel(map);
QueueDel(grid);
return;
}
component.MapEntity = map;
component.Entity = grid;
_shuttle.AddFTLDestination(grid.Value, false);
} }
public HashSet<MapId> GetCentcommMaps() public HashSet<EntityUid> GetCentcommMaps()
{ {
var query = AllEntityQuery<StationCentcommComponent>(); var query = AllEntityQuery<StationCentcommComponent>();
var maps = new HashSet<MapId>(Count<StationCentcommComponent>()); var maps = new HashSet<EntityUid>(Count<StationCentcommComponent>());
while (query.MoveNext(out var comp)) while (query.MoveNext(out var comp))
{ {
maps.Add(comp.MapId); if (comp.MapEntity != null)
maps.Add(comp.MapEntity.Value);
} }
return maps; return maps;
@@ -342,14 +374,15 @@ public sealed partial class EmergencyShuttleSystem : EntitySystem
{ {
if (!_emergencyShuttleEnabled if (!_emergencyShuttleEnabled
|| component.EmergencyShuttle != null || || component.EmergencyShuttle != null ||
!TryComp<StationCentcommComponent>(uid, out var centcomm)) !TryComp<StationCentcommComponent>(uid, out var centcomm)
|| !TryComp(centcomm.MapEntity, out MapComponent? map))
{ {
return; return;
} }
// Load escape shuttle // Load escape shuttle
var shuttlePath = component.EmergencyShuttlePath; var shuttlePath = component.EmergencyShuttlePath;
var shuttle = _map.LoadGrid(centcomm.MapId, shuttlePath.ToString(), new MapLoadOptions() var shuttle = _map.LoadGrid(map.MapId, shuttlePath.ToString(), new MapLoadOptions()
{ {
// Should be far enough... right? I'm too lazy to bounds check CentCom rn. // Should be far enough... right? I'm too lazy to bounds check CentCom rn.
Offset = new Vector2(500f + centcomm.ShuttleIndex, 0f) Offset = new Vector2(500f + centcomm.ShuttleIndex, 0f)
@@ -368,7 +401,7 @@ public sealed partial class EmergencyShuttleSystem : EntitySystem
while (query.MoveNext(out var comp)) while (query.MoveNext(out var comp))
{ {
if (comp == centcomm || comp.MapId != centcomm.MapId) if (comp == centcomm || comp.MapEntity != centcomm.MapEntity)
continue; continue;
comp.ShuttleIndex = centcomm.ShuttleIndex; comp.ShuttleIndex = centcomm.ShuttleIndex;