Fix Centcomm (#16772)
This commit is contained in:
@@ -154,39 +154,39 @@ public sealed partial class EmergencyShuttleSystem
|
||||
{
|
||||
_launchedShuttles = true;
|
||||
|
||||
if (CentComMap != null)
|
||||
var dataQuery = AllEntityQuery<StationEmergencyShuttleComponent>();
|
||||
|
||||
while (dataQuery.MoveNext(out var stationUid, out var comp))
|
||||
{
|
||||
var dataQuery = AllEntityQuery<StationEmergencyShuttleComponent>();
|
||||
|
||||
while (dataQuery.MoveNext(out var comp))
|
||||
if (!TryComp<ShuttleComponent>(comp.EmergencyShuttle, out var shuttle) ||
|
||||
!TryComp<StationCentcommComponent>(stationUid, out var centcomm))
|
||||
{
|
||||
if (!TryComp<ShuttleComponent>(comp.EmergencyShuttle, out var shuttle))
|
||||
continue;
|
||||
|
||||
if (Deleted(CentComGrid))
|
||||
{
|
||||
// TODO: Need to get non-overlapping positions.
|
||||
_shuttle.FTLTravel(comp.EmergencyShuttle.Value, shuttle,
|
||||
new EntityCoordinates(
|
||||
_mapManager.GetMapEntityId(CentComMap.Value),
|
||||
_random.NextVector2(1000f)), _consoleAccumulator, TransitTime);
|
||||
}
|
||||
else
|
||||
{
|
||||
_shuttle.FTLTravel(comp.EmergencyShuttle.Value, shuttle,
|
||||
CentComGrid.Value, _consoleAccumulator, TransitTime, true);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
var podQuery = AllEntityQuery<EscapePodComponent>();
|
||||
var podLaunchOffset = 0.5f;
|
||||
|
||||
// Stagger launches coz funny
|
||||
while (podQuery.MoveNext(out _, out var pod))
|
||||
if (Deleted(centcomm.Entity))
|
||||
{
|
||||
pod.LaunchTime = _timing.CurTime + TimeSpan.FromSeconds(podLaunchOffset);
|
||||
podLaunchOffset += _random.NextFloat(0.5f, 2.5f);
|
||||
// TODO: Need to get non-overlapping positions.
|
||||
_shuttle.FTLTravel(comp.EmergencyShuttle.Value, shuttle,
|
||||
new EntityCoordinates(
|
||||
_mapManager.GetMapEntityId(centcomm.MapId),
|
||||
_random.NextVector2(1000f)), _consoleAccumulator, TransitTime);
|
||||
}
|
||||
else
|
||||
{
|
||||
_shuttle.FTLTravel(comp.EmergencyShuttle.Value, shuttle,
|
||||
centcomm.Entity, _consoleAccumulator, TransitTime, true);
|
||||
}
|
||||
}
|
||||
|
||||
var podQuery = AllEntityQuery<EscapePodComponent>();
|
||||
var podLaunchOffset = 0.5f;
|
||||
|
||||
// Stagger launches coz funny
|
||||
while (podQuery.MoveNext(out _, out var pod))
|
||||
{
|
||||
pod.LaunchTime = _timing.CurTime + TimeSpan.FromSeconds(podLaunchOffset);
|
||||
podLaunchOffset += _random.NextFloat(0.5f, 2.5f);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -194,13 +194,16 @@ public sealed partial class EmergencyShuttleSystem
|
||||
|
||||
while (podLaunchQuery.MoveNext(out var uid, out var pod, out var shuttle))
|
||||
{
|
||||
if (CentComGrid == null || pod.LaunchTime == null || pod.LaunchTime < _timing.CurTime)
|
||||
var stationUid = _station.GetOwningStation(uid);
|
||||
|
||||
if (!TryComp<StationCentcommComponent>(stationUid, out var centcomm) ||
|
||||
Deleted(centcomm.Entity) || pod.LaunchTime == null || pod.LaunchTime < _timing.CurTime)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
// Don't dock them. If you do end up doing this then stagger launch.
|
||||
_shuttle.FTLTravel(uid, shuttle,
|
||||
CentComGrid.Value, hyperspaceTime: TransitTime);
|
||||
|
||||
_shuttle.FTLTravel(uid, shuttle, centcomm.Entity, hyperspaceTime: TransitTime);
|
||||
RemCompDeferred<EscapePodComponent>(uid);
|
||||
}
|
||||
|
||||
@@ -210,16 +213,22 @@ public sealed partial class EmergencyShuttleSystem
|
||||
_leftShuttles = true;
|
||||
_chatSystem.DispatchGlobalAnnouncement(Loc.GetString("emergency-shuttle-left", ("transitTime", $"{TransitTime:0}")));
|
||||
|
||||
_roundEndCancelToken = new CancellationTokenSource();
|
||||
Timer.Spawn((int) (TransitTime * 1000) + _bufferTime.Milliseconds, () => _roundEnd.EndRound(), _roundEndCancelToken.Token);
|
||||
Timer.Spawn((int) (TransitTime * 1000) + _bufferTime.Milliseconds, () => _roundEnd.EndRound(), _roundEndCancelToken?.Token ?? default);
|
||||
}
|
||||
|
||||
// All the others.
|
||||
if (_consoleAccumulator < minTime)
|
||||
{
|
||||
var query = AllEntityQuery<StationCentcommComponent>();
|
||||
|
||||
// Guarantees that emergency shuttle arrives first before anyone else can FTL.
|
||||
if (CentComGrid != null)
|
||||
_shuttle.AddFTLDestination(CentComGrid.Value, true);
|
||||
while (query.MoveNext(out var comp))
|
||||
{
|
||||
if (Deleted(comp.Entity))
|
||||
continue;
|
||||
|
||||
_shuttle.AddFTLDestination(comp.Entity, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -371,7 +380,9 @@ public sealed partial class EmergencyShuttleSystem
|
||||
|
||||
public bool DelayEmergencyRoundEnd()
|
||||
{
|
||||
if (_roundEndCancelToken == null) return false;
|
||||
if (_roundEndCancelToken == null)
|
||||
return false;
|
||||
|
||||
_roundEndCancelToken?.Cancel();
|
||||
_roundEndCancelToken = null;
|
||||
return true;
|
||||
|
||||
Reference in New Issue
Block a user