using System; using System.Collections.Generic; using CleverCrow.Fluid.BTs.Trees; using UnityEngine; using UnityEngine.Timeline; namespace Game { public delegate IAIObject EventCallbackCreate(); public interface IAIObject { BehaviorTree Tree(); void Create(); void Reset(GameEntity entity); void Tick(); } public partial class AIObjectBase : IAIObject where T : new() { private GameEntity _entity; private BehaviorTreeBuilder _builder; private BehaviorTree _tree; public static EventCallbackCreate GetCreator() { return () => (IAIObject)new T(); } public void Create() { _builder = new BehaviorTreeBuilder(); OnCreate(); _tree = _builder.Build(); } public void Reset(GameEntity entity) { _entity = entity; } protected virtual void OnCreate() { } public void Tick() { _tree.Tick(); } public BehaviorTree Tree() { return _tree; } } }