"""apilot.stubs: 全量装配入口 install_all。""" from __future__ import annotations from typing import Any from apilot.stubs.env import EnvData, install_env from apilot.stubs.netclient import NetClientStub from apilot.stubs.networkctl import NetworkCtlStub from apilot.stubs.noop import install_noop_globals from apilot.stubs.scheduler import Scheduler, install_scheduler def install_all(lua: Any, nc: NetClientStub, ctl: NetworkCtlStub, sched: Scheduler, env: EnvData, state_dir: str) -> None: """全量装配到 lua runtime: noop → scheduler → env → networkctl → global.* 引用。 顺序说明: 1) install_noop_globals 装 cc/ccui/ccs/ccexp 骨架 2) install_scheduler 装 PerformWithDelayGlobal/Schedule/UnSchedule/SL_getScheduler 3) install_env 装 L_GameEnvManager/LuaBridgeCtl/cc.FileUtils/gameEnviroment + 杂项全局 4) ctl.install_to_lua 装 networkCtl/LuaNetworkController(最后, 真实实现覆盖 no-op) 5) 把 C++ 静态单例引用挂到 global.* (游戏原版 Lua 大量通过 global.X 访问) 6) gameEnviroment.GetNetClient 指向真实 nc (Task 6 之后 game code 会用) """ install_noop_globals(lua) install_scheduler(lua, sched) install_env(lua, env, state_dir) ctl.install_to_lua(lua) lua.globals()["AP_netclient_ref"] = nc lua.execute("gameEnviroment:SetNetClient(AP_netclient_ref)") lua.execute("global = global or {}") lua.execute("global.networkCtl = networkCtl; global.LuaBridgeCtl = LuaBridgeCtl") lua.execute("global.L_GameEnvManager = L_GameEnvManager") lua.execute("global.gameEnviroment = gameEnviroment") lua.execute("global.gameEnvironment = gameEnviroment") __all__ = [ "EnvData", "NetClientStub", "NetworkCtlStub", "Scheduler", "install_all", "install_env", "install_noop_globals", "install_scheduler", ]