- add: interaction part 2

This commit is contained in:
2024-02-23 18:52:03 +03:00
parent 28c8b45eec
commit 2ec981e9e6
22 changed files with 608 additions and 79 deletions

View File

@@ -0,0 +1,40 @@
using Content.Shared._Amour.InteractionPanel;
using Robust.Client.AutoGenerated;
using Robust.Client.UserInterface.CustomControls;
using Robust.Client.UserInterface.XAML;
namespace Content.Client._Amour.InteractionPanel.UI;
[GenerateTypedNameReferences]
public sealed partial class InteractionPanelWindow : DefaultWindow
{
public event Action<string>? OnInteraction;
public InteractionPanelWindow()
{
RobustXamlLoader.Load(this);
IoCManager.InjectDependencies(this);
}
public void AddButton(string id)
{
var btn = new InteractionPanelButton();
btn.InteractionId = id;
btn.OnInteraction += _id => OnInteraction?.Invoke(_id);
Interactions.AddChild(btn);
}
public void Update(InteractionState state)
{
Interactions.Children.Clear();
TargetView.SetEntity(state.Target);
PerformerView.SetEntity(state.Performer);
foreach (var interaction in state.AvailableInteractions)
{
AddButton(interaction);
}
}
}