mirror of
https://github.com/space-wizards/RobustToolbox.git
synced 2026-02-15 03:30:53 +01:00
Network interfacedata (#5399)
If UIs are dynamically changed this fixes it.
This commit is contained in:
@@ -34,16 +34,19 @@ namespace Robust.Shared.GameObjects
|
||||
[Serializable, NetSerializable]
|
||||
internal sealed class UserInterfaceComponentState(
|
||||
Dictionary<Enum, List<NetEntity>> actors,
|
||||
Dictionary<Enum, BoundUserInterfaceState> states)
|
||||
Dictionary<Enum, BoundUserInterfaceState> states,
|
||||
Dictionary<Enum, InterfaceData> data)
|
||||
: IComponentState
|
||||
{
|
||||
public Dictionary<Enum, List<NetEntity>> Actors = actors;
|
||||
|
||||
public Dictionary<Enum, BoundUserInterfaceState> States = states;
|
||||
|
||||
public Dictionary<Enum, InterfaceData> Data = data;
|
||||
}
|
||||
}
|
||||
|
||||
[DataDefinition]
|
||||
[DataDefinition, Serializable, NetSerializable]
|
||||
public sealed partial class InterfaceData
|
||||
{
|
||||
[DataField("type", required: true)]
|
||||
@@ -65,6 +68,11 @@ namespace Robust.Shared.GameObjects
|
||||
/// </remarks>
|
||||
[DataField]
|
||||
public bool RequireInputValidation = true;
|
||||
|
||||
public InterfaceData(string type)
|
||||
{
|
||||
ClientType = type;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -300,7 +300,7 @@ public abstract class SharedUserInterfaceSystem : EntitySystem
|
||||
// I.e., don't resend the whole BUI state just because a new user opened it.
|
||||
|
||||
var actors = new Dictionary<Enum, List<NetEntity>>();
|
||||
args.State = new UserInterfaceComponent.UserInterfaceComponentState(actors, ent.Comp.States);
|
||||
args.State = new UserInterfaceComponent.UserInterfaceComponentState(actors, ent.Comp.States, ent.Comp.Interfaces);
|
||||
|
||||
// Ensure that only the player that currently has the UI open gets to know what they have it open.
|
||||
if (args.ReplayState)
|
||||
@@ -326,6 +326,17 @@ public abstract class SharedUserInterfaceSystem : EntitySystem
|
||||
if (args.Current is not UserInterfaceComponent.UserInterfaceComponentState state)
|
||||
return;
|
||||
|
||||
ent.Comp.Interfaces.Clear();
|
||||
|
||||
foreach (var data in state.Data)
|
||||
{
|
||||
ent.Comp.Interfaces[data.Key] = new(data.Value.ClientType)
|
||||
{
|
||||
InteractionRange = data.Value.InteractionRange,
|
||||
RequireInputValidation = data.Value.RequireInputValidation,
|
||||
};
|
||||
}
|
||||
|
||||
foreach (var key in ent.Comp.Actors.Keys)
|
||||
{
|
||||
if (!state.Actors.ContainsKey(key))
|
||||
|
||||
Reference in New Issue
Block a user