Files
AIC-Project/Tools/PcMiniGameSmoke/README.md
T
2026-07-10 10:24:29 +08:00

62 lines
2.8 KiB
Markdown

# PC MiniGame Smoke
This smoke path verifies the C# lobby-to-hot-update-minigame flow on PC: enter the C# lobby,
request the server game list, random-match a discovered game, download the minigame package from
the local CDN, load its AssetBundle, play `rps` (rock-paper-scissors), and exit on `RoomEnd`.
## Build Package
> 旧脚本 `Build-PcMiniGameSmoke.ps1` 已废弃并删除。
>
> 其产物是裸 `.bytes` 直下格式(`server/games/...`、`client/minigame/...`),运行时不再支持——
> 客户端与服务器现已统一走 AssetBundle,而 ps1 无法打 AssetBundle。
本地打包/联调改用 Unity 菜单 **`XWorld/生成小游戏更新`**,它会同时产出客户端与服务器两侧的统一 AB:
- 客户端产物 → `CDN/minigame/<id>/<ver>/<platform>/`
- 服务器产物 → `deploy/minigame/<id>/<ver>/`
### 运行中热更(发布即生效)
网关支持运行中热更小游戏,**不做启动期存在性检测**:`deploy/minigame` 为空也照常启动
(游戏列表每次请求实时重扫目录,建房时才按需加载 DLL)。运行中随时用菜单发布新游戏
或新版本,客户端重新拉列表即可见,无需重启网关。
**同版本覆盖重发也支持**:服务器 DLL 为字节加载(不锁文件),覆盖落位总能成功;
网关按磁盘内容指纹自动失效——下一个新房间即用新代码,已入房玩家打完旧代码后旧模块自动卸载。
(生产环境仍建议版本号递增,便于客户端 AB 与服务器 DLL 的版本对应关系可追溯。)
## Start Gateway / CDN
Editor Play 会自动拉起本地网关与 CDN(见 `Client/Assets/Script/Editor/XWorldUtil.cs`):
- 本地网关 `Gateway.Runner``--gamesRoot` 已指向仓库根的 `deploy/minigame`
- CDN 服务 `Cdn.Runner --root <仓库>/CDN`,覆盖 `CDN/minigame/`(以及旧全量热更 `CDN/XWorld/<platform>/`),
监听 `http://127.0.0.1:15081/`
也可用 Unity 菜单 `XWorld/Server/Open Local Server (All)` 手动启动,或直接命令行:
```powershell
dotnet Server\Gateway.Runner\bin\Debug\net10.0\XWorld.Server.Gateway.Runner.dll --gamesRoot "D:\UD\AI\AIC#Project\deploy\minigame" --port 5005 --tickMs 100 --matchTimeoutTicks 150
```
WebSocket URL:
```text
ws://127.0.0.1:5005/ws?pid=1
```
## Run Unity Client
In the Unity Editor, use menu `XWorld/PC Smoke/Create Lobby Flow Launcher`, then press Play.
`XWorld/PC Smoke/Create MiniGame Smoke Launcher` is still available for direct single-game debugging.
Expected flow:
```text
Lobby GameListRequest -> RandomMatchRequest -> MatchAssigned rps -> download rps package (AssetBundle) -> load -> MatchFound(+AI) -> rock-paper-scissors snapshots -> RoomEnd -> return lobby
```
The default runner settings use `tickMs=100` and `matchTimeoutTicks=150`, so a single real player is
AI-filled after a few seconds.