mirror of
https://github.com/wega-team/ss14-wega.git
synced 2026-02-15 03:31:44 +01:00
Fix xenoborg evac calling announcment (#41437)
* no longer calls evac if evac is called or if the round is over * can't recall shuttle * some commentary * can recall next round * cancel evac recalling * add this back * only call once * admins can recall anyway now * 1 bool is better than 2 i guess * some cleanup --------- Co-authored-by: Princess Cheeseballs <66055347+Pronana@users.noreply.github.com>
This commit is contained in:
@@ -35,7 +35,7 @@ namespace Content.Server.Administration.Commands
|
||||
|
||||
public override void Execute(IConsoleShell shell, string argStr, string[] args)
|
||||
{
|
||||
_roundEndSystem.CancelRoundEndCountdown(shell.Player?.AttachedEntity, false);
|
||||
_roundEndSystem.CancelRoundEndCountdown(shell.Player?.AttachedEntity, forceRecall: true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,4 +36,11 @@ public sealed partial class XenoborgsRuleComponent : Component
|
||||
/// </summary>
|
||||
[DataField]
|
||||
public bool MothershipCoreDeathAnnouncmentSent = false;
|
||||
|
||||
/// <summary>
|
||||
/// If the emergency shuttle trigged by <see cref="XenoborgShuttleCallPercentage"> was already called.
|
||||
/// Will only call once. if a admin recalls it. it won't call again unless this is set to false by a admin
|
||||
/// </summary>
|
||||
[DataField]
|
||||
public bool XenoborgShuttleCalled = false;
|
||||
}
|
||||
|
||||
@@ -100,14 +100,17 @@ public sealed class XenoborgsRuleSystem : GameRuleSystem<XenoborgsRuleComponent>
|
||||
|
||||
xenoborgsRuleComponent.MaxNumberXenoborgs = Math.Max(xenoborgsRuleComponent.MaxNumberXenoborgs, numXenoborgs);
|
||||
|
||||
if ((float)numXenoborgs / (numHumans + numXenoborgs) > xenoborgsRuleComponent.XenoborgShuttleCallPercentage)
|
||||
if (xenoborgsRuleComponent.XenoborgShuttleCalled
|
||||
|| (float)numXenoborgs / (numHumans + numXenoborgs) <= xenoborgsRuleComponent.XenoborgShuttleCallPercentage
|
||||
|| _roundEnd.IsRoundEndRequested())
|
||||
return;
|
||||
|
||||
foreach (var station in _station.GetStations())
|
||||
{
|
||||
foreach (var station in _station.GetStations())
|
||||
{
|
||||
_chatSystem.DispatchStationAnnouncement(station, Loc.GetString("xenoborg-shuttle-call"), colorOverride: Color.BlueViolet);
|
||||
}
|
||||
_roundEnd.RequestRoundEnd(null, false);
|
||||
_chatSystem.DispatchStationAnnouncement(station, Loc.GetString("xenoborg-shuttle-call"), colorOverride: Color.BlueViolet);
|
||||
}
|
||||
_roundEnd.RequestRoundEnd(null, false, cantRecall: true);
|
||||
xenoborgsRuleComponent.XenoborgShuttleCalled = true;
|
||||
}
|
||||
|
||||
protected override void Started(EntityUid uid, XenoborgsRuleComponent component, GameRuleComponent gameRule, GameRuleStartedEvent args)
|
||||
|
||||
@@ -56,6 +56,11 @@ namespace Content.Server.RoundEnd
|
||||
public TimeSpan? ExpectedShuttleLength => ExpectedCountdownEnd - LastCountdownStart;
|
||||
public TimeSpan? ShuttleTimeLeft => ExpectedCountdownEnd - _gameTiming.CurTime;
|
||||
|
||||
/// <summary>
|
||||
/// If the shuttle can't be recalled. if set to true, the station wont be able to recall
|
||||
/// </summary>
|
||||
public bool CantRecall = false;
|
||||
|
||||
public TimeSpan AutoCallStartTime;
|
||||
private bool _autoCalledBefore = false;
|
||||
|
||||
@@ -85,6 +90,8 @@ namespace Content.Server.RoundEnd
|
||||
_cooldownTokenSource = null;
|
||||
}
|
||||
|
||||
CantRecall = false;
|
||||
|
||||
LastCountdownStart = null;
|
||||
ExpectedCountdownEnd = null;
|
||||
SetAutoCallTime();
|
||||
@@ -116,7 +123,7 @@ namespace Content.Server.RoundEnd
|
||||
|
||||
public bool CanCallOrRecall()
|
||||
{
|
||||
return _cooldownTokenSource == null;
|
||||
return _cooldownTokenSource == null && !CantRecall;
|
||||
}
|
||||
|
||||
public bool IsRoundEndRequested()
|
||||
@@ -124,7 +131,15 @@ namespace Content.Server.RoundEnd
|
||||
return _countdownTokenSource != null;
|
||||
}
|
||||
|
||||
public void RequestRoundEnd(EntityUid? requester = null, bool checkCooldown = true, string text = "round-end-system-shuttle-called-announcement", string name = "round-end-system-shuttle-sender-announcement")
|
||||
/// <summary>
|
||||
/// Starts the process of ending the round by calling evac
|
||||
/// </summary>
|
||||
/// <param name="requester"></param>
|
||||
/// <param name="checkCooldown"></param>
|
||||
/// <param name="text">text in the announcement of shuttle calling</param>
|
||||
/// <param name="name">name in the announcement of shuttle calling</param>
|
||||
/// <param name="cantRecall">if the station shouldn't be able to recall the shuttle</param>
|
||||
public void RequestRoundEnd(EntityUid? requester = null, bool checkCooldown = true, string text = "round-end-system-shuttle-called-announcement", string name = "round-end-system-shuttle-sender-announcement", bool cantRecall = false)
|
||||
{
|
||||
var duration = DefaultCountdownDuration;
|
||||
|
||||
@@ -139,10 +154,19 @@ namespace Content.Server.RoundEnd
|
||||
}
|
||||
}
|
||||
|
||||
RequestRoundEnd(duration, requester, checkCooldown, text, name);
|
||||
RequestRoundEnd(duration, requester, checkCooldown, text, name, cantRecall);
|
||||
}
|
||||
|
||||
public void RequestRoundEnd(TimeSpan countdownTime, EntityUid? requester = null, bool checkCooldown = true, string text = "round-end-system-shuttle-called-announcement", string name = "round-end-system-shuttle-sender-announcement")
|
||||
/// <summary>
|
||||
/// Starts the process of ending the round by calling evac
|
||||
/// </summary>
|
||||
/// <param name="countdownTime">time for evac to arrive</param>
|
||||
/// <param name="requester"></param>
|
||||
/// <param name="checkCooldown"></param>
|
||||
/// <param name="text">text in the announcement of shuttle calling</param>
|
||||
/// <param name="name">name in the announcement of shuttle calling</param>
|
||||
/// <param name="cantRecall">if the station shouldn't be able to recall the shuttle</param>
|
||||
public void RequestRoundEnd(TimeSpan countdownTime, EntityUid? requester = null, bool checkCooldown = true, string text = "round-end-system-shuttle-called-announcement", string name = "round-end-system-shuttle-sender-announcement", bool cantRecall = false)
|
||||
{
|
||||
if (_gameTicker.RunLevel != GameRunLevel.InRound)
|
||||
return;
|
||||
@@ -154,6 +178,7 @@ namespace Content.Server.RoundEnd
|
||||
return;
|
||||
|
||||
_countdownTokenSource = new();
|
||||
CantRecall = cantRecall;
|
||||
|
||||
if (requester != null)
|
||||
{
|
||||
@@ -214,12 +239,17 @@ namespace Content.Server.RoundEnd
|
||||
}
|
||||
}
|
||||
|
||||
public void CancelRoundEndCountdown(EntityUid? requester = null, bool checkCooldown = true)
|
||||
public void CancelRoundEndCountdown(EntityUid? requester = null, bool forceRecall = false)
|
||||
{
|
||||
if (_gameTicker.RunLevel != GameRunLevel.InRound) return;
|
||||
if (checkCooldown && _cooldownTokenSource != null) return;
|
||||
if (_gameTicker.RunLevel != GameRunLevel.InRound)
|
||||
return;
|
||||
|
||||
if (!forceRecall && (CantRecall || _cooldownTokenSource != null))
|
||||
return;
|
||||
|
||||
if (_countdownTokenSource == null)
|
||||
return;
|
||||
|
||||
if (_countdownTokenSource == null) return;
|
||||
_countdownTokenSource.Cancel();
|
||||
_countdownTokenSource = null;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user