base.Open();
EntityUid? gridUid = null;
- if (EntMan.TryGetComponent<TransformComponent>(Owner, out var xform))
+ if (EntMan.TryGetComponent<StationMapComponent>(Owner, out var comp) && comp.TargetGrid != null)
+ {
+ gridUid = comp.TargetGrid;
+ }
+ else if (EntMan.TryGetComponent<TransformComponent>(Owner, out var xform))
{
gridUid = xform.GridUid;
}
{
stationName = gridMetaData.EntityName;
}
-
- if (EntMan.TryGetComponent<StationMapComponent>(Owner, out var comp) && comp.ShowLocation)
+
+ if (comp != null && comp.ShowLocation)
_window.Set(stationName, gridUid, Owner);
else
_window.Set(stationName, gridUid, null);
return;
component.TargetStation = RobustRandom.Pick(eligible);
+ var ev = new NukeopsTargetStationSelectedEvent(uid, component.TargetStation);
+ RaiseLocalEvent(ref ev);
}
#region Event Handlers
return null;
}
}
+
+/// <summary>
+/// Raised when a station has been assigned as a target for the NukeOps rule.
+/// </summary>
+[ByRefEvent]
+public readonly struct NukeopsTargetStationSelectedEvent(EntityUid ruleEntity, EntityUid? targetStation)
+{
+ /// <summary>
+ /// The entity containing the NukeOps gamerule.
+ /// </summary>
+ public readonly EntityUid RuleEntity = ruleEntity;
+
+ /// <summary>
+ /// The target station, if it exists.
+ /// </summary>
+ public readonly EntityUid? TargetStation = targetStation;
+}
+using Content.Server.GameTicking;
+using Content.Server.GameTicking.Rules;
+using Content.Server.GameTicking.Rules.Components;
using Content.Shared.PowerCell;
using Content.Shared.Pinpointer;
+using Content.Shared.Station;
using Robust.Server.GameObjects;
-using Robust.Shared.Player;
namespace Content.Server.Pinpointer;
{
[Dependency] private readonly UserInterfaceSystem _ui = default!;
[Dependency] private readonly PowerCellSystem _cell = default!;
+ [Dependency] private readonly SharedStationSystem _station = default!;
+ [Dependency] private readonly SharedTransformSystem _xform = default!;
+ [Dependency] private readonly GameTicker _gameTicker = default!;
public override void Initialize()
{
base.Initialize();
+ SubscribeLocalEvent<StationMapComponent, MapInitEvent>(OnMapInit);
SubscribeLocalEvent<StationMapUserComponent, EntParentChangedMessage>(OnUserParentChanged);
+ SubscribeLocalEvent<NukeopsStationMapComponent, NukeopsTargetStationSelectedEvent>(OnNukeopsStationSelected);
+
Subs.BuiEvents<StationMapComponent>(StationMapUiKey.Key, subs =>
{
subs.Event<BoundUIOpenedEvent>(OnStationMapOpened);
});
}
+ private void OnMapInit(Entity<StationMapComponent> ent, ref MapInitEvent args)
+ {
+ if (!ent.Comp.InitializeWithStation)
+ return;
+
+ // If we ever find a need to make more exceptions like this, just turn this into an event.
+ if (HasComp<NukeopsStationMapComponent>(ent))
+ {
+ foreach (var rule in _gameTicker.GetActiveGameRules())
+ {
+ if (TryComp<NukeopsRuleComponent>(rule, out var nukeopsRule) && nukeopsRule.TargetStation != null)
+ {
+ ent.Comp.TargetGrid = _station.GetLargestGrid((nukeopsRule.TargetStation.Value, null));
+ Dirty(ent);
+ return;
+ }
+ }
+ }
+
+ var station = _station.GetStationInMap(_xform.GetMapId(ent.Owner));
+ if (station != null)
+ {
+ ent.Comp.TargetGrid = _station.GetLargestGrid((station.Value, null));
+ Dirty(ent);
+ }
+ }
+
private void OnStationMapClosed(EntityUid uid, StationMapComponent component, BoundUIClosedEvent args)
{
if (!Equals(args.UiKey, StationMapUiKey.Key))
var comp = EnsureComp<StationMapUserComponent>(args.Actor);
comp.Map = uid;
}
+
+ private void OnNukeopsStationSelected(Entity<NukeopsStationMapComponent> ent, ref NukeopsTargetStationSelectedEvent args)
+ {
+ if (args.TargetStation == null)
+ return;
+
+ if (!TryComp<StationMapComponent>(ent, out var stationMap) || !TryComp<RuleGridsComponent>(args.RuleEntity, out var ruleGrids))
+ return;
+
+ if (Transform(ent).MapID != ruleGrids.Map)
+ return;
+
+ stationMap.TargetGrid = _station.GetLargestGrid((args.TargetStation.Value, null));
+ Dirty(ent);
+ }
}
--- /dev/null
+namespace Content.Shared.Pinpointer;
+
+/// <summary>
+/// Used to indicate that an entity with the StationMapComponent should be updated to target the TargetStation of NukeopsRuleComponent.
+/// Uses the most recent active NukeopsRule when spawned, or the NukeopsRule which spawned the grid that the entity is on.
+/// </summary>
+[RegisterComponent]
+public sealed partial class NukeopsStationMapComponent : Component
+{
+}
+using Robust.Shared.GameStates;
+
namespace Content.Shared.Pinpointer;
-[RegisterComponent]
+[RegisterComponent, NetworkedComponent, AutoGenerateComponentState]
public sealed partial class StationMapComponent : Component
{
/// <summary>
/// Whether or not to show the user's location on the map.
/// </summary>
- [DataField]
+ [DataField, AutoNetworkedField]
public bool ShowLocation = true;
+
+ /// <summary>
+ /// If true, when this entity initializes it will target and remember the station grid of the map the entity is in.
+ /// If there is no station, the entity will target a random station in the current session.
+ /// </summary>
+ [DataField]
+ public bool InitializeWithStation = false;
+
+ /// <summary>
+ /// The target grid that the map will display.
+ /// If null, it will display the user's current grid.
+ /// </summary>
+ [DataField, AutoNetworkedField]
+ public EntityUid? TargetGrid;
}
id: HandheldStationMapUnpowered
parent: BaseHandheldStationMap
suffix: Handheld, Always Powered
+
+- type: entity
+ parent: HandheldStationMap
+ id: HandheldStationMapStatic
+ suffix: Handheld, Works Off-Station
+ components:
+ - type: StationMap
+ initializeWithStation: true
+
+- type: entity
+ parent: HandheldStationMap
+ id: HandheldStationMapNukeops
+ name: target station map
+ suffix: Handheld, NukeOps
+ description: Displays a readout of the target station.
+ components:
+ - type: Sprite
+ sprite: Objects/Devices/tablets.rsi
+ layers:
+ - state: tablet
+ - state: syndie
+ shader: unshaded
+ - type: Item
+ sprite: Objects/Devices/tablets.rsi
+ inhandVisuals:
+ left:
+ - state: inhand-left-syndie
+ right:
+ - state: inhand-right-syndie
+ - type: StationMap
+ showLocation: false
+ initializeWithStation: true
+ - type: NukeopsStationMap
+
{
"version": 1,
"license": "CC-BY-SA-3.0",
- "copyright": "Taken from Baystation12 at https://github.com/Baystation12/Baystation12/tree/17e84546562b97d775cb26790a08e6d87e7f8077 and heavily modified by Flareguy for Space Station 14. Inhands by carousel",
+ "copyright": "Taken from Baystation12 at https://github.com/Baystation12/Baystation12/tree/17e84546562b97d775cb26790a08e6d87e7f8077 and heavily modified by Flareguy for Space Station 14. Inhands by carousel. Syndie versions modified from generic by SlamBamActionman",
"size": {
"x": 32,
"y": 32
{
"name": "inhand-right",
"directions": 4
+ },
+ {
+ "name": "syndie",
+ "delays": [
+ [
+ 0.3,
+ 0.3
+ ]
+ ]
+ },
+ {
+ "name": "inhand-left-syndie",
+ "directions": 4
+ },
+ {
+ "name": "inhand-right-syndie",
+ "directions": 4
}
]
}