2
0
Fork 0
You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

56 lines
1.1 KiB
C#

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<T> : 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;
}
}
}