using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Sirenix.OdinInspector;
using KairoEngine.Core.GameActions;
using KairoEngine.UI.InteractionHandler;
namespace KairoEngine.UI
{
///
/// Set GameActions to be run when a UI Menu buttom has been clicked
///
[HideMonoScript]
public class MenuController : MonoBehaviour, IClickHandler
{
[InlineProperty, HideLabel] public GameActionContext context = new GameActionContext();
[OnCollectionChanged("SetupActions"), PropertySpace(4,0), ListDrawerSettings(DraggableItems = false)]
public List menuActions = new List();
public void OnClick(string title)
{
for (int i = 0; i < menuActions.Count; i++)
{
if(menuActions[i].title == title) menuActions[i].Execute();
}
}
private void SetupActions()
{
for (int i = 0; i < menuActions.Count; i++)
{
if(menuActions[i] != null)
{
if(menuActions[i].actionsController != null)
{
menuActions[i].actionsController.context = context;
}
}
}
}
}
}