IndieGame/client/Assets/ParadoxNotion/NodeCanvas/Modules/BehaviourTrees/BehaviourTreeOwner.cs
DOBEST\zhaoyingjie f242607587 初始化工程
2024-10-11 10:12:15 +08:00

42 lines
1.6 KiB
C#

using NodeCanvas.Framework;
using UnityEngine;
namespace NodeCanvas.BehaviourTrees
{
///<summary> Use this component on a game object to behave based on a BehaviourTree.</summary>
[AddComponentMenu("NodeCanvas/Behaviour Tree Owner")]
public class BehaviourTreeOwner : GraphOwner<BehaviourTree>
{
///<summary>Should the assigned BT reset and re-execute after a cycle? Sets the BehaviourTree's repeat</summary>
public bool repeat {
get { return behaviour != null ? behaviour.repeat : true; }
set { if ( behaviour != null ) behaviour.repeat = value; }
}
///<summary>The interval in seconds to update the BT. 0 for every frame. Sets the BehaviourTree's updateInterval</summary>
public float updateInterval {
get { return behaviour != null ? behaviour.updateInterval : 0; }
set { if ( behaviour != null ) behaviour.updateInterval = value; }
}
///<summary>The last status of the assigned Behaviour Tree's root node (aka Start Node)</summary>
public Status rootStatus {
get { return behaviour != null ? behaviour.rootStatus : Status.Resting; }
}
///<summary>Ticks the assigned Behaviour Tree for this owner agent and returns it's root status</summary>
public Status Tick() {
if ( behaviour == null ) {
ParadoxNotion.Services.Logger.LogWarning("There is no Behaviour Tree assigned", LogTag.EXECUTION, gameObject);
return Status.Resting;
}
UpdateBehaviour();
return behaviour.rootStatus;
}
}
}