Refactor actions to be entities with components (#19900)
This commit is contained in:
23
Content.Shared/UserInterface/OpenUiActionEvent.cs
Normal file
23
Content.Shared/UserInterface/OpenUiActionEvent.cs
Normal file
@@ -0,0 +1,23 @@
|
||||
using Content.Shared.Actions;
|
||||
using Robust.Shared.Reflection;
|
||||
using Robust.Shared.Serialization;
|
||||
|
||||
namespace Content.Shared.UserInterface;
|
||||
|
||||
public sealed partial class OpenUiActionEvent : InstantActionEvent, ISerializationHooks
|
||||
{
|
||||
[ViewVariables]
|
||||
public Enum? Key { get; private set; }
|
||||
|
||||
[DataField("key", required: true)]
|
||||
private string _keyRaw = default!;
|
||||
|
||||
void ISerializationHooks.AfterDeserialization()
|
||||
{
|
||||
var reflectionManager = IoCManager.Resolve<IReflectionManager>();
|
||||
if (reflectionManager.TryParseEnumReference(_keyRaw, out var key))
|
||||
Key = key;
|
||||
else
|
||||
Logger.Error($"Invalid UI key ({_keyRaw}) in open-UI action");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user