active pinpointers finds targets upon map transition (#10241)
This commit is contained in:
@@ -2,6 +2,7 @@ using Content.Shared.Interaction;
|
|||||||
using Content.Shared.Pinpointer;
|
using Content.Shared.Pinpointer;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using Robust.Shared.Utility;
|
using Robust.Shared.Utility;
|
||||||
|
using Content.Server.Shuttles.Events;
|
||||||
|
|
||||||
namespace Content.Server.Pinpointer
|
namespace Content.Server.Pinpointer
|
||||||
{
|
{
|
||||||
@@ -13,12 +14,29 @@ namespace Content.Server.Pinpointer
|
|||||||
{
|
{
|
||||||
base.Initialize();
|
base.Initialize();
|
||||||
SubscribeLocalEvent<PinpointerComponent, ActivateInWorldEvent>(OnActivate);
|
SubscribeLocalEvent<PinpointerComponent, ActivateInWorldEvent>(OnActivate);
|
||||||
|
SubscribeLocalEvent<HyperspaceJumpCompletedEvent>(OnLocateTarget);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnActivate(EntityUid uid, PinpointerComponent component, ActivateInWorldEvent args)
|
private void OnActivate(EntityUid uid, PinpointerComponent component, ActivateInWorldEvent args)
|
||||||
{
|
{
|
||||||
TogglePinpointer(uid, component);
|
TogglePinpointer(uid, component);
|
||||||
|
LocateTarget(uid, component);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnLocateTarget(HyperspaceJumpCompletedEvent ev)
|
||||||
|
{
|
||||||
|
// This feels kind of expensive, but it only happens once per hyperspace jump
|
||||||
|
foreach (var uid in ActivePinpointers)
|
||||||
|
{
|
||||||
|
if (TryComp<PinpointerComponent>(uid, out var component))
|
||||||
|
{
|
||||||
|
LocateTarget(uid, component);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void LocateTarget(EntityUid uid, PinpointerComponent component)
|
||||||
|
{
|
||||||
// try to find target from whitelist
|
// try to find target from whitelist
|
||||||
if (component.IsActive && component.Component != null)
|
if (component.IsActive && component.Component != null)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -0,0 +1,8 @@
|
|||||||
|
using Content.Server.Shuttles.Systems;
|
||||||
|
|
||||||
|
namespace Content.Server.Shuttles.Events;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Raised when <see cref="ShuttleSystem.FasterThanLight"/> has completed FTL Travel.
|
||||||
|
/// </summary>
|
||||||
|
public sealed class HyperspaceJumpCompletedEvent: EntityEventArgs {}
|
||||||
@@ -13,6 +13,7 @@ using Robust.Shared.Map;
|
|||||||
using Robust.Shared.Player;
|
using Robust.Shared.Player;
|
||||||
using Robust.Shared.Utility;
|
using Robust.Shared.Utility;
|
||||||
using System.Diagnostics.CodeAnalysis;
|
using System.Diagnostics.CodeAnalysis;
|
||||||
|
using Content.Server.Shuttles.Events;
|
||||||
|
|
||||||
namespace Content.Server.Shuttles.Systems;
|
namespace Content.Server.Shuttles.Systems;
|
||||||
|
|
||||||
@@ -307,6 +308,7 @@ public sealed partial class ShuttleSystem
|
|||||||
comp.State = FTLState.Cooldown;
|
comp.State = FTLState.Cooldown;
|
||||||
comp.Accumulator += FTLCooldown;
|
comp.Accumulator += FTLCooldown;
|
||||||
_console.RefreshShuttleConsoles(comp.Owner);
|
_console.RefreshShuttleConsoles(comp.Owner);
|
||||||
|
RaiseLocalEvent(new HyperspaceJumpCompletedEvent());
|
||||||
break;
|
break;
|
||||||
case FTLState.Cooldown:
|
case FTLState.Cooldown:
|
||||||
RemComp<FTLComponent>(comp.Owner);
|
RemComp<FTLComponent>(comp.Owner);
|
||||||
|
|||||||
Reference in New Issue
Block a user