Files
2026-08-28 19:44:46 +08:00

3.2 KiB
Raw Permalink Blame History

2026-08-27

「一切皆模组」设计理解修正(关键)

  • 用户纠正方向:目标是多玩家联机,核心抽象是 GameModule(封装网络层在 GamingQueue 上的"游戏模式模组"),c/s/IModule 只是内容层。
  • 研读参考:FunGame.Core v2 分支(IGameModule/IGameModuleServer/GameModule/GameModuleServer/GameModuleDepend/GamingObject/GameModuleLoader/ExampleGameModule)与旧版 C:\milimoe\fungame.server(ServerModel 把 SocketMessageType.Gaming 路由到 NowGamingServer.GamingMessageHandler,switch-case 处理 GamingType,结果 Send 回客户端)。
  • 确认 v3 现状:IServerPlugin.HandleGamingMessage 是 v2 GamingMessageHandler 的薄版;gaming.action 未接路由;IGameSession 已暴露 Queue/Clients/CustomData。

Phase 0 GameModule 落地(编译 0 错误,冒烟 OK)

  • Contracts:新增 IGameModuleServer(Id/Dependencies/DefaultMap/RoomType/MaxUsers/StartGameAsync/HandleGamingMessageAsync,GamingType/RoomType 复用 Core Library/Constant/TypeEnum)、GameModuleDepend(内容依赖前缀);扩展 IGameSession(Characters/BroadcastAsync/EndGameAsync)。
  • modules/FunGame.Server.Modules.Melee:MeleeGameModuleServer 复刻 v2 ExampleGameModuleServer——单例、按 session 建 Worker、StartGameAsync 建 MixGamingQueue(淘汰/复活=1)、HandleGamingMessage switch-case(Connect/PickCharacter/Surrender)。
  • Host 接线:PluginKind.GameModuleServer + modules/games 目录;GetGameModule;CreateGameFromModule/GetGameOfClient;gaming.action 路由到房间 GameModule;RoomStart 优先走 GameModule(无则回退 IServerPlugin)。老 IServerPlugin 并存逐步退役。

核心约定:Oshima 引用不拷贝(用户拍板)

  • Testing-v3 最先适配 Core v3,Server-v3 不再维护 Oshima 内容拷贝(Core #172/#173 把 Effect 钩子改成 Context 模式,拷贝会快速过期)。
  • 已抽取独立库:C:\milimoe\FunGame.Testing-v3\OshimaGameModules\OshimaGameModules.csproj(net10.0,281 cs:Characters/Effects/Skills/Items/Units + Others/RandomNames.cs + configs→输出 modules/oshima-studios/);Testing-v3 WebAPI 与 Server-v3 的 Oshima 包装层均 ProjectReference 它。
  • Testing-v3 WebAPI/OshimaGameModules/ 只留 Modules/ 接线层(继承 Core IModule + JSON 加载);雇佣兵团.cs 的 FunGameService.GenerateRandomChineseName() → 库内自包含 RandomNames(Milimoe.FunGameTesting.Others)。
  • Server-v3 FunGame.Server.Modules.Oshima 只剩包装:csproj(引用库,CopyModulesToHost 同时复制包装层 + OshimaGameModules.dll 到 modules/*/_staging)+ OshimaServerModules.cs + OshimaGameModuleConstant.cs;内容/配置/Others/RandomNames.cs 已删除。
  • 插件 ALC 解析:被引用的库 DLL 与包装层同目录 → PluginLoadContext 第 3 步 fallback(_pluginDirectory + name.dll)命中;冒烟验证 oshima.* 全部加载。
  • 顺带迁移(旧钩子→Context):CharacterBuildService e.OnEffectLost(new HookContext(null, c));Example 模组 OnSkillCasted(SkillCastContext)。
  • 约定:以后 Oshima 内容改动只改 Testing-v3 库;Server-v3 重新 build 即自动跟随(复制目标同步库 DLL)。