This commit is contained in:
2026-08-17 18:18:13 +08:00
parent 5765f411e9
commit d2cd3b9fa8
188 changed files with 32929 additions and 2 deletions
@@ -0,0 +1,50 @@
# Mod 开发
## 公共接口
纯规则层位于 `ReplacedPerson.Core`,可在 Unity 和 .NET 8 独服中使用:
- `IReplacedPersonMod`
- `IReplacedPersonRegistry`
- `IReplacedPersonEffectResolver`
- `ReplacedPersonModManifest`
可注册卡牌、结束牌、敌人、奖励、剧情、规则效果和命令。联网规则不得依赖 Unity 类型。Unity 适配层通过 ShrinkModFramework 生命周期把规则实现注册到 `replaced-person.mods``AutoApplyHarmonyPatches` 应保持关闭。
## 审计训练 Mod
示例位于 `Assets/Demos/ReplacedPerson/Mods/ExampleGreedMod/`,包含:
- 普通牌“审计”:反击类型,触发正式效果解析器后恢复 1 COST。
- 训练敌人“训练用审计员”。
- 奖励、短剧情和 `example audit` 命令。
- 纯规则程序集和可选 Unity 适配程序集。
- 内容 JSON、PNG 图标和严格文件哈希清单。
构建并打包:
```powershell
./GeneratedServers/ExampleGreedMod.Rules/pack-mod.ps1
```
输出:
```text
Artifacts/ReplacedPersonMods/ExampleGreedMod-1.0.0.zip
GeneratedServers/ReplacedPerson.ServerHost/Mods/ExampleGreedMod/
```
## 包结构
```text
ExampleGreedMod/
manifest.json
content.json
icon.png
ExampleGreedMod.Rules.dll
ExampleGreedMod.Unity.dll # 可选,仅 Unity 端需要
```
`manifest.json``files` 必须覆盖包内所有参与联网兼容判断的文件,并写入小写 SHA-256。独服启动时先校验文件,再加载纯规则 DLL;当前房间保留不可变内容快照,`reload-mods` 只影响之后创建的房间。
不可信 DLL 不在本 Demo 的安全边界内。服务器管理员只应安装可信来源的规则程序集。