Firstborn/Assets/RPG Creation Kit/Scripts/BehaviourTrees/Nodes/Conditions/CBoolCheckNode.cs

48 lines
1.3 KiB
C#
Raw Permalink Normal View History

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using XNode;
using RPGCreationKit.BehaviourTree.Data;
namespace RPGCreationKit.BehaviourTree
{
[CreateNodeMenu("RPGCK_BehaviourTree/Comparison/Bool Check", order = 1)]
[System.Serializable]
public class CBoolCheckNode : BTNode
{
public bool not = false;
public BT_Bool boolToCheck;
public override void OnStart()
{
if (boolToCheck)
boolToCheck = (BT_Bool)BTReference.SolveReference(this.graph as RPGCK_BT, boolToCheck.name);
STARTED = true;
}
public override NodeState Execute()
{
if (m_NodeState == NodeState.Success || m_NodeState == NodeState.Failure)
if (hasEvaluated == true)
return m_NodeState;
if (!STARTED)
OnStart();
if(not)
m_NodeState = (boolToCheck.value) ? NodeState.Failure : NodeState.Success;
else
m_NodeState = (boolToCheck.value) ? NodeState.Success : NodeState.Failure;
hasEvaluated = true;
return m_NodeState;
}
public override void ReEvaluate()
{
if (m_NodeState != NodeState.Running)
base.ReEvaluate();
}
}
}