main cult

This commit is contained in:
EnefFlow
2024-01-27 15:19:52 +03:00
committed by Aviu00
parent 6310813ce6
commit 4fab8188f0
429 changed files with 12281 additions and 9 deletions

View File

@@ -0,0 +1,52 @@
using System.Linq;
using Content.Client._White.UserInterface.Radial;
using Content.Shared.White.Cult.Runes.Components;
using Content.Shared.White.Cult.UI;
using Robust.Client.GameObjects;
using Robust.Shared.Prototypes;
namespace Content.Client._White.Cult.UI.ConstructSelector;
public sealed class ConstructSelectorBui : BoundUserInterface
{
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
[Dependency] private readonly IEntityManager _entityManager = default!;
private SpriteSystem _spriteSystem = default!;
private bool _selected;
public ConstructSelectorBui(EntityUid owner, Enum uiKey) : base(owner, uiKey) { }
protected override void Open()
{
base.Open();
_spriteSystem = _entityManager.EntitySysManager.GetEntitySystem<SpriteSystem>();
var shellComponent = _entityManager.GetComponent<ConstructShellComponent>(Owner);
var shellSelector = new RadialContainer();
shellSelector.Closed += () =>
{
if(_selected) return;
SendMessage(new ConstructFormSelectedEvent(shellComponent.ConstructForms.First()));
};
foreach (var form in shellComponent.ConstructForms)
{
var formPrototype = _prototypeManager.Index<EntityPrototype>(form);
var button = shellSelector.AddButton(formPrototype.Name, _spriteSystem.GetPrototypeIcon(formPrototype).Default);
button.Controller.OnPressed += _ =>
{
_selected = true;
SendMessage(new ConstructFormSelectedEvent(form));
shellSelector.Close();
};
}
shellSelector.OpenCentered();
}
}