Files

67 lines
1.9 KiB
C#
Raw Permalink Normal View History

2024-01-27 15:19:52 +03:00
using Content.Client._White.UserInterface.Radial;
2023-11-15 19:15:07 +03:00
using Content.Shared.Actions;
using Content.Shared._White.Cult;
using Content.Shared._White.Cult.Components;
2024-01-27 15:19:52 +03:00
using Robust.Client.Utility;
2023-11-15 19:15:07 +03:00
using Robust.Shared.Prototypes;
using Robust.Shared.Utility;
2024-01-29 01:02:37 +07:00
using CultistComponent = Content.Shared._White.Cult.Components.CultistComponent;
2024-01-27 15:19:52 +03:00
namespace Content.Client._White.Cult.UI.SpellSelector;
public sealed class SpellSelectorBUI : BoundUserInterface
{
private RadialContainer? _radialContainer;
public SpellSelectorBUI(EntityUid owner, Enum uiKey) : base(owner, uiKey)
{
IoCManager.InjectDependencies(this);
}
protected override void Open()
{
base.Open();
_radialContainer = new RadialContainer();
_radialContainer.Closed += Close;
2023-11-15 19:15:07 +03:00
var protoMan = IoCManager.Resolve<IPrototypeManager>();
2024-01-27 15:19:52 +03:00
foreach (var action in CultistComponent.CultistActions)
{
2023-11-15 19:15:07 +03:00
if (!protoMan.TryIndex(action, out var proto))
continue;
SpriteSpecifier? icon;
if (action.StartsWith("InstantAction") && proto.TryGetComponent(out InstantActionComponent? instantComp))
icon = instantComp.Icon;
else
{
if (!proto.TryGetComponent(out EntityTargetActionComponent? targetComp))
continue;
icon = targetComp.Icon;
}
if (icon == null)
continue;
2023-11-16 15:16:27 +03:00
var texture = icon.Frame0();
var button = _radialContainer.AddButton(proto.Name, texture);
2024-01-27 15:19:52 +03:00
button.Controller.OnPressed += _ =>
{
SendMessage(new CultEmpowerSelectedBuiMessage(action));
Close();
};
}
_radialContainer.OpenAttachedLocalPlayer();
}
protected override void Dispose(bool disposing)
{
base.Dispose(disposing);
_radialContainer?.Close();
}
}