更改了文件结构
This commit is contained in:
52
Src/UnityPluginsSupport/NodeCanvas/EntityBehaviourTree.cs
Normal file
52
Src/UnityPluginsSupport/NodeCanvas/EntityBehaviourTree.cs
Normal file
@@ -0,0 +1,52 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using BITKit.Entities;
|
||||
using NodeCanvas.BehaviourTrees;
|
||||
using NodeCanvas.Framework;
|
||||
using UnityEngine;
|
||||
|
||||
namespace BITKit
|
||||
{
|
||||
public class EntityBehaviourTree :EntityComponent, IHealthCallback,IEntityOverrideCallback
|
||||
{
|
||||
public BehaviourTreeOwner behaviourTree;
|
||||
[SerializeField] private Blackboard blackboard;
|
||||
|
||||
private readonly ValidHandle _allow=new();
|
||||
|
||||
public override void OnAwake()
|
||||
{
|
||||
entity.RegisterCallback<IHealthCallback>(this);
|
||||
entity.RegisterCallback<IEntityOverrideCallback>(this);
|
||||
|
||||
_allow.AddListener(OnAllow);
|
||||
}
|
||||
|
||||
public void OnSetAlive(bool alive)
|
||||
{
|
||||
_allow.SetElements(this,alive);
|
||||
blackboard.SetVariableValue("IsAlive", alive);
|
||||
}
|
||||
public void OnSetHP(int hp)
|
||||
{
|
||||
blackboard.SetVariableValue("HP", hp);
|
||||
}
|
||||
|
||||
public void OnEntryOverride(bool @override)
|
||||
{
|
||||
_allow.SetDisableElements(this,@override);
|
||||
}
|
||||
private void OnAllow(bool allow)
|
||||
{
|
||||
if (allow)
|
||||
{
|
||||
behaviourTree.StartBehaviour();
|
||||
}
|
||||
else
|
||||
{
|
||||
behaviourTree.StopBehaviour();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user