]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Fix xenoborg evac calling announcment (#41437)
authorSamuka <47865393+Samuka-C@users.noreply.github.com>
Tue, 2 Dec 2025 14:28:33 +0000 (11:28 -0300)
committerGitHub <noreply@github.com>
Tue, 2 Dec 2025 14:28:33 +0000 (14:28 +0000)
* 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>
Content.Server/Administration/Commands/ShuttleCommands.cs
Content.Server/GameTicking/Rules/Components/XenoborgsRuleComponent.cs
Content.Server/GameTicking/Rules/XenoborgsRuleSystem.cs
Content.Server/RoundEnd/RoundEndSystem.cs

index 677c38ac4e9b8ce32bd255a97ae0b584b18df850..6dffe1f52c8e5cce9bf09f9aa5448dc9436b190d 100644 (file)
@@ -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);
         }
     }
 }
index c7496bb0fbda36b28b16e4620076d97a14f768b9..4a018d7e6c626e07cf3f82c1122fe311188a3b4a 100644 (file)
@@ -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;
 }
index 97a6efb471ed096cad9dd9f6798a6b3ac1ffc7fa..cda1bce258c900f1efac27a67b99187614e52209 100644 (file)
@@ -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)
index a464796a74eb1047f8529236e9bc0da6ec20a87a..9419d4b01ce48de66275e8fc84128951349fad72 100644 (file)
@@ -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;