- add: interaction part 2
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user