mirror of
https://gitee.com/dgflash/oops-framework.git
synced 2026-06-18 19:52:10 +08:00
扩展ECSEntity可添加子实体对象与访问父实体对象的功能;CC3.6引擎API兼容处理
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
* @Author: dgflash
|
||||
* @Date: 2021-07-03 16:13:17
|
||||
* @LastEditors: dgflash
|
||||
* @LastEditTime: 2022-07-21 14:48:35
|
||||
* @LastEditTime: 2022-07-22 15:52:11
|
||||
*/
|
||||
import { dynamicAtlasManager, macro, profiler, _decorator } from 'cc';
|
||||
import { DEBUG, JSB } from 'cc/env';
|
||||
@@ -24,7 +24,7 @@ export class Main extends CommonEnter {
|
||||
if (DEBUG) profiler.showStats();
|
||||
}
|
||||
|
||||
protected async run() {
|
||||
protected async run() {this.node.children
|
||||
smc.initialize = ecs.getEntity<Initialize>(Initialize);
|
||||
if (JSB) {
|
||||
oops.gui.toast("热更新后新程序的提示");
|
||||
|
||||
@@ -2,10 +2,11 @@
|
||||
* @Author: dgflash
|
||||
* @Date: 2021-07-03 16:13:17
|
||||
* @LastEditors: dgflash
|
||||
* @LastEditTime: 2022-06-14 19:53:59
|
||||
* @LastEditTime: 2022-07-22 17:12:05
|
||||
*/
|
||||
import { ecs } from "../../../../../extensions/oops-framework/assets/libs/ecs/ECS";
|
||||
import { EcsAccountSystem } from "../../account/Account";
|
||||
import { EcsInitializeSystem } from "../../initialize/Initialize";
|
||||
import { EcsRoleSystem } from "../../role/Role";
|
||||
import { EcsPositionSystem } from "./position/EcsPositionSystem";
|
||||
|
||||
@@ -17,5 +18,6 @@ export class CommonSystem extends ecs.System {
|
||||
this.add(new EcsPositionSystem());
|
||||
this.add(new EcsAccountSystem());
|
||||
this.add(new EcsRoleSystem());
|
||||
this.add(new EcsInitializeSystem());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* @Author: dgflash
|
||||
* @Date: 2021-11-18 14:20:46
|
||||
* @LastEditors: dgflash
|
||||
* @LastEditTime: 2022-06-14 19:54:06
|
||||
* @LastEditTime: 2022-07-22 17:38:46
|
||||
*/
|
||||
|
||||
import { ecs } from "../../../../../extensions/oops-framework/assets/libs/ecs/ECS";
|
||||
@@ -15,7 +15,9 @@ export class SingletonModuleComp extends ecs.Comp {
|
||||
/** 游戏初始化模块 */
|
||||
initialize: Initialize = null!;
|
||||
/** 游戏账号模块 */
|
||||
account: Account = null!;
|
||||
get account(): Account {
|
||||
return this.initialize.account;
|
||||
}
|
||||
|
||||
reset() { }
|
||||
}
|
||||
|
||||
@@ -2,15 +2,11 @@
|
||||
* @Author: dgflash
|
||||
* @Date: 2021-11-11 17:45:23
|
||||
* @LastEditors: dgflash
|
||||
* @LastEditTime: 2022-06-14 19:55:36
|
||||
* @LastEditTime: 2022-07-22 17:44:32
|
||||
*/
|
||||
import { resLoader } from "../../../../extensions/oops-framework/assets/core/common/loader/ResLoader";
|
||||
import { AsyncQueue, NextFunction } from "../../../../extensions/oops-framework/assets/core/common/queue/AsyncQueue";
|
||||
import { oops } from "../../../../extensions/oops-framework/assets/core/Oops";
|
||||
import { ecs } from "../../../../extensions/oops-framework/assets/libs/ecs/ECS";
|
||||
import { config } from "../common/config/Config";
|
||||
import { UIID } from "../common/config/GameUIConfig";
|
||||
import { LoadingViewComp } from "./view/LoadingViewComp";
|
||||
import { Account } from "../account/Account";
|
||||
import { InitResComp, InitResSystem } from "./bll/InitRes";
|
||||
|
||||
/**
|
||||
* 游戏进入初始化模块
|
||||
@@ -18,64 +14,23 @@ import { LoadingViewComp } from "./view/LoadingViewComp";
|
||||
* 2、加载默认资源
|
||||
*/
|
||||
export class Initialize extends ecs.Entity {
|
||||
LoadingView!: LoadingViewComp;
|
||||
/** 帐号管理 */
|
||||
account: Account = null!;
|
||||
|
||||
protected init() {
|
||||
var queue: AsyncQueue = new AsyncQueue();
|
||||
// 帐号模块为初始化模块的子实体对象
|
||||
this.account = ecs.getEntity<Account>(Account);
|
||||
this.addChild(this.account);
|
||||
|
||||
// 加载自定义资源
|
||||
this.loadCustom(queue);
|
||||
// 加载多语言包
|
||||
this.loadLanguage(queue);
|
||||
// 加载公共资源
|
||||
this.loadCommon(queue);
|
||||
// 加载游戏内容加载进度提示界面
|
||||
this.onComplete();
|
||||
|
||||
queue.play();
|
||||
// 初始化游戏公共资源
|
||||
this.add(InitResComp);
|
||||
}
|
||||
}
|
||||
|
||||
export class EcsInitializeSystem extends ecs.System {
|
||||
constructor() {
|
||||
super();
|
||||
|
||||
/** 加载自定义内容(可选) */
|
||||
private loadCustom(queue: AsyncQueue) {
|
||||
queue.push(async (next: NextFunction, params: any, args: any) => {
|
||||
// 设置渠道号
|
||||
// if (config.query.channelId) SDKPlatform.setChannelId(config.query.channelId);
|
||||
|
||||
// 加载多语言对应字体
|
||||
resLoader.load("language/font/" + oops.language.current, next);
|
||||
});
|
||||
}
|
||||
|
||||
/** 加载化语言包(可选) */
|
||||
private loadLanguage(queue: AsyncQueue) {
|
||||
queue.push((next: NextFunction, params: any, args: any) => {
|
||||
// 设置默认语言
|
||||
let lan = oops.storage.get("language");
|
||||
if (lan == null) {
|
||||
// lan = SDKPlatform.getLanguage();
|
||||
lan = "zh";
|
||||
oops.storage.set("language", lan!);
|
||||
}
|
||||
|
||||
// 设置语言包路径
|
||||
oops.language.setAssetsPath(config.game.languagePathJson, config.game.languagePathTexture);
|
||||
|
||||
// 加载语言包资源
|
||||
oops.language.setLanguage(lan!, next);
|
||||
});
|
||||
}
|
||||
|
||||
/** 加载公共资源(必备) */
|
||||
private loadCommon(queue: AsyncQueue) {
|
||||
queue.push((next: NextFunction, params: any, args: any) => {
|
||||
resLoader.loadDir("common", next);
|
||||
});
|
||||
}
|
||||
|
||||
/** 加载完成进入游戏内容加载界面 */
|
||||
private async onComplete() {
|
||||
var node = await oops.gui.openAsync(UIID.Loading);
|
||||
if (node) this.add(node.getComponent(LoadingViewComp) as ecs.Comp);
|
||||
this.add(new InitResSystem());
|
||||
}
|
||||
}
|
||||
12
assets/script/game/initialize/bll.meta
Normal file
12
assets/script/game/initialize/bll.meta
Normal file
@@ -0,0 +1,12 @@
|
||||
{
|
||||
"ver": "1.1.0",
|
||||
"importer": "directory",
|
||||
"imported": true,
|
||||
"uuid": "de5401a8-45c8-4249-aa4c-933102551227",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {
|
||||
"compressionType": {},
|
||||
"isRemoteBundle": {}
|
||||
}
|
||||
}
|
||||
87
assets/script/game/initialize/bll/InitRes.ts
Normal file
87
assets/script/game/initialize/bll/InitRes.ts
Normal file
@@ -0,0 +1,87 @@
|
||||
/*
|
||||
* @Author: dgflash
|
||||
* @Date: 2022-07-22 17:06:22
|
||||
* @LastEditors: dgflash
|
||||
* @LastEditTime: 2022-07-22 17:09:30
|
||||
*/
|
||||
import { resLoader } from "../../../../../extensions/oops-framework/assets/core/common/loader/ResLoader";
|
||||
import { AsyncQueue, NextFunction } from "../../../../../extensions/oops-framework/assets/core/common/queue/AsyncQueue";
|
||||
import { oops } from "../../../../../extensions/oops-framework/assets/core/Oops";
|
||||
import { ecs } from "../../../../../extensions/oops-framework/assets/libs/ecs/ECS";
|
||||
import { config } from "../../common/config/Config";
|
||||
import { UIID } from "../../common/config/GameUIConfig";
|
||||
import { Initialize } from "../Initialize";
|
||||
import { LoadingViewComp } from "../view/LoadingViewComp";
|
||||
|
||||
/** 初始化游戏公共资源 */
|
||||
@ecs.register('InitRes')
|
||||
export class InitResComp extends ecs.Comp {
|
||||
reset() { }
|
||||
}
|
||||
|
||||
export class InitResSystem extends ecs.ComblockSystem implements ecs.IEntityEnterSystem {
|
||||
filter(): ecs.IMatcher {
|
||||
return ecs.allOf(InitResComp);
|
||||
}
|
||||
|
||||
entityEnter(e: Initialize): void {
|
||||
var queue: AsyncQueue = new AsyncQueue();
|
||||
|
||||
// 加载自定义资源
|
||||
this.loadCustom(queue);
|
||||
// 加载多语言包
|
||||
this.loadLanguage(queue);
|
||||
// 加载公共资源
|
||||
this.loadCommon(queue);
|
||||
// 加载游戏内容加载进度提示界面
|
||||
this.onComplete(queue, e);
|
||||
|
||||
queue.play();
|
||||
}
|
||||
|
||||
/** 加载自定义内容(可选) */
|
||||
private loadCustom(queue: AsyncQueue) {
|
||||
queue.push(async (next: NextFunction, params: any, args: any) => {
|
||||
// 设置渠道号
|
||||
// if (config.query.channelId) SDKPlatform.setChannelId(config.query.channelId);
|
||||
|
||||
// 加载多语言对应字体
|
||||
resLoader.load("language/font/" + oops.language.current, next);
|
||||
});
|
||||
}
|
||||
|
||||
/** 加载化语言包(可选) */
|
||||
private loadLanguage(queue: AsyncQueue) {
|
||||
queue.push((next: NextFunction, params: any, args: any) => {
|
||||
// 设置默认语言
|
||||
let lan = oops.storage.get("language");
|
||||
if (lan == null) {
|
||||
// lan = SDKPlatform.getLanguage();
|
||||
lan = "zh";
|
||||
oops.storage.set("language", lan!);
|
||||
}
|
||||
|
||||
// 设置语言包路径
|
||||
oops.language.setAssetsPath(config.game.languagePathJson, config.game.languagePathTexture);
|
||||
|
||||
// 加载语言包资源
|
||||
oops.language.setLanguage(lan!, next);
|
||||
});
|
||||
}
|
||||
|
||||
/** 加载公共资源(必备) */
|
||||
private loadCommon(queue: AsyncQueue) {
|
||||
queue.push((next: NextFunction, params: any, args: any) => {
|
||||
resLoader.loadDir("common", next);
|
||||
});
|
||||
}
|
||||
|
||||
/** 加载完成进入游戏内容加载界面 */
|
||||
private onComplete(queue: AsyncQueue, e: Initialize) {
|
||||
queue.complete = async () => {
|
||||
var node = await oops.gui.openAsync(UIID.Loading);
|
||||
if (node) e.add(node.getComponent(LoadingViewComp) as ecs.Comp);
|
||||
e.remove(InitResComp);
|
||||
};
|
||||
}
|
||||
}
|
||||
9
assets/script/game/initialize/bll/InitRes.ts.meta
Normal file
9
assets/script/game/initialize/bll/InitRes.ts.meta
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "4.0.23",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "2ee0cf3e-ed1f-4414-a41b-f8e3e7f66964",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
import { error, log, sys } from "cc";
|
||||
import { error, log, native, sys } from "cc";
|
||||
import { resLoader } from "../../../../../extensions/oops-framework/assets/core/common/loader/ResLoader";
|
||||
|
||||
/** 热更参数 */
|
||||
@@ -66,7 +66,7 @@ export class Hot {
|
||||
this.showSearchPath();
|
||||
|
||||
this.manifest = res.nativeUrl;
|
||||
this.storagePath = `${jsb.fileUtils.getWritablePath()}/oops_framework_remote`;
|
||||
this.storagePath = `${native.fileUtils.getWritablePath()}/oops_framework_remote`;
|
||||
this.assetsMgr = new jsb.AssetsManager(this.manifest, this.storagePath, (versionA, versionB) => {
|
||||
console.log("【热更新】客户端版本: " + versionA + ', 当前最新版本: ' + versionB);
|
||||
this.options?.onVersionInfo && this.options.onVersionInfo({ local: versionA, server: versionB });
|
||||
@@ -116,7 +116,7 @@ export class Hot {
|
||||
|
||||
/** 删除热更所有存储文件 */
|
||||
clearHotUpdateStorage() {
|
||||
jsb.fileUtils.removeDirectory(this.storagePath);
|
||||
native.fileUtils.removeDirectory(this.storagePath);
|
||||
}
|
||||
|
||||
// 检查更新
|
||||
@@ -191,11 +191,11 @@ export class Hot {
|
||||
|
||||
private onUpdateFinished() {
|
||||
this.assetsMgr.setEventCallback(null!);
|
||||
let searchPaths = jsb.fileUtils.getSearchPaths();
|
||||
let searchPaths = native.fileUtils.getSearchPaths();
|
||||
let newPaths = this.assetsMgr.getLocalManifest().getSearchPaths();
|
||||
Array.prototype.unshift.apply(searchPaths, newPaths);
|
||||
localStorage.setItem('HotUpdateSearchPaths', JSON.stringify(searchPaths));
|
||||
jsb.fileUtils.setSearchPaths(searchPaths);
|
||||
native.fileUtils.setSearchPaths(searchPaths);
|
||||
|
||||
console.log('【热更新】更新成功');
|
||||
this.options?.onUpdateSucceed && this.options.onUpdateSucceed();
|
||||
@@ -203,7 +203,7 @@ export class Hot {
|
||||
|
||||
private showSearchPath() {
|
||||
console.log("========================搜索路径========================");
|
||||
let searchPaths = jsb.fileUtils.getSearchPaths();
|
||||
let searchPaths = native.fileUtils.getSearchPaths();
|
||||
for (let i = 0; i < searchPaths.length; i++) {
|
||||
console.log("[" + i + "]: " + searchPaths[i]);
|
||||
}
|
||||
|
||||
@@ -2,14 +2,13 @@
|
||||
* @Author: dgflash
|
||||
* @Date: 2021-07-03 16:13:17
|
||||
* @LastEditors: dgflash
|
||||
* @LastEditTime: 2022-06-21 15:30:55
|
||||
* @LastEditTime: 2022-07-22 17:44:57
|
||||
*/
|
||||
import { _decorator } from "cc";
|
||||
import { resLoader } from "../../../../../extensions/oops-framework/assets/core/common/loader/ResLoader";
|
||||
import { oops } from "../../../../../extensions/oops-framework/assets/core/Oops";
|
||||
import { JsonUtil } from "../../../../../extensions/oops-framework/assets/core/utils/JsonUtil";
|
||||
import { ecs } from "../../../../../extensions/oops-framework/assets/libs/ecs/ECS";
|
||||
import { Account } from "../../account/Account";
|
||||
import { GameEvent } from "../../common/config/GameEvent";
|
||||
import { UIID } from "../../common/config/GameUIConfig";
|
||||
import { CCVMParentComp } from "../../common/ecs/CCVMParentComp";
|
||||
@@ -114,7 +113,6 @@ export class LoadingViewComp extends CCVMParentComp {
|
||||
/** 加载完成事件 */
|
||||
private onCompleteCallback() {
|
||||
// 初始化帐号模块
|
||||
smc.account = ecs.getEntity<Account>(Account);
|
||||
smc.account.connect();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user