Predict IntrinsicUI (#31310)

This commit is contained in:
metalgearsloth
2024-08-23 03:03:05 +10:00
committed by GitHub
parent 6a549ceee4
commit 7e2de7937f
2 changed files with 13 additions and 16 deletions

View File

@@ -1,9 +1,9 @@
using Robust.Shared.Prototypes;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
using Robust.Shared.GameStates;
using Robust.Shared.Prototypes;
namespace Content.Server.UserInterface;
namespace Content.Shared.UserInterface;
[RegisterComponent]
[RegisterComponent, NetworkedComponent]
public sealed partial class IntrinsicUIComponent : Component
{
/// <summary>
@@ -15,8 +15,8 @@ public sealed partial class IntrinsicUIComponent : Component
[DataDefinition]
public sealed partial class IntrinsicUIEntry
{
[DataField("toggleAction", customTypeSerializer: typeof(PrototypeIdSerializer<EntityPrototype>), required: true)]
public string? ToggleAction;
[DataField("toggleAction", required: true)]
public EntProtoId? ToggleAction;
/// <summary>
/// The action used for this BUI.

View File

@@ -1,14 +1,11 @@
using Content.Server.Actions;
using Content.Shared.UserInterface;
using Robust.Server.GameObjects;
using Robust.Shared.Player;
using Content.Shared.Actions;
namespace Content.Server.UserInterface;
namespace Content.Shared.UserInterface;
public sealed class IntrinsicUISystem : EntitySystem
{
[Dependency] private readonly ActionsSystem _actionsSystem = default!;
[Dependency] private readonly UserInterfaceSystem _uiSystem = default!;
[Dependency] private readonly SharedActionsSystem _actionsSystem = default!;
[Dependency] private readonly SharedUserInterfaceSystem _uiSystem = default!;
public override void Initialize()
{
@@ -32,9 +29,9 @@ public sealed class IntrinsicUISystem : EntitySystem
}
}
public bool InteractUI(EntityUid uid, Enum key, IntrinsicUIComponent? iui = null, ActorComponent? actor = null)
public bool InteractUI(EntityUid uid, Enum key, IntrinsicUIComponent? iui = null)
{
if (!Resolve(uid, ref iui, ref actor))
if (!Resolve(uid, ref iui))
return false;
var attempt = new IntrinsicUIOpenAttemptEvent(uid, key);
@@ -42,7 +39,7 @@ public sealed class IntrinsicUISystem : EntitySystem
if (attempt.Cancelled)
return false;
return _uiSystem.TryToggleUi(uid, key, actor.PlayerSession);
return _uiSystem.TryToggleUi(uid, key, uid);
}
}