(client) feat:支持定义实体的碰撞体大小和偏移;建筑支持定义实体建筑和瓦片建筑,建筑支持指定按钮回调;添加存档管理器;Dev支持设置是否暂停;实体允许定义事件组;添加基地界面 (#57)

Co-authored-by: m0_75251201 <m0_75251201@noreply.gitcode.com>
Reviewed-on: http://47.107.252.169:3000/Roguelite-Game-Developing-Team/Gen_Hack-and-Slash-Roguelite/pulls/57
This commit is contained in:
2025-09-28 15:02:57 +08:00
parent 87a8abe86c
commit aff747be17
232 changed files with 39203 additions and 4161 deletions

View File

@@ -7,29 +7,42 @@ namespace AI
public abstract class JobBase
{
public Entity.Entity entity;
protected int timeoutTicks = 150;
public bool Running => timeoutTicks > 0;
protected int timeoutTicks = 180;
protected bool isCompleted = false; // 新增:表示工作是否已完成
// Running 现在可以基于 isCompleted 来判断
public bool Running => !isCompleted && timeoutTicks > 0;
public bool IsCompleted => isCompleted; // 新增:提供公共访问器
protected abstract void UpdateJob();
public virtual void StartJob(Entity.Entity target)
{
entity = target;
timeoutTicks = 180; // 重置超时,确保新工作开始时是活跃的
isCompleted = false; // 开始新工作时,重置完成状态
}
public bool Update()
{
if (!Running)
if (IsCompleted) // 如果已经完成直接返回false
return false;
if (!Running) // 如果因为超时而不再运行,则标记为完成
{
StopJob(); // 确保完成状态被设置
return false;
}
UpdateJob();
timeoutTicks--;
return true;
}
public virtual void StopJob()
{
timeoutTicks = 0;
isCompleted = true; // 显式标记工作已完成
}
// 可以添加一个方法来重置任务,以便它可以被重新使用
public virtual void ResetJob()
{
timeoutTicks = 180; // 重置超时
isCompleted = false; // 重置完成状态
entity = null; // 清除关联实体
}
}
@@ -148,7 +161,7 @@ namespace AI
private Entity.Entity FindNewHostileTarget()
{
if (!entity) return null;
return EntityManage.Instance.FindNearestEntityByRelation(
return EntityManager.Instance.FindNearestEntityByRelation(
entity.currentDimensionId, // 搜索维度ID
entity.entityPrefab, // 执行实体的Prefab ID用于关系判断
Relation.Hostile)?.entity; // 寻找敌对关系的目标
@@ -268,7 +281,7 @@ namespace AI
private Entity.Entity FindNewHostileTarget()
{
if (!entity) return null;
return EntityManage.Instance.FindNearestEntityByRelation(
return EntityManager.Instance.FindNearestEntityByRelation(
entity.currentDimensionId,
entity.entityPrefab,
Relation.Hostile)?.entity;
@@ -441,7 +454,7 @@ namespace AI
private Entity.Entity FindNearestHostileTarget()
{
if (entity == null) return null;
return EntityManage.Instance.FindNearestEntityByRelation(
return EntityManager.Instance.FindNearestEntityByRelation(
entity.currentDimensionId, // 搜索维度ID
entity.entityPrefab, // 执行实体的Prefab ID用于关系判断
Relation.Hostile)?.entity; // 寻找敌对关系的目标