]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Allow early salvage launches (#16503)
authormetalgearsloth <31366439+metalgearsloth@users.noreply.github.com>
Tue, 16 May 2023 13:18:37 +0000 (23:18 +1000)
committerGitHub <noreply@github.com>
Tue, 16 May 2023 13:18:37 +0000 (23:18 +1000)
Content.Server/Salvage/SalvageSystem.Runner.cs
Content.Server/Shuttles/Events/ConsoleFTLAttemptEvent.cs [new file with mode: 0644]
Content.Server/Shuttles/Systems/ShuttleSystem.FasterThanLight.cs
Resources/Locale/en-US/procedural/expeditions.ftl

index 01f7340d42360c0021ab4c122161e8365ae13626..9c7cd903bd5a850a398aa7b2d515adfae1d4bd87 100644 (file)
@@ -5,6 +5,8 @@ using Content.Server.Shuttles.Events;
 using Content.Server.Shuttles.Systems;
 using Content.Server.Station.Components;
 using Content.Shared.Chat;
+using Content.Shared.Humanoid;
+using Content.Shared.Mobs.Components;
 using Content.Shared.Salvage;
 using Content.Shared.Shuttles.Components;
 using Robust.Shared.Audio;
@@ -25,6 +27,33 @@ public sealed partial class SalvageSystem
         SubscribeLocalEvent<FTLRequestEvent>(OnFTLRequest);
         SubscribeLocalEvent<FTLStartedEvent>(OnFTLStarted);
         SubscribeLocalEvent<FTLCompletedEvent>(OnFTLCompleted);
+        SubscribeLocalEvent<ConsoleFTLAttemptEvent>(OnConsoleFTLAttempt);
+    }
+
+    private void OnConsoleFTLAttempt(ref ConsoleFTLAttemptEvent ev)
+    {
+        if (!TryComp<TransformComponent>(ev.Uid, out var xform) ||
+            !TryComp<SalvageExpeditionComponent>(xform.MapUid, out var salvage))
+        {
+            return;
+        }
+
+        // TODO: This is terrible but need bluespace harnesses or something.
+        var query = EntityQueryEnumerator<HumanoidAppearanceComponent, MobStateComponent, TransformComponent>();
+
+        while (query.MoveNext(out var _, out var _, out var mobXform))
+        {
+            if (mobXform.MapUid != xform.MapUid)
+                continue;
+
+            // Okay they're on salvage, so are they on the shuttle.
+            if (mobXform.GridUid != ev.Uid)
+            {
+                ev.Cancelled = true;
+                ev.Reason = Loc.GetString("salvage-expedition-not-all-present");
+                return;
+            }
+        }
     }
 
     /// <summary>
@@ -74,8 +103,6 @@ public sealed partial class SalvageSystem
             Announce(args.MapUid, Loc.GetString("salvage-expedition-announcement-dungeon", ("direction", component.DungeonLocation.GetDir())));
 
         component.Stage = ExpeditionStage.Running;
-        // At least for now stop them FTLing back until the mission is over.
-        EnsureComp<PreventPilotComponent>(args.Entity);
     }
 
     private void OnFTLStarted(ref FTLStartedEvent ev)
@@ -97,9 +124,6 @@ public sealed partial class SalvageSystem
             return;
         }
 
-        // Let them pilot again when they get back.
-        RemCompDeferred<PreventPilotComponent>(ev.Entity);
-
         // Check if any shuttles remain.
         var query = EntityQueryEnumerator<ShuttleComponent, TransformComponent>();
 
diff --git a/Content.Server/Shuttles/Events/ConsoleFTLAttemptEvent.cs b/Content.Server/Shuttles/Events/ConsoleFTLAttemptEvent.cs
new file mode 100644 (file)
index 0000000..ad2b355
--- /dev/null
@@ -0,0 +1,9 @@
+namespace Content.Server.Shuttles.Events;
+
+/// <summary>
+/// Raised when a shuttle console is trying to FTL via UI input.
+/// </summary>
+/// <param name="Cancelled"></param>
+/// <param name="Reason"></param>
+[ByRefEvent]
+public record struct ConsoleFTLAttemptEvent(EntityUid Uid, bool Cancelled, string Reason);
index 594be5aa54c19ed9863a236a30dde91e0255a724..2187936551d08eecf31c07097ef1c1b4fa83ad75 100644 (file)
@@ -96,6 +96,18 @@ public sealed partial class ShuttleSystem
             return false;
         }
 
+        if (uid != null)
+        {
+            var ev = new ConsoleFTLAttemptEvent(uid.Value, false, string.Empty);
+            RaiseLocalEvent(uid.Value, ref ev, true);
+
+            if (ev.Cancelled)
+            {
+                reason = ev.Reason;
+                return false;
+            }
+        }
+
         reason = null;
         return true;
     }
index b7258d365d46b219b434dedbd2b94d5a7fea0801..bed82b0fb0a1bbed4201db9636be272ffd5bf8f3 100644 (file)
@@ -36,6 +36,8 @@ salvage-expedition-difficulty-Hazardous = Hazardous
 salvage-expedition-difficulty-Extreme = Extreme
 
 # Runner
+salvage-expedition-not-all-present = Not all salvagers are aboard the shuttle!
+
 salvage-expedition-announcement-countdown-minutes = {$duration} minutes remaining to complete the expedition.
 salvage-expedition-announcement-countdown-seconds = {$duration} seconds remaining to complete the expedition.
 salvage-expedition-announcement-dungeon = Dungeon is located {$direction}.