Allow early salvage launches (#16503)
This commit is contained in:
@@ -5,6 +5,8 @@ using Content.Server.Shuttles.Events;
|
|||||||
using Content.Server.Shuttles.Systems;
|
using Content.Server.Shuttles.Systems;
|
||||||
using Content.Server.Station.Components;
|
using Content.Server.Station.Components;
|
||||||
using Content.Shared.Chat;
|
using Content.Shared.Chat;
|
||||||
|
using Content.Shared.Humanoid;
|
||||||
|
using Content.Shared.Mobs.Components;
|
||||||
using Content.Shared.Salvage;
|
using Content.Shared.Salvage;
|
||||||
using Content.Shared.Shuttles.Components;
|
using Content.Shared.Shuttles.Components;
|
||||||
using Robust.Shared.Audio;
|
using Robust.Shared.Audio;
|
||||||
@@ -25,6 +27,33 @@ public sealed partial class SalvageSystem
|
|||||||
SubscribeLocalEvent<FTLRequestEvent>(OnFTLRequest);
|
SubscribeLocalEvent<FTLRequestEvent>(OnFTLRequest);
|
||||||
SubscribeLocalEvent<FTLStartedEvent>(OnFTLStarted);
|
SubscribeLocalEvent<FTLStartedEvent>(OnFTLStarted);
|
||||||
SubscribeLocalEvent<FTLCompletedEvent>(OnFTLCompleted);
|
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>
|
/// <summary>
|
||||||
@@ -74,8 +103,6 @@ public sealed partial class SalvageSystem
|
|||||||
Announce(args.MapUid, Loc.GetString("salvage-expedition-announcement-dungeon", ("direction", component.DungeonLocation.GetDir())));
|
Announce(args.MapUid, Loc.GetString("salvage-expedition-announcement-dungeon", ("direction", component.DungeonLocation.GetDir())));
|
||||||
|
|
||||||
component.Stage = ExpeditionStage.Running;
|
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)
|
private void OnFTLStarted(ref FTLStartedEvent ev)
|
||||||
@@ -97,9 +124,6 @@ public sealed partial class SalvageSystem
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Let them pilot again when they get back.
|
|
||||||
RemCompDeferred<PreventPilotComponent>(ev.Entity);
|
|
||||||
|
|
||||||
// Check if any shuttles remain.
|
// Check if any shuttles remain.
|
||||||
var query = EntityQueryEnumerator<ShuttleComponent, TransformComponent>();
|
var query = EntityQueryEnumerator<ShuttleComponent, TransformComponent>();
|
||||||
|
|
||||||
|
|||||||
9
Content.Server/Shuttles/Events/ConsoleFTLAttemptEvent.cs
Normal file
9
Content.Server/Shuttles/Events/ConsoleFTLAttemptEvent.cs
Normal file
@@ -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);
|
||||||
@@ -96,6 +96,18 @@ public sealed partial class ShuttleSystem
|
|||||||
return false;
|
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;
|
reason = null;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,6 +36,8 @@ salvage-expedition-difficulty-Hazardous = Hazardous
|
|||||||
salvage-expedition-difficulty-Extreme = Extreme
|
salvage-expedition-difficulty-Extreme = Extreme
|
||||||
|
|
||||||
# Runner
|
# 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-minutes = {$duration} minutes remaining to complete the expedition.
|
||||||
salvage-expedition-announcement-countdown-seconds = {$duration} seconds 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}.
|
salvage-expedition-announcement-dungeon = Dungeon is located {$direction}.
|
||||||
|
|||||||
Reference in New Issue
Block a user