Firstborn/Assets/RPG Creation Kit/Scripts/BehaviourTrees/Nodes/Execution/AI_ChangeSteeringBehaviour.cs

68 lines
1.7 KiB
C#
Raw Normal View History

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using XNode;
using RPGCreationKit.BehaviourTree;
using RPGCreationKit.AI;
namespace RPGCreationKit.BehaviourTree
{
/// <summary>
/// Changes the Steering Behaviour of this AI
/// </summary>
[CreateNodeMenu("RPGCK_BehaviourTree/Actions/AI/Change Steering Behaviour", order = 1)]
[System.Serializable]
public class AI_ChangeSteeringBehaviour : BTNode
{
RckAI thisAI;
public SteeringBehaviours behaviour;
// Use this for initialization
protected override void Init()
{
base.Init();
}
// Return the correct value of an output port when requested
public override object GetValue(NodePort port)
{
return null; // Replace this
}
public override NodeState Execute()
{
if (m_NodeState == NodeState.Success || m_NodeState == NodeState.Failure)
if (hasEvaluated == true)
return m_NodeState;
if (!STARTED)
OnStart();
thisAI.selectedSteeringBehaviour = behaviour;
m_NodeState = NodeState.Success;
hasEvaluated = true;
return m_NodeState;
}
public override void OnRemoveConnection(NodePort port)
{
base.OnRemoveConnection(port);
indexInSequence = -1;
}
public override void OnStart()
{
thisAI = (this.graph as RPGCK_BT).ai;
STARTED = true;
}
public override void ReEvaluate()
{
if (m_NodeState != NodeState.Running)
base.ReEvaluate();
}
}
}