refactor(debug-mod): 使用原生 System 替换 QuMod

删除未使用的大型 QuMod 加载框架,改为直接注册客户端和服务端 System,并显式管理按键监听、输出包装与双端销毁。

IPC 网络线程仅负责收包,所有 ModAPI 回调由游戏线程 Update 派发,同时补充断线重连、分帧读取和幂等关闭。
This commit is contained in:
2026-07-21 20:52:10 +08:00
parent 3afc122404
commit 94b1b9a1f5
15 changed files with 386 additions and 1057 deletions

View File

@@ -0,0 +1,77 @@
# -*- coding: utf-8 -*-
import mod.client.extraClientApi as clientApi
from . import IPCSystem, Lifecycle
from .Config import DEBUG_CONFIG
from .Game import (
INIT_RELOAD_TIME,
RELOAD_ADDON,
RELOAD_MOD,
RELOAD_SHADERS,
RELOAD_WORLD,
)
ClientSystem = clientApi.GetClientSystemCls()
ENGINE_NAMESPACE = clientApi.GetEngineNamespace()
ENGINE_SYSTEM_NAME = clientApi.GetEngineSystemName()
class DebugClientSystem(ClientSystem):
def __init__(self, namespace, system_name):
ClientSystem.__init__(self, namespace, system_name)
self._initialized = False
self._listening = False
def Update(self):
if not self._initialized:
Lifecycle.activate(self)
IPCSystem.ON_CLIENT_INIT()
self.ListenForEvent(
ENGINE_NAMESPACE,
ENGINE_SYSTEM_NAME,
"OnKeyPressInGame",
self,
self.on_key_press_in_game,
)
self._listening = True
self._initialized = True
INIT_RELOAD_TIME()
IPCSystem.UPDATE_CLIENT()
return ClientSystem.Update(self)
def Destroy(self):
try:
if self._listening:
self.UnListenForEvent(
ENGINE_NAMESPACE,
ENGINE_SYSTEM_NAME,
"OnKeyPressInGame",
self,
self.on_key_press_in_game,
)
self._listening = False
finally:
try:
IPCSystem.ON_CLIENT_EXIT()
finally:
self._initialized = False
Lifecycle.deactivate(self)
def on_key_press_in_game(self, args):
if args["isDown"] != "0":
return
if args["screenName"] != "hud_screen" and not DEBUG_CONFIG.get(
"reload_key_global", False
):
return
key = args["key"]
if key == str(DEBUG_CONFIG.get("reload_key", "82")):
RELOAD_MOD()
elif key == str(DEBUG_CONFIG.get("reload_world_key", "")):
RELOAD_WORLD()
elif key == str(DEBUG_CONFIG.get("reload_addon_key", "")):
RELOAD_ADDON()
elif key == str(DEBUG_CONFIG.get("reload_shaders_key", "")):
RELOAD_SHADERS()