Add FTL destinations (#9685)
This commit is contained in:
@@ -52,7 +52,7 @@ public sealed partial class ShuttleSystem
|
||||
/// <summary>
|
||||
/// <see cref="CCVars.EmergencyShuttleTransitTime"/>
|
||||
/// </summary>
|
||||
private float _transitTime;
|
||||
public float TransitTime { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// <see cref="CCVars.EmergencyShuttleAuthorizeTime"/>
|
||||
@@ -69,6 +69,11 @@ public sealed partial class ShuttleSystem
|
||||
/// </summary>
|
||||
private bool _launchedShuttles;
|
||||
|
||||
/// <summary>
|
||||
/// Have we announced the launch?
|
||||
/// </summary>
|
||||
private bool _announced;
|
||||
|
||||
private void InitializeEmergencyConsole()
|
||||
{
|
||||
_configManager.OnValueChanged(CCVars.EmergencyShuttleTransitTime, SetTransitTime, true);
|
||||
@@ -86,7 +91,7 @@ public sealed partial class ShuttleSystem
|
||||
|
||||
private void SetTransitTime(float obj)
|
||||
{
|
||||
_transitTime = obj;
|
||||
TransitTime = obj;
|
||||
}
|
||||
|
||||
private void ShutdownEmergencyConsole()
|
||||
@@ -106,6 +111,14 @@ public sealed partial class ShuttleSystem
|
||||
|
||||
_consoleAccumulator -= frameTime;
|
||||
|
||||
// No early launch but we're under the timer.
|
||||
if (!_launchedShuttles && _consoleAccumulator <= _authorizeTime)
|
||||
{
|
||||
if (!EarlyLaunchAuthorized)
|
||||
AnnounceLaunch();
|
||||
}
|
||||
|
||||
// Imminent departure
|
||||
if (!_launchedShuttles && _consoleAccumulator <= DefaultStartupTime)
|
||||
{
|
||||
_launchedShuttles = true;
|
||||
@@ -119,27 +132,33 @@ public sealed partial class ShuttleSystem
|
||||
if (Deleted(_centcomm))
|
||||
{
|
||||
// TODO: Need to get non-overlapping positions.
|
||||
Hyperspace(shuttle,
|
||||
FTLTravel(shuttle,
|
||||
new EntityCoordinates(
|
||||
_mapManager.GetMapEntityId(_centcommMap.Value),
|
||||
Vector2.One * 1000f), _consoleAccumulator, _transitTime);
|
||||
Vector2.One * 1000f), _consoleAccumulator, TransitTime);
|
||||
}
|
||||
else
|
||||
{
|
||||
Hyperspace(shuttle,
|
||||
_centcomm.Value, _consoleAccumulator, _transitTime);
|
||||
FTLTravel(shuttle,
|
||||
_centcomm.Value, _consoleAccumulator, TransitTime);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Departed
|
||||
if (_consoleAccumulator <= 0f)
|
||||
{
|
||||
_launchedShuttles = true;
|
||||
_chatSystem.DispatchGlobalAnnouncement(Loc.GetString("emergency-shuttle-left", ("transitTime", $"{_transitTime:0}")));
|
||||
_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);
|
||||
|
||||
// Guarantees that emergency shuttle arrives first before anyone else can FTL.
|
||||
if (_centcomm != null)
|
||||
AddFTLDestination(_centcomm.Value, true);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -213,6 +232,7 @@ public sealed partial class ShuttleSystem
|
||||
|
||||
private void CleanupEmergencyConsole()
|
||||
{
|
||||
_announced = false;
|
||||
_roundEndCancelToken = null;
|
||||
_launchedShuttles = false;
|
||||
_consoleAccumulator = 0f;
|
||||
@@ -259,20 +279,28 @@ public sealed partial class ShuttleSystem
|
||||
/// </summary>
|
||||
public bool EarlyLaunch()
|
||||
{
|
||||
if (EarlyLaunchAuthorized || !EmergencyShuttleArrived) return false;
|
||||
if (EarlyLaunchAuthorized || !EmergencyShuttleArrived || _consoleAccumulator <= _authorizeTime) return false;
|
||||
|
||||
_logger.Add(LogType.EmergencyShuttle, LogImpact.Extreme, $"Emergency shuttle launch authorized");
|
||||
_consoleAccumulator = MathF.Max(1f, MathF.Min(_consoleAccumulator, _authorizeTime));
|
||||
_consoleAccumulator =_authorizeTime;
|
||||
EarlyLaunchAuthorized = true;
|
||||
RaiseLocalEvent(new EmergencyShuttleAuthorizedEvent());
|
||||
AnnounceLaunch();
|
||||
UpdateAllEmergencyConsoles();
|
||||
return true;
|
||||
}
|
||||
|
||||
private void AnnounceLaunch()
|
||||
{
|
||||
if (_announced) return;
|
||||
|
||||
_announced = true;
|
||||
_chatSystem.DispatchGlobalAnnouncement(
|
||||
Loc.GetString("emergency-shuttle-launch-time", ("consoleAccumulator", $"{_consoleAccumulator:0}")),
|
||||
playDefaultSound: false,
|
||||
colorOverride: DangerColor);
|
||||
|
||||
SoundSystem.Play("/Audio/Misc/notice1.ogg", Filter.Broadcast());
|
||||
UpdateAllEmergencyConsoles();
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool DelayEmergencyRoundEnd()
|
||||
|
||||
Reference in New Issue
Block a user