diff --git a/TODO.md b/TODO.md index 71ce5e2..7e72988 100644 --- a/TODO.md +++ b/TODO.md @@ -1,27 +1,58 @@ -# GeometryTD 三层拆分迁移 TODO +# GeometryTD 三层拆分迁移 TODO(边界纠偏版) -最后更新:2026-05-09 +最后更新:2026-05-12 > **2026-04-30 第一波完成**:Definition/Enum + Event > **2026-04-30 第二波完成**:Vector3/Mathf 替换,AttackPayload/HitContext 迁移 -> **2026-05-01 第三波完成**:IDataRow 实现、TagRow/RarityTagBudgetRow、TagGenerationRuleRegistry 重构 +> **2026-05-01 第三波完成**:IDataRow 实现、TagRow/RarityTagBudgetRow、TagGenerationRuleRegistry 重构(**现已判定为过渡态方案,非目标边界**) > **2026-05-09 状态校准**:同步仓库实况,补记已落地的 DataStruct / UI/Base / Entity / BinaryReaderExtension,并修正 TagRuntimeUtility 路径与各小节计数 +> **2026-05-10 第四波进行中(1.1)**:迁移 BackpackInventoryData / EventItem / EventOption / TowerStatsData、CombatParticipantTowerValidation*、ParticipantTowerAssignResult(含依赖 TowerItemData) +> **2026-05-12 边界纠偏**:明确 L0 不依赖 GameFramework/Unity;DataTable 解析、二进制反序列化、IDataRow/DR* 统一归 L1;此前已迁但越界项标记为“过渡态待下沉” + +--- + +## 分层判定基线(本文件后续统计以此为准) + +### L0(Domain,纯业务) + +- 允许:业务实体、值对象、规则服务、领域枚举、领域事件、纯数据模型 +- 禁止: + - `UnityEngine.*` + - `UnityGameFramework.*` + - `GameFramework.*` + - `IDataRow` / `DataRowBase` + - `ParseDataRow(string/byte[])`、`BinaryReader/BinaryWriter` 解析细节 + +### L1(Infrastructure,技术适配) + +- 承接:DataTable、序列化/反序列化、配置读取、框架适配、桥接/映射 +- 允许依赖:`GameFramework.*`、`UnityGameFramework.*` +- 可不依赖 UnityEngine(仍属 L1,不属于 L0) + +### L2(Presentation,表现层) + +- 承接:UI/View、Scene、`MonoBehaviour`、`UGuiForm`、Unity 运行时流程 + +### 过渡态定义 + +- 若文件“物理位置”在 `GeometryTD.Domain`,但语义属于 L1(例如 `IDataRow`、二进制解析),统一标记为:**过渡态待下沉 L1** ## 概述 | 指标 | 数量 | 状态 | |------|------|------| | 总文件数 | 457 | - | -| L0 (Domain) 可直接迁移 | ~180 | **当前已落地 100+ 项(以本文件勾选和波次记录为准)** | -| L1 (Infrastructure) 需重构 | ~80 | **项目已建,承接内容仍少** | -| L2 (Presentation) Unity 依赖 | ~197 | **项目骨架已建,UI 五层迁移待展开** | +| 阶段一清单(L0 候选) | 235 | **已勾选 111 / 未勾选 124(按本文件当前勾选)** | +| Domain 当前 .cs 文件数 | 119 | **其中含“过渡态待下沉 L1”文件(如 DataTable Row/Parser)** | +| Infrastructure 当前 .cs 文件数 | 3 | **承接明显不足,需补 DR*/Parser/Bridge** | +| Presentation 当前 .cs 文件数 | 1 | **仅项目骨架,UI 五层迁移待展开** | ## 项目骨架 ``` src/ ├── GeometryTD.Domain/ # L0 - 纯净 C#(当前迁移主战场) -│ ├── DataTable/ # IDataRow 实现 + 纯 C# BinaryReaderExtension +│ ├── DataTable/ # 当前含过渡态(目标下沉至 L1) │ ├── Definition/ │ ├── Event/ │ └── UI/Base/ # IUIFormController / IUIUseCase / UIContext @@ -33,9 +64,9 @@ src/ --- -## 阶段一:L0 直接迁移(无需修改) +## 阶段一:L0 直接迁移(纯业务,不引入框架依赖) -以下文件可直接复制到 `GeometryTD.Domain/`,无任何修改。 +以下文件原则上可迁移到 `GeometryTD.Domain/`;若引入框架解析职责,改归 L1。 ### Definition/Enum(27 个文件) @@ -69,25 +100,26 @@ src/ > ⚠️ 注:原 TODO 统计 25 个 Enum 文件,实际源文件 23 个。第一波新增 4 个枚举从其他层迁移:CombatSelectActionType(UI层)、RunNodeType/RunNodeStatus/RunNodeCompletionStatus(Procedure层) -### Definition/DataStruct(10 个文件) +### Definition/DataStruct(11 个文件) - [x] `Definition/DataStruct/AttackPayload.cs` ⚠️ **已迁移** - Vector3 → System.Numerics.Vector3 - [x] `Definition/DataStruct/HitContext.cs` ⚠️ **已迁移** - Vector3 → System.Numerics.Vector3,TargetStatusRuntime 已恢复 -- [ ] `Definition/DataStruct/BackpackInventoryData.cs` +- [x] `Definition/DataStruct/BackpackInventoryData.cs` ✅ **已迁移** - 背包聚合数据 - [x] `Definition/DataStruct/BuildInfo.cs` ✅ **已迁移** - 纯数据对象 -- [ ] `Definition/DataStruct/EventItem.cs` -- [ ] `Definition/DataStruct/EventOption.cs` +- [x] `Definition/DataStruct/EventItem.cs` ✅ **已迁移** - 事件条目模型 +- [x] `Definition/DataStruct/EventOption.cs` ✅ **已迁移** - 事件选项模型 - [x] `Definition/DataStruct/ImpactData.cs` ✅ **已迁移** - 纯结构体 - [x] `Definition/DataStruct/TowerCompItemData.cs` ✅ **已迁移** - 背包组件实例模型 -- [ ] `Definition/DataStruct/TowerStatsData.cs` +- [x] `Definition/DataStruct/TowerStatsData.cs` ✅ **已迁移** - 塔属性快照 +- [x] `Definition/DataStruct/TowerItemData.cs` ✅ **已迁移** - 作为 1.1 依赖补迁(移除 Sprite/JsonIgnore) - [x] `Definition/DataStruct/VersionInfo.cs` ✅ **已迁移** - 纯数据对象 ### Definition/ 其他 -- [ ] `Definition/CombatParticipantTowerValidation.cs` -- [ ] `Definition/CombatParticipantTowerValidationText.cs` +- [x] `Definition/CombatParticipantTowerValidation.cs` ✅ **已迁移** - 参战塔校验服务 +- [x] `Definition/CombatParticipantTowerValidationText.cs` ✅ **已迁移** - 校验结果文案 - [ ] `Definition/InventoryRarityRuleService.cs` -- [ ] `Definition/ParticipantTowerAssignResult.cs` +- [x] `Definition/ParticipantTowerAssignResult.cs` ✅ **已迁移** - 参战分配结果模型 ### Event(35 个文件) @@ -153,8 +185,8 @@ src/ - [ ] `Definition/Tag/Combat/TagEffectResolver.cs` - [x] `Definition/Tag/Generation/TagGenerationRule.cs` ✅ **已迁移** - 纯 C# - [x] `Definition/Tag/Generation/RarityTagBudgetRule.cs` ✅ **已迁移** - 纯 C# -- [x] `Definition/Tag/Generation/TagGenerationRuleRegistry.cs` ✅ **已重构** - 使用 IEnumerable -- [x] `Definition/Tag/Generation/RarityTagBudgetRuleRegistry.cs` ✅ **已重构** - 使用 IEnumerable +- [x] `Definition/Tag/Generation/TagGenerationRuleRegistry.cs` ✅ **已重构** - 当前使用 `IEnumerable`(**过渡态待后续改为 L1 输入模型/Mapper**) +- [x] `Definition/Tag/Generation/RarityTagBudgetRuleRegistry.cs` ✅ **已重构** - 当前使用 `IEnumerable`(**过渡态待后续改为 L1 输入模型/Mapper**) - [ ] `Definition/Tag/Generation/ComponentTagGenerationService.cs` - 依赖 InventoryTagRandomContext - [ ] `Definition/Tag/Generation/InventoryTagRandomContext.cs` - [x] `Definition/Tag/Metadata/Config/AbsoluteZeroTagConfig.cs` ⚠️ **已迁移** - 无 Unity 依赖 @@ -178,11 +210,11 @@ src/ - [ ] `Definition/Event/EventEffect/AddGoldEffect.cs` - [ ] `Definition/Event/EventEffect/AddRandomCompsEffect.cs` - [ ] `Definition/Event/EventEffect/DamageRandomTowerEnduranceEffect.cs` -- [ ] `Definition/Event/EventEffect/EventEffectBase.cs` +- [x] `Definition/Event/EventEffect/EventEffectBase.cs` ✅ **已迁移** - 为 EventOption 提供基础类型 - [ ] `Definition/Event/EventEffect/RemoveRandomCompEffect.cs` - [ ] `Definition/Event/EventOptionExecutor.cs` - [ ] `Definition/Event/EventRequirement/CompCountAtLeastRequirement.cs` -- [ ] `Definition/Event/EventRequirement/EventRequirementBase.cs` +- [x] `Definition/Event/EventRequirement/EventRequirementBase.cs` ✅ **已迁移** - 为 EventOption 提供基础类型 - [ ] `Definition/Event/EventRequirement/GoldAtLeastRequirement.cs` - [ ] `Definition/Event/EventRequirement/HasRelicRequirement.cs` - [ ] `Definition/Event/EventRequirement/TowerCountAtLeastRequirement.cs` @@ -322,7 +354,9 @@ src/ --- -## 阶段二:L1 重构迁移(需修改后迁移) +## 阶段二:L1 重构迁移(技术适配层) + +> 说明:以下能力全部归 L1,不再计入 L0 完成率。 ### 策略 1:Vector3 替换 @@ -343,9 +377,10 @@ src/ | `Utility/AssetUtility.cs` | `GameEntry.*` → 注入服务 | | `Utility/JsonNetUtility.cs` | `GameFramework.Utility.Json` → 注入 | -### 策略 3:DataTable 保持 L1 +### 策略 3:DataTable / Row 解析统一归 L1 -多数 DR* 类继承 `UnityGameFramework.Runtime.DataRowBase`,留在 L1;`BinaryReaderExtension` 当前已在 Domain 提供纯 C# 版本: +多数 DR* 类继承 `UnityGameFramework.Runtime.DataRowBase`,留在 L1。 +`BinaryReaderExtension/BinaryExtension`(含 `Read7BitEncodedInt32`)属于二进制解析能力,归 L1。 - [ ] `DataTable/DREnemy.cs` - [ ] `DataTable/DRLevel.cs` @@ -367,7 +402,10 @@ src/ - [ ] `DataTable/DRUIForm.cs` - [ ] `DataTable/DRUISound.cs` - [ ] `DataTable/DataTableExtension.cs`(含 Vector3/Color 解析) -- [x] `DataTable/BinaryReaderExtension.cs` ✅ **已迁移到 Domain** - 使用纯 C# `Color` / `Color32` / `Rect` struct 替代 Unity 类型 +- [ ] `DataTable/BinaryReaderExtension.cs`(L1) +- [ ] `DataTable/BinaryExtension.cs`(L1,7bit 编码/加密字符串) +- [ ] `DataTable/TagRow.cs`(过渡态待下沉 L1:当前包含 `IDataRow + ParseDataRow`) +- [ ] `DataTable/RarityTagBudgetRow.cs`(过渡态待下沉 L1:当前包含 `IDataRow + ParseDataRow`) ### 策略 4:Tilemap 接口抽象 @@ -558,27 +596,28 @@ src/ ## 关键依赖链 ``` -L0 迁移阻塞链: -├── TagDefinitionRegistry (L1 重构) ──→ DR* (L1) ──→ DataTableExtension (L1) -├── AttackPayload (L1 重构) ──→ TagEffectResolver (L1 重构) -└── MapTopologyService (L1 重构) ──→ EntityData (L2) +L0/L1 边界阻塞链(纠偏后): +├── 领域规则(L0)依赖输入模型,但不依赖 IDataRow/二进制解析 +├── IDataRow/ParseDataRow/7bit 读取必须下沉至 L1(DR*/Bridge/Mapper) +└── L2 通过 L1 获取领域可用模型,不直接触达底层表解析 -三层拆分新架构(2026-05-01): -├── L0: IDataRow 实现(TagRow, RarityTagBudgetRow) -│ └── Registry 使用 IEnumerable 而非 DRTag -└── L1: DR* : DataRowBase + L0 实例成员 - └── Bridge: UGF DataTableComponent → L0 IDataRow +三层拆分目标架构(2026-05-12 校准后): +├── L0: 纯领域模型/规则(不实现 IDataRow,不包含 ParseDataRow) +├── L1: DR* / Parser / Bridge / Mapper +│ └── Bridge: UGF DataTableComponent → L0 领域模型 +└── L2: Unity 运行时/表现层编排 ``` ### 重构优先级 1. **第一波**:Definition/Enum + Event ✅ 已完成 2. **第二波**:Vector3 → System.Numerics.Vector3,Mathf → System.Math ✅ **已完成** -3. **第三波**:IDataRow 实现、TagRow/RarityTagBudgetRow、TagGenerationRuleRegistry ✅ **已完成** -4. **第四波**:L1 DR* 包装类 + Bridge 实现(UGF DataTable → L0 IDataRow) -5. **第五波**:GameEntry 静态调用 → 接口注入 -6. **第六波**:Tilemap 接口抽象 -7. **第七波**:剩余 L1 文件迁移 +3. **第三波**:IDataRow 实现、TagRow/RarityTagBudgetRow、TagGenerationRuleRegistry ✅ **已完成(历史完成项,现已纠偏为过渡态)** +4. **第四波**:边界纠偏(已开始)——识别并标记 L0 中越界项为“过渡态待下沉” +5. **第五波**:L1 DR* + Parser + Bridge(UGF DataTable → L0 领域模型) +6. **第六波**:GameEntry 静态调用 → 接口注入(L1/L2) +7. **第七波**:Tilemap/Color 等 Unity 细节抽象(L1/L2) +8. **第八波**:清理过渡态,实现 L0 零框架依赖 --- @@ -590,9 +629,9 @@ L0 迁移阻塞链: |------|----------|--------|--------| | Definition/Enum | 23 | 27* | 100%+ | | Event | 35 | 35 | 100% | -| **小计** | **58** | **62** | **~34% of L0** | +| **小计** | **58** | **62** | **~34% of L0(按当时旧口径统计)** | -> *注:Enum 源文件23个,第一波新增4个枚举从其他层迁移,故总计27个。L0总约180个文件。 +> *注:Enum 源文件23个,第一波新增4个枚举从其他层迁移,故总计27个。`L0 总约180个文件` 为当时旧口径估算,**已不作为 2026-05-12 后的边界统计依据**。 ### 新增文件 @@ -656,25 +695,29 @@ L0 迁移阻塞链: ### 概述 -采用新架构:L0 实现 `IDataRow` 接口,L1 提供 `DataRowBase` 包装类。 +当时采用方案:L0 实现 `IDataRow` 接口,L1 提供 `DataRowBase` 包装类。 +**该方案已在 2026-05-12 边界纠偏后降级为“过渡态”**(原因:`IDataRow/ParseDataRow` 属于 L1 技术适配职责)。 ``` -L0: TagRow : IDataRow ← 纯 C# 解析逻辑 -L1: DRTag : DataRowBase ← UGF 兼容层,内部持有 TagRow 实例 - └── DRTag.ParseDataRow() 委托给 TagRow.ParseDataRow() -Bridge: DataTableComponent ← 将 UGF 数据转换为 L0 Row 集合 +[过渡态] +L0(当前物理位置): TagRow : IDataRow +L1(目标归位): DRTag/DataTableBridge/Parser + +[目标态] +L0: 纯领域模型(不实现 IDataRow,不含 ParseDataRow) +L1: DataTable 解析 + 映射到 L0 模型 ``` ### 新增文件 | 文件 | 说明 | |------|------| -| `DataTable/TagRow.cs` | 实现 `IDataRow`,含 TagId, TagType, MinRarity, Weight, IsImplemented | -| `DataTable/RarityTagBudgetRow.cs` | 实现 `IDataRow`,含 Id, Rarity, MinCount, MaxCount | +| `DataTable/TagRow.cs` | 现状:实现 `IDataRow`(**过渡态待下沉 L1**) | +| `DataTable/RarityTagBudgetRow.cs` | 现状:实现 `IDataRow`(**过渡态待下沉 L1**) | | `Definition/Tag/Generation/TagGenerationRule.cs` | 从 src-ref 迁移 | | `Definition/Tag/Generation/RarityTagBudgetRule.cs` | 从 src-ref 迁移 | -| `Definition/Tag/Generation/TagGenerationRuleRegistry.cs` | 重构为使用 `IEnumerable` | -| `Definition/Tag/Generation/RarityTagBudgetRuleRegistry.cs` | 重构为使用 `IEnumerable` | +| `Definition/Tag/Generation/TagGenerationRuleRegistry.cs` | 重构为使用 `IEnumerable`(**现视为过渡态依赖**) | +| `Definition/Tag/Generation/RarityTagBudgetRuleRegistry.cs` | 重构为使用 `IEnumerable`(**现视为过渡态依赖**) | ### L0 构建状态 @@ -684,7 +727,7 @@ Bridge: DataTableComponent ← 将 UGF 数据转换为 L0 Row 集合 - [ ] `DataTable/DRTag : DataRowBase` — 包装 TagRow - [ ] `DataTable/DRRarityTagBudget : DataRowBase` — 包装 RarityTagBudgetRow -- [ ] `Bridge/DataTableBridge` — UGF DataTableComponent → L0 Row 集合 +- [ ] `Bridge/DataTableBridge` — UGF DataTableComponent → L0 领域模型集合 ---