From d092dce67e17b5ad5fa1e1c9a4ed5fac5d6f6185 Mon Sep 17 00:00:00 2001 From: dgflash Date: Fri, 14 Jun 2024 18:06:23 +0800 Subject: [PATCH] =?UTF-8?q?1=E3=80=81=E4=BC=98=E5=8C=96=E6=A1=86=E6=9E=B6?= =?UTF-8?q?=E5=90=AF=E5=8A=A8=E9=85=8D=E7=BD=AE=E5=9C=A8H5=E6=A8=A1?= =?UTF-8?q?=E5=BC=8F=E4=B8=8B=E5=9B=A0=E5=BC=B1=E7=BD=91=E5=8A=A0=E8=BD=BD?= =?UTF-8?q?=E5=A4=B1=E8=B4=A5=E8=BF=9B=E4=B8=8D=E4=BA=86=E6=B8=B8=E6=88=8F?= =?UTF-8?q?=E9=97=AE=E9=A2=98=EF=BC=8C=E6=A1=86=E6=9E=B6=E4=BC=9A=E8=87=AA?= =?UTF-8?q?=E5=8A=A8=E5=8F=8D=E5=A4=8D=E9=87=8D=E8=AF=95=E5=8A=A0=E8=BD=BD?= =?UTF-8?q?=E9=85=8D=E7=BD=AE=E6=96=87=E4=BB=B6=202=E3=80=81=E9=85=8D?= =?UTF-8?q?=E7=BD=AE=E6=95=B0=E6=8D=AE=E8=8E=B7=E5=8F=96=E5=90=8E=EF=BC=8C?= =?UTF-8?q?=E5=88=A0=E9=99=A4=E5=86=85=E5=AD=98=E4=B8=AD=E7=9A=84=E9=85=8D?= =?UTF-8?q?=E7=BD=AE=E8=B5=84=E6=BA=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- assets/core/Root.ts | 41 ++++++++++++++++++------------ assets/module/config/GameConfig.ts | 3 +-- 2 files changed, 26 insertions(+), 18 deletions(-) diff --git a/assets/core/Root.ts b/assets/core/Root.ts index c9318ec..7c87ecc 100644 --- a/assets/core/Root.ts +++ b/assets/core/Root.ts @@ -45,25 +45,34 @@ export class Root extends Component { console.log(`Oops Framework v${version}`); this.enabled = false; - - let config_name = "config"; - oops.res.load(config_name, JsonAsset, () => { - var config = oops.res.get(config_name); - // oops.config.btc = new BuildTimeConstants(); - oops.config.query = new GameQueryConfig(); - oops.config.game = new GameConfig(config); - oops.http.server = oops.config.game.httpServer; // Http 服务器地址 - oops.http.timeout = oops.config.game.httpTimeout; // Http 请求超时时间 - oops.storage.init(oops.config.game.localDataKey, oops.config.game.localDataIv); // 初始化本地存储加密 - game.frameRate = oops.config.game.frameRate; // 初始化每秒传输帧数 - - this.enabled = true; - this.init(); - this.run(); - }); + this.loadConfig(); } } + private loadConfig() { + const config_name = "config"; + oops.res.load(config_name, JsonAsset, () => { + var config = oops.res.get(config_name); + if (config == null) { + this.loadConfig(); + return; + } + // oops.config.btc = new BuildTimeConstants(); + oops.config.query = new GameQueryConfig(); + oops.config.game = new GameConfig(config); + oops.http.server = oops.config.game.httpServer; // Http 服务器地址 + oops.http.timeout = oops.config.game.httpTimeout; // Http 请求超时时间 + oops.storage.init(oops.config.game.localDataKey, oops.config.game.localDataIv); // 初始化本地存储加密 + game.frameRate = oops.config.game.frameRate; // 初始化每秒传输帧数 + + this.enabled = true; + this.init(); + this.run(); + + oops.res.release(config_name); + }); + } + update(dt: number) { oops.ecs.execute(dt); } diff --git a/assets/module/config/GameConfig.ts b/assets/module/config/GameConfig.ts index 0a9a142..6516f65 100644 --- a/assets/module/config/GameConfig.ts +++ b/assets/module/config/GameConfig.ts @@ -75,8 +75,7 @@ export class GameConfig { } constructor(config: any) { - let data = config.json; - this._data = Object.freeze(data); + this._data = Object.freeze(config.json); oops.log.logConfig(this._data, "游戏配置"); }