(client) feat:实现实体动态创建,实体右键菜单

Co-authored-by: m0_75251201 <m0_75251201@noreply.gitcode.com>
Reviewed-on: #41
This commit is contained in:
2025-07-25 19:16:58 +08:00
parent 28ddcda9a0
commit 82dc89c890
55 changed files with 2964 additions and 747 deletions

View File

@ -8,7 +8,12 @@ namespace AI
{
public List<AIBase> children = new();
public virtual JobBase GetJob(Entity.Entity target)
public abstract JobBase GetJob(Entity.Entity target);
}
public class Selector : AIBase
{
public override JobBase GetJob(Entity.Entity target)
{
foreach (var aiBase in children)
{
@ -19,28 +24,7 @@ namespace AI
return null;
}
}
public class ContinuousMove : AIBase
{
override public JobBase GetJob(Entity.Entity target)
{
return null;
}
}
public class TrackPlayer : AIBase
{
}
public class RandomWander : AIBase
{
public override JobBase GetJob(Entity.Entity target)
{
return new WanderJob();
}
}
public class ConditionalAI : AIBase
public class ConditionalAI : Selector
{
// 条件函数,返回 true 表示满足条件
private Func<Entity.Entity, bool> condition;
@ -64,4 +48,56 @@ namespace AI
return null;
}
}
public class SequentialAI : Selector
{
private int currentIndex = 0; // 当前正在尝试的子节点索引
public override JobBase GetJob(Entity.Entity target)
{
// 如果当前索引超出了子节点范围,重置索引并返回 null
if (currentIndex >= children.Count)
{
ResetIndex();
return null;
}
// 获取当前子节点的任务
var currentChild = children[currentIndex];
var job = currentChild.GetJob(target);
// 移动到下一个子节点
currentIndex++;
return job;
}
// 重置当前索引(用于重新开始遍历)
private void ResetIndex()
{
currentIndex = 0;
}
}
public class ContinuousMove : AIBase
{
public override JobBase GetJob(Entity.Entity target)
{
return new MoveJob();
}
}
public class TrackPlayer : AIBase
{
public override JobBase GetJob(Entity.Entity target)
{
throw new NotImplementedException();
}
}
public class RandomWander : AIBase
{
public override JobBase GetJob(Entity.Entity target)
{
return new WanderJob();
}
}
}