Implement Intrinsic UIs (#6926)
* Implement Intrinsic UIs, allowing the admin ghost to double as a computer. * ignore moment * remove debug statement, sort the actions. * ffs * didn't ever use this and don't need to, removed. * rm dead code * lil bit of commenting.
This commit is contained in:
56
Content.Server/UserInterface/IntrinsicUIComponent.cs
Normal file
56
Content.Server/UserInterface/IntrinsicUIComponent.cs
Normal file
@@ -0,0 +1,56 @@
|
||||
using Content.Shared.Actions.ActionTypes;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Server.GameObjects;
|
||||
using Robust.Shared.Reflection;
|
||||
using Robust.Shared.Serialization;
|
||||
|
||||
namespace Content.Server.UserInterface;
|
||||
|
||||
[RegisterComponent]
|
||||
public sealed class IntrinsicUIComponent : Component, ISerializationHooks
|
||||
{
|
||||
/// <summary>
|
||||
/// List of UIs and their actions that this entity has.
|
||||
/// </summary>
|
||||
[ViewVariables, DataField("uis", required: true)]
|
||||
public List<IntrinsicUIEntry> UIs = new();
|
||||
|
||||
void ISerializationHooks.AfterDeserialization()
|
||||
{
|
||||
foreach (var ui in UIs)
|
||||
{
|
||||
ui.AfterDeserialization();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[DataDefinition]
|
||||
public struct IntrinsicUIEntry
|
||||
{
|
||||
[ViewVariables]
|
||||
public Enum? Key { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The BUI key that this intrinsic UI should open.
|
||||
/// </summary>
|
||||
[DataField("key", readOnly: true, required: true)]
|
||||
private string _keyRaw = default!;
|
||||
|
||||
/// <summary>
|
||||
/// The action used for this BUI.
|
||||
/// </summary>
|
||||
[DataField("toggleAction", required: true)]
|
||||
public InstantAction ToggleAction = new();
|
||||
|
||||
public void AfterDeserialization()
|
||||
{
|
||||
var reflectionManager = IoCManager.Resolve<IReflectionManager>();
|
||||
if (reflectionManager.TryParseEnumReference(_keyRaw, out var key))
|
||||
Key = key;
|
||||
|
||||
if (ToggleAction.Event is ToggleIntrinsicUIEvent ev)
|
||||
{
|
||||
ev.Key = Key;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user