]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Set pAI up with a static map the pAI can use (#23499)
authormr-bo-jangles <mr-bo-jangles@users.noreply.github.com>
Sat, 6 Jan 2024 07:31:20 +0000 (07:31 +0000)
committerGitHub <noreply@github.com>
Sat, 6 Jan 2024 07:31:20 +0000 (18:31 +1100)
* 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 <comedian_vs_clown@hotmail.com>
Content.Client/Pinpointer/UI/NavMapBeaconBoundUserInterface.cs
Content.Client/Pinpointer/UI/UntrackedMapBoundUserInterface.cs [new file with mode: 0644]
Content.Shared/PAI/PAIComponent.cs
Content.Shared/PAI/SharedPAISystem.cs
Resources/Prototypes/Entities/Objects/Fun/pai.yml

index 0573d1a2db0766d6e1ff0f7313d0cf233ea9fc2b..3ebcf7cbcedb37fa1a6a759443e038a912dadaf7 100644 (file)
@@ -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 (file)
index 0000000..57965b0
--- /dev/null
@@ -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<TransformComponent>(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();
+    }
+}
index 677b0b4d485e565e517ca9cf2601ad0cde0b1103..b4e4c92735415ae141a796cdcceb4ab35e9e0c69 100644 (file)
@@ -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.
 /// </summary>
-[RegisterComponent, NetworkedComponent]
+[RegisterComponent, NetworkedComponent, AutoGenerateComponentState]
 public sealed partial class PAIComponent : Component
 {
     /// <summary>
     /// The last person who activated this PAI.
     /// Used for assigning the name.
     /// </summary>
-    [DataField("lastUser"), ViewVariables(VVAccess.ReadWrite)]
+    [DataField, ViewVariables(VVAccess.ReadWrite)]
     public EntityUid? LastUser;
 
-    [DataField("midiActionId", serverOnly: true,
-        customTypeSerializer: typeof(PrototypeIdSerializer<EntityPrototype>))]
-    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<EntityPrototype> MapActionId = "ActionPAIOpenMap";
+
+    [DataField, AutoNetworkedField]
+    public EntityUid? MapAction;
+
     /// <summary>
     /// When microwaved there is this chance to brick the pai, kicking out its player and preventing it from being used again.
     /// </summary>
-    [DataField("brickChance")]
+    [DataField]
     public float BrickChance = 0.5f;
 
     /// <summary>
     /// Locale id for the popup shown when the pai gets bricked.
     /// </summary>
-    [DataField("brickPopup")]
+    [DataField]
     public string BrickPopup = "pai-system-brick-popup";
 
     /// <summary>
     /// Locale id for the popup shown when the pai is microwaved but does not get bricked.
     /// </summary>
-    [DataField("scramblePopup")]
+    [DataField]
     public string ScramblePopup = "pai-system-scramble-popup";
 }
index 59db9dd54df8f39a76889515e416cbdef27f2ebb..d66365eb8555c9fac8caef42068812e1fb254319 100644 (file)
@@ -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);
         }
     }
 }
index b9da6775c9521fe62f12f278ab9cfdc3f415c7c1..723d74c4c88eff4ec6229158f474857b7a02cde3 100644 (file)
@@ -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
     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