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 <comedian_vs_clown@hotmail.com>
This commit is contained in:
mr-bo-jangles
2024-01-06 07:31:20 +00:00
committed by GitHub
parent 46ea3b63e8
commit 412f3f470c
5 changed files with 66 additions and 10 deletions

View File

@@ -16,7 +16,6 @@ public sealed class NavMapBeaconBoundUserInterface : BoundUserInterface
protected override void Open() protected override void Open()
{ {
base.Open(); base.Open();
_window = new NavMapBeaconWindow(Owner); _window = new NavMapBeaconWindow(Owner);
_window.OpenCentered(); _window.OpenCentered();
_window.OnClose += Close; _window.OnClose += Close;

View File

@@ -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();
}
}

View File

@@ -14,38 +14,43 @@ namespace Content.Shared.PAI;
/// and there's not always enough players and ghost roles to justify it. /// and there's not always enough players and ghost roles to justify it.
/// All logic in PAISystem. /// All logic in PAISystem.
/// </summary> /// </summary>
[RegisterComponent, NetworkedComponent] [RegisterComponent, NetworkedComponent, AutoGenerateComponentState]
public sealed partial class PAIComponent : Component public sealed partial class PAIComponent : Component
{ {
/// <summary> /// <summary>
/// The last person who activated this PAI. /// The last person who activated this PAI.
/// Used for assigning the name. /// Used for assigning the name.
/// </summary> /// </summary>
[DataField("lastUser"), ViewVariables(VVAccess.ReadWrite)] [DataField, ViewVariables(VVAccess.ReadWrite)]
public EntityUid? LastUser; public EntityUid? LastUser;
[DataField("midiActionId", serverOnly: true, [DataField(serverOnly: true)]
customTypeSerializer: typeof(PrototypeIdSerializer<EntityPrototype>))] public EntProtoId? MidiActionId = "ActionPAIPlayMidi";
public string? 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; public EntityUid? MidiAction;
[DataField]
public ProtoId<EntityPrototype> MapActionId = "ActionPAIOpenMap";
[DataField, AutoNetworkedField]
public EntityUid? MapAction;
/// <summary> /// <summary>
/// When microwaved there is this chance to brick the pai, kicking out its player and preventing it from being used again. /// When microwaved there is this chance to brick the pai, kicking out its player and preventing it from being used again.
/// </summary> /// </summary>
[DataField("brickChance")] [DataField]
public float BrickChance = 0.5f; public float BrickChance = 0.5f;
/// <summary> /// <summary>
/// Locale id for the popup shown when the pai gets bricked. /// Locale id for the popup shown when the pai gets bricked.
/// </summary> /// </summary>
[DataField("brickPopup")] [DataField]
public string BrickPopup = "pai-system-brick-popup"; public string BrickPopup = "pai-system-brick-popup";
/// <summary> /// <summary>
/// Locale id for the popup shown when the pai is microwaved but does not get bricked. /// Locale id for the popup shown when the pai is microwaved but does not get bricked.
/// </summary> /// </summary>
[DataField("scramblePopup")] [DataField]
public string ScramblePopup = "pai-system-scramble-popup"; public string ScramblePopup = "pai-system-scramble-popup";
} }

View File

@@ -26,11 +26,13 @@ namespace Content.Shared.PAI
private void OnMapInit(EntityUid uid, PAIComponent component, MapInitEvent args) private void OnMapInit(EntityUid uid, PAIComponent component, MapInitEvent args)
{ {
_actionsSystem.AddAction(uid, ref component.MidiAction, component.MidiActionId); _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) private void OnShutdown(EntityUid uid, PAIComponent component, ComponentShutdown args)
{ {
_actionsSystem.RemoveAction(uid, component.MidiAction); _actionsSystem.RemoveAction(uid, component.MidiAction);
_actionsSystem.RemoveAction(uid, component.MapAction);
} }
} }
} }

View File

@@ -15,6 +15,8 @@
interfaces: interfaces:
- key: enum.InstrumentUiKey.Key - key: enum.InstrumentUiKey.Key
type: InstrumentBoundUserInterface type: InstrumentBoundUserInterface
- key: enum.StationMapUiKey.Key
type: UntrackedStationMapBoundUserInterface
- type: Sprite - type: Sprite
sprite: Objects/Fun/pai.rsi sprite: Objects/Fun/pai.rsi
layers: layers:
@@ -67,6 +69,7 @@
Off: { state: pai-off-overlay } Off: { state: pai-off-overlay }
Searching: { state: pai-searching-overlay } Searching: { state: pai-searching-overlay }
On: { state: pai-on-overlay } On: { state: pai-on-overlay }
- type: StationMap
- type: entity - type: entity
parent: PersonalAI parent: PersonalAI
@@ -138,3 +141,15 @@
icon: Interface/Actions/pai-midi.png icon: Interface/Actions/pai-midi.png
event: !type:OpenUiActionEvent event: !type:OpenUiActionEvent
key: enum.InstrumentUiKey.Key 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