using System.Text;
using Schema;
using UnityEngine;
using VOID.Generic.Objects.Unit;

namespace VOID.Generic.AI.Schema.Conditionals
{
    [DarkIcon("Conditionals/d_IsNull")]
    [LightIcon("Conditionals/IsNull")]
    [Category(SchemaCategory.CombatAnyUnit)]
    public class IsUnitTurn : Conditional
    {
        [SerializeField] public BlackboardEntrySelector<UnitObject> _unit;

        public override bool Evaluate(object nodeMemory, SchemaAgent agent)
        {
            return _unit.value && _unit.value.basicState.turnManager && _unit.value.unitState.isSelfTurn;
        }

        public override GUIContent GetConditionalContent()
        {
            var sb = new StringBuilder();
            if (invert) sb.Append("<color=red>NOT</color> ");
            sb.Append($"If its <color=red>{_unit.name}</color>'s turn");
            return new GUIContent(sb.ToString());
        }
    }
}