From 412f3f470c92bf2d974b13bc4e5e1c964d3a5346 Mon Sep 17 00:00:00 2001 From: mr-bo-jangles Date: Sat, 6 Jan 2024 07:31:20 +0000 Subject: [PATCH] Set pAI up with a static map the pAI can use (#23499) * Set pAI up with a trackless map * Added a untracked map user interface class to support gps-less mapping * Added to pAI by default, expect it to be given to borgs as well in time. As the personal AI is literally immobile as a ghost, it is useful to ensure that people carry one. With that idea in mind, it is worth giving the pAI a reason to be carried that doesn't depend on the player having a cracking selection of midi files on hand. * Tried to use new ProtoId and have EntityUid on the client as commented by metalgearsloth * Review --------- Co-authored-by: metalgearsloth --- .../UI/NavMapBeaconBoundUserInterface.cs | 1 - .../UI/UntrackedMapBoundUserInterface.cs | 35 +++++++++++++++++++ Content.Shared/PAI/PAIComponent.cs | 23 +++++++----- Content.Shared/PAI/SharedPAISystem.cs | 2 ++ .../Prototypes/Entities/Objects/Fun/pai.yml | 15 ++++++++ 5 files changed, 66 insertions(+), 10 deletions(-) create mode 100644 Content.Client/Pinpointer/UI/UntrackedMapBoundUserInterface.cs diff --git a/Content.Client/Pinpointer/UI/NavMapBeaconBoundUserInterface.cs b/Content.Client/Pinpointer/UI/NavMapBeaconBoundUserInterface.cs index 0573d1a2db..3ebcf7cbce 100644 --- a/Content.Client/Pinpointer/UI/NavMapBeaconBoundUserInterface.cs +++ b/Content.Client/Pinpointer/UI/NavMapBeaconBoundUserInterface.cs @@ -16,7 +16,6 @@ public sealed class NavMapBeaconBoundUserInterface : BoundUserInterface protected override void Open() { base.Open(); - _window = new NavMapBeaconWindow(Owner); _window.OpenCentered(); _window.OnClose += Close; diff --git a/Content.Client/Pinpointer/UI/UntrackedMapBoundUserInterface.cs b/Content.Client/Pinpointer/UI/UntrackedMapBoundUserInterface.cs new file mode 100644 index 0000000000..57965b030a --- /dev/null +++ b/Content.Client/Pinpointer/UI/UntrackedMapBoundUserInterface.cs @@ -0,0 +1,35 @@ +using Robust.Client.GameObjects; + +namespace Content.Client.Pinpointer.UI; + +public sealed class UntrackedStationMapBoundUserInterface : BoundUserInterface +{ + [ViewVariables] + private StationMapWindow? _window; + + public UntrackedStationMapBoundUserInterface(EntityUid owner, Enum uiKey) : base(owner, uiKey) + { + } + + protected override void Open() + { + base.Open(); + _window?.Close(); + EntityUid? gridUid = null; + + if (EntMan.TryGetComponent(Owner, out var xform)) + { + gridUid = xform.GridUid; + } + + _window = new StationMapWindow(gridUid, null); + _window.OpenCentered(); + _window.OnClose += Close; + } + + protected override void Dispose(bool disposing) + { + base.Dispose(disposing); + _window?.Dispose(); + } +} diff --git a/Content.Shared/PAI/PAIComponent.cs b/Content.Shared/PAI/PAIComponent.cs index 677b0b4d48..b4e4c92735 100644 --- a/Content.Shared/PAI/PAIComponent.cs +++ b/Content.Shared/PAI/PAIComponent.cs @@ -14,38 +14,43 @@ namespace Content.Shared.PAI; /// and there's not always enough players and ghost roles to justify it. /// All logic in PAISystem. /// -[RegisterComponent, NetworkedComponent] +[RegisterComponent, NetworkedComponent, AutoGenerateComponentState] public sealed partial class PAIComponent : Component { /// /// The last person who activated this PAI. /// Used for assigning the name. /// - [DataField("lastUser"), ViewVariables(VVAccess.ReadWrite)] + [DataField, ViewVariables(VVAccess.ReadWrite)] public EntityUid? LastUser; - [DataField("midiActionId", serverOnly: true, - customTypeSerializer: typeof(PrototypeIdSerializer))] - public string? MidiActionId = "ActionPAIPlayMidi"; + [DataField(serverOnly: true)] + public EntProtoId? MidiActionId = "ActionPAIPlayMidi"; - [DataField("midiAction", serverOnly: true)] // server only, as it uses a server-BUI event !type + [DataField(serverOnly: true)] // server only, as it uses a server-BUI event !type public EntityUid? MidiAction; + [DataField] + public ProtoId MapActionId = "ActionPAIOpenMap"; + + [DataField, AutoNetworkedField] + public EntityUid? MapAction; + /// /// When microwaved there is this chance to brick the pai, kicking out its player and preventing it from being used again. /// - [DataField("brickChance")] + [DataField] public float BrickChance = 0.5f; /// /// Locale id for the popup shown when the pai gets bricked. /// - [DataField("brickPopup")] + [DataField] public string BrickPopup = "pai-system-brick-popup"; /// /// Locale id for the popup shown when the pai is microwaved but does not get bricked. /// - [DataField("scramblePopup")] + [DataField] public string ScramblePopup = "pai-system-scramble-popup"; } diff --git a/Content.Shared/PAI/SharedPAISystem.cs b/Content.Shared/PAI/SharedPAISystem.cs index 59db9dd54d..d66365eb85 100644 --- a/Content.Shared/PAI/SharedPAISystem.cs +++ b/Content.Shared/PAI/SharedPAISystem.cs @@ -26,11 +26,13 @@ namespace Content.Shared.PAI private void OnMapInit(EntityUid uid, PAIComponent component, MapInitEvent args) { _actionsSystem.AddAction(uid, ref component.MidiAction, component.MidiActionId); + _actionsSystem.AddAction(uid, ref component.MapAction, component.MapActionId); } private void OnShutdown(EntityUid uid, PAIComponent component, ComponentShutdown args) { _actionsSystem.RemoveAction(uid, component.MidiAction); + _actionsSystem.RemoveAction(uid, component.MapAction); } } } diff --git a/Resources/Prototypes/Entities/Objects/Fun/pai.yml b/Resources/Prototypes/Entities/Objects/Fun/pai.yml index b9da6775c9..723d74c4c8 100644 --- a/Resources/Prototypes/Entities/Objects/Fun/pai.yml +++ b/Resources/Prototypes/Entities/Objects/Fun/pai.yml @@ -15,6 +15,8 @@ interfaces: - key: enum.InstrumentUiKey.Key type: InstrumentBoundUserInterface + - key: enum.StationMapUiKey.Key + type: UntrackedStationMapBoundUserInterface - type: Sprite sprite: Objects/Fun/pai.rsi layers: @@ -67,6 +69,7 @@ Off: { state: pai-off-overlay } Searching: { state: pai-searching-overlay } On: { state: pai-on-overlay } + - type: StationMap - type: entity parent: PersonalAI @@ -138,3 +141,15 @@ icon: Interface/Actions/pai-midi.png event: !type:OpenUiActionEvent key: enum.InstrumentUiKey.Key + +- type: entity + id: ActionPAIOpenMap + name: Open Map + description: Open your map interface and guide your owner. + noSpawn: true + components: + - type: InstantAction + checkCanInteract: false + icon: Interface/home.png + event: !type:OpenUiActionEvent + key: enum.StationMapUiKey.Key