修改资源

This commit is contained in:
2026-07-20 10:33:18 +08:00
parent 88fca8f9b0
commit 902afbca1c
12 changed files with 28163 additions and 28288 deletions
@@ -222,20 +222,25 @@ git commit -m "feat(enemy): 新增 EnemyLocomotion 执行器(Idle/Patrol-Wander/
### Task 3: 缓存并暴露 `EnemyBase.Locomotion`
**Files:**
- Modify: `Assets/_Game/Scripts/Enemies/EnemyBase.cs`(字段区 + Awake 缓存 + 属性)
- Modify: `Assets/_Game/Scripts/Enemies/EnemyBase.cs`(字段区 + Awake 获取 + 属性)
- [ ] **Step 1: 加字段与属性**(放在 `_movement`/`_nav` 等子系统字段旁;照抄现有序列化字段风格)
> **关键约束(已核实):** `EnemyLocomotion` 在 `BaseGames.Enemies.Navigation` 程序集,该程序集引用 `BaseGames.Enemies`;因此 `EnemyBase`(在 `BaseGames.Enemies`**不能引用具体类 `EnemyLocomotion`**(会造成循环依赖)。必须用接口 `IEnemyLocomotion`(在 `BaseGames.AI`Enemies 已引用)+ 运行时 `GetComponent` 发现——与现有 `IPathAgent _nav``EnemyBase.cs:60,568`)完全相同的模式。**不要**用 `[SerializeField]` 具体类型。
- [ ] **Step 1: 加字段与属性**(放在 `_nav`(约 `EnemyBase.cs:60`)字段旁,同 `Nav` 属性风格约 `:216`;确保文件已 `using BaseGames.AI;`
在 EnemyBase 的子系统引用区新增:
```csharp
[SerializeField] private EnemyLocomotion _locomotion;
public EnemyLocomotion Locomotion => _locomotion;
// 移动执行器(IEnemyLocomotion;由 EnemyLocomotion 在 Navigation 程序集实现)
protected IEnemyLocomotion _locomotion;
```
属性(放在 `public IPathAgent Nav => _nav;` 旁):
```csharp
public IEnemyLocomotion Locomotion => _locomotion;
```
- [ ] **Step 2: Awake 兜底获取**在现有 `_stats.Initialize` 附近,若未序列化则 GetComponent
- [ ] **Step 2: Awake 获取**紧邻 `_nav = GetComponent<IPathAgent>() ?? new NullPathAgent();`,约 `EnemyBase.cs:568`
```csharp
if (_locomotion == null) _locomotion = GetComponentInChildren<EnemyLocomotion>();
_locomotion = GetComponentInChildren<IEnemyLocomotion>(true);
```
- [ ] **Step 3: 编译门** — count=0。
@@ -252,12 +257,11 @@ git commit -m "feat(enemy): EnemyBase 缓存并暴露 Locomotion"
**Files:**
- Modify: `Assets/_Game/Scripts/Editor/Scene/SceneObjectPlacerTool.cs`PlaceE001_CaoZhi 内)
- [ ] **Step 1: 在 PlaceE001 里挂组件并绑 EnemyBase._locomotion**`using BaseGames.Enemies;` 已在文件顶部)
- [ ] **Step 1: 在 PlaceE001 里挂组件**`using BaseGames.Enemies;` 已在文件顶部)
`var brain = GetOrAddComponent<EnemyAiBrain>(go);` 之前插入:
`var brain = GetOrAddComponent<EnemyAiBrain>(go);` 之前插入`_locomotion` 由 EnemyBase.Awake 经 `GetComponentInChildren<IEnemyLocomotion>` 自动发现,**无需 AssignReference**——它非序列化字段)
```csharp
var locomotion = GetOrAddComponent<EnemyLocomotion>(go);
AssignReference(enemyBase, "_locomotion", locomotion, report);
GetOrAddComponent<EnemyLocomotion>(go);
```
- [ ] **Step 2: 编译门** — count=0。
@@ -268,9 +272,9 @@ git commit -m "feat(enemy): EnemyBase 缓存并暴露 Locomotion"
- [ ] **Step 4: 用 prefab 实例替换 TestRoomA 场景实例并保存**(保留位置;`PrefabUtility.InstantiatePrefab``EditorSceneManager.SaveScene`)。
- [ ] **Step 5: 验证 prefab 挂了 EnemyLocomotion 且 EnemyBase._locomotion 已绑**
- [ ] **Step 5: 验证 prefab 挂了 EnemyLocomotion**
`unity_execute_code`:加载 prefab,断言 `GetComponentInChildren<EnemyLocomotion>() != null` 且 EnemyBase 序列化字段 `_locomotion` 非空。期望都为真。
`unity_execute_code`:加载 prefab,断言 `root.GetComponentInChildren<BaseGames.Enemies.EnemyLocomotion>(true) != null`。(`_locomotion` 是运行时 `GetComponentInChildren` 发现的非序列化字段,故在 PlayMode(Task 5)验证 `EnemyBase.Locomotion != null`,此处只验组件存在。)
- [ ] **Step 6: 提交**
@@ -304,6 +308,8 @@ return "mode=" + loco.CurrentMode; // 期望 Approach
## P3 — AI 改绑 locomotion 意图,删协程能力/IMover
> **执行顺序调整(Unity 全程序集编译约束):** Unity 里测试程序集编译失败会阻断整个项目编译与 MCP 编译门,因此不能提交"编译红"的测试。P3 实际执行顺序改为 **Task 7 → Task 8 → Task 6 → Task 9 → 10 → 11**:先做接口切换(Task 7,含创建 FakeLocomotion 并修好现有 `AiRuntimeTests`/`FakeAiContext`),再做 `AddLocomotionState`(Task 8),最后补 `PerceptionStateMachineTests`(Task 6,此时全部类型已存在,测试应为**绿**——作为回归/特征测试,而非 red-first)。每次提交保持编译绿。
### Task 6: 编写失败测试 — PerceptionStateMachine 状态设置正确 locomotion 意图
**Files:**