diff --git a/Robust.Shared/GameObjects/Systems/SharedUserInterfaceSystem.cs b/Robust.Shared/GameObjects/Systems/SharedUserInterfaceSystem.cs index 42605e24821..0e0688ce988 100644 --- a/Robust.Shared/GameObjects/Systems/SharedUserInterfaceSystem.cs +++ b/Robust.Shared/GameObjects/Systems/SharedUserInterfaceSystem.cs @@ -91,6 +91,19 @@ public override void Initialize() SubscribeLocalEvent(OnActorShutdown); } + /// + /// Enqueues a BUI command to be processed in the next Update call, + /// getting the last available state for the given UserInterfaceComponent at the last state. + /// + private void AddQueued(BoundUserInterface bui, QueuedUpdate type, Entity ent, Enum key) + { + var state = ent.Comp.States.GetValueOrDefault(key); + _queuedBuis.Add((bui, type, state)); + } + + /// + /// Enqueues a BUI command to be processed in the next Update call. + /// private void AddQueued(BoundUserInterface bui, QueuedUpdate type, BoundUserInterfaceState? state = null) { _queuedBuis.Add((bui, type, state)); @@ -292,8 +305,7 @@ private void OnUserInterfaceStartup(Entity ent, ref Comp // PlayerAttachedEvent will catch some of these. foreach (var (key, bui) in ent.Comp.ClientOpenInterfaces) { - var state = ent.Comp.States.GetValueOrDefault(key); - AddQueued(bui, QueuedUpdate.Open, state); + AddQueued(bui, QueuedUpdate.Open, ent, key); } } @@ -554,7 +566,7 @@ private void EnsureClientBui(Entity entity, Enum key, In if (!open) return; - AddQueued(boundUserInterface, QueuedUpdate.Open); + AddQueued(boundUserInterface, QueuedUpdate.Open, entity, key); } ///