Expand SharedUserInterfaceSystem API (#6342)

* Expand SharedUserInterfaceSystem API

* addr reviews
This commit is contained in:
ArtisticRoomba
2025-12-18 13:05:33 -08:00
committed by GitHub
parent a74f755692
commit 077ad1929e

View File

@@ -801,6 +801,41 @@ public abstract class SharedUserInterfaceSystem : EntitySystem
return actors.Contains(actor);
}
/// <summary>
/// Returns true if any of the specified UI keys are open for this entity by anyone.
/// </summary>
/// <param name="entity">The entity to check.</param>
/// <param name="uiKeys">The UI keys to check.</param>
/// <returns>True if any UI is open, false otherwise.</returns>
[PublicAPI]
public bool IsUiOpen(Entity<UserInterfaceComponent?> entity, IEnumerable<Enum> uiKeys)
{
if (!UIQuery.Resolve(entity.Owner, ref entity.Comp, false))
return false;
foreach (var key in uiKeys)
{
if (entity.Comp.Actors.ContainsKey(key))
return true;
}
return false;
}
/// <summary>
/// Returns true if any UI is open for this entity by anyone.
/// </summary>
/// <param name="entity">The entity to check.</param>
/// <returns>True if any UI is open, false otherwise.</returns>
[PublicAPI]
public bool IsAnyUiOpen(Entity<UserInterfaceComponent?> entity)
{
if (!UIQuery.Resolve(entity.Owner, ref entity.Comp, false))
return false;
return entity.Comp.Actors.Count > 0;
}
/// <summary>
/// Raises a BUI message locally (on client or server) without networking it.
/// </summary>