Commit 5753aeeb authored by rockyl's avatar rockyl

修改过程执行为每次都拷贝一份入参

parent ed52c049
...@@ -322,7 +322,7 @@ export const GlobalPro = { ...@@ -322,7 +322,7 @@ export const GlobalPro = {
* @return {boolean} is webgl supported * @return {boolean} is webgl supported
*/ */
export function isWebGLSupported(): boolean { export function isWebGLSupported(): boolean {
const contextOptions = { stencil: true, failIfMajorPerformanceCaveat: true }; const contextOptions = { stencil: true };//, failIfMajorPerformanceCaveat: true
try { try {
if (!window["WebGLRenderingContext"]) { if (!window["WebGLRenderingContext"]) {
return false; return false;
......
...@@ -73,6 +73,8 @@ export class Process { ...@@ -73,6 +73,8 @@ export class Process {
} }
async execute(args) { async execute(args) {
let payload = objClone(args);
let metaConfig = this._config.meta; let metaConfig = this._config.meta;
let meta, result; let meta, result;
if (metaConfig) { if (metaConfig) {
...@@ -87,7 +89,7 @@ export class Process { ...@@ -87,7 +89,7 @@ export class Process {
let p; let p;
for (let i = 0, li = meta.output.length; i < li; i++) { for (let i = 0, li = meta.output.length; i < li; i++) {
const key = meta.output[i]; const key = meta.output[i];
p = this._executeNextProcess(key, args); p = this._executeNextProcess(key, payload);
if (i === li - 1) { if (i === li - 1) {
result = await p; result = await p;
} else { } else {
...@@ -97,7 +99,7 @@ export class Process { ...@@ -97,7 +99,7 @@ export class Process {
} }
} }
} else { } else {
const scriptResult = await this._executeMetaScript('', args, metaConfig); const scriptResult = await this._executeMetaScript('', payload, metaConfig);
let subProcessResult; let subProcessResult;
if (this._meta.sub && Object.keys(this._meta.sub).length > 1) { if (this._meta.sub && Object.keys(this._meta.sub).length > 1) {
subProcessResult = await this._executeSubProcess(scriptResult.type, scriptResult.payload); subProcessResult = await this._executeSubProcess(scriptResult.type, scriptResult.payload);
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
import {Stage} from "../../2d/display/index"; import {Stage} from "../../2d/display/index";
import {StackContainer} from "./StackContainer"; import {StackContainer} from "./StackContainer";
import {loadAssetGroup} from "./assets-manager"; import {loadAssets} from "./assets-manager";
import {instantiate} from "./view-interpreter"; import {instantiate} from "./view-interpreter";
import {dataCenter, DataCenter} from "./data-center"; import {dataCenter, DataCenter} from "./data-center";
import {setProcessMetaLibs} from "../behavior-runtime/index"; import {setProcessMetaLibs} from "../behavior-runtime/index";
...@@ -98,11 +98,10 @@ export class GameStage extends Node { ...@@ -98,11 +98,10 @@ export class GameStage extends Node {
/** /**
* 启动游戏 * 启动游戏
* @param config * @param config
* @param onPreloadAssetsProgress 预加载素材进度 * @param onAssetsProgress
* @param onPreloadAssetsComplete 预加载素材完成 * @param onAssetsComplete
* @param onStart
*/ */
async launch(config, onPreloadAssetsProgress?, onPreloadAssetsComplete?, onStart?) { async launch(config, onAssetsProgress?, onAssetsComplete?, onStart?) {
this._config = config; this._config = config;
const {assets, customs} = config; const {assets, customs} = config;
let loaded = 0; let loaded = 0;
...@@ -115,13 +114,13 @@ export class GameStage extends Node { ...@@ -115,13 +114,13 @@ export class GameStage extends Node {
} }
} }
await loadAssetGroup(assets, p).catch(e => { await loadAssets(assets, p).catch(e => {
console.log(e); console.log(e);
}); });
if (customs) { if (customs) {
for (let custom of customs) { for (let custom of customs) {
if (custom.assets) { if (custom.assets) {
await loadAssetGroup(custom.assets, p).catch(e => { await loadAssets(custom.assets, p).catch(e => {
console.log(e); console.log(e);
}); });
} }
......
...@@ -56,7 +56,7 @@ export class StackContainer extends Node { ...@@ -56,7 +56,7 @@ export class StackContainer extends Node {
*/ */
pop(dispatch = true) { pop(dispatch = true) {
let len = this.children.length; let len = this.children.length;
if (len <= 1) { if (len <= 0) {
return false; return false;
} }
this.removeChildAt(len - 1); this.removeChildAt(len - 1);
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
*/ */
import {globalLoader} from "../../2d/loader/Loader"; import {globalLoader} from "../../2d/loader/Loader";
import {arrayFind, linkScheme} from "../utils/index"; import {arrayFind, linkScheme} from "../utils";
import {parse} from "./bmp-text-manager"; import {parse} from "./bmp-text-manager";
let assetsConfig = []; let assetsConfig = [];
...@@ -23,9 +23,9 @@ const loaderMapping = { ...@@ -23,9 +23,9 @@ const loaderMapping = {
}; };
/** /**
* 加载素材 * 加载素材
*/ */
export function loadAssetGroup(config, onProgress?, onComplete?) { export function loadAssets(config, onProgress?, onComplete?) {
let total = config.length; let total = config.length;
let loaded = 0; let loaded = 0;
let failedList = []; let failedList = [];
......
...@@ -2,16 +2,15 @@ ...@@ -2,16 +2,15 @@
* Created by rockyl on 2019-11-08. * Created by rockyl on 2019-11-08.
*/ */
import {Stage} from "../2d/display/index"; import {Stage} from "../2d/display";
import {GameStage, registerCustomModuleFromConfig} from "./game-warpper/index"; import {registerCustomModuleFromConfig, registerScripts, RENDERER_TYPE, setProcessMetaLibs, StageScaleMode} from "..";
import {setGlobalContext, setProcessMetaLibs} from "./behavior-runtime/index"; import {GameStage} from "./game-warpper/index";
import {setGlobalContext} from "./behavior-runtime";
import {globalLoader} from "../2d/loader/Loader"; import {globalLoader} from "../2d/loader/Loader";
import {Event} from "../2d/events/Event"; import {Event} from "../2d/events/Event";
import builtinLoadingView from "./game-warpper/LoadingView"; import builtinLoadingView from "./game-warpper/LoadingView";
import {queryParams} from "./web"; import {queryParams} from "./web";
import {initAutoLayout} from "./game-warpper/auto-layout"; import {initAutoLayout} from "./game-warpper/auto-layout";
import {registerScripts} from "./decorators/scripts";
import {RENDERER_TYPE, StageScaleMode} from "../2d/const";
export let gameStage: GameStage; export let gameStage: GameStage;
......
...@@ -31,7 +31,7 @@ export function arrayFind(arr, predicate) { ...@@ -31,7 +31,7 @@ export function arrayFind(arr, predicate) {
* @param obj * @param obj
*/ */
export function objClone(obj) { export function objClone(obj) {
return JSON.parse(JSON.stringify(obj)); return obj ? JSON.parse(JSON.stringify(obj)) : obj;
} }
const percentKeys = ['width', 'height']; const percentKeys = ['width', 'height'];
...@@ -73,11 +73,11 @@ export function getDataByPath(scope, path, throwException?) { ...@@ -73,11 +73,11 @@ export function getDataByPath(scope, path, throwException?) {
* @param code * @param code
* @param throwException * @param throwException
*/ */
export function safeEval(code, throwException = false){ export function safeEval(code, throwException = false) {
let func = new Function(code); let func = new Function(code);
try { try {
return func(); return func();
}catch (e) { } catch (e) {
if (throwException) { if (throwException) {
throw e; throw e;
} }
...@@ -329,7 +329,7 @@ export const cmdOldPrefix = '//z-'; ...@@ -329,7 +329,7 @@ export const cmdOldPrefix = '//z-';
*/ */
export function injectProperties(target, source) { export function injectProperties(target, source) {
for (let key in source) { for (let key in source) {
if(key.indexOf('//') !== 0 && !source.hasOwnProperty(cmdPrefix + key)){ if (key.indexOf('//') !== 0 && !source.hasOwnProperty(cmdPrefix + key)) {
propertyParse(key, target, source); propertyParse(key, target, source);
} }
} }
...@@ -344,7 +344,7 @@ export function injectProperties(target, source) { ...@@ -344,7 +344,7 @@ export function injectProperties(target, source) {
* @param includeSelf * @param includeSelf
*/ */
export function traverseViewNode(node: Container, callback: Function, includeSelf = false) { export function traverseViewNode(node: Container, callback: Function, includeSelf = false) {
if(includeSelf){ if (includeSelf) {
callback(node); callback(node);
} }
for (let child of node.children) { for (let child of node.children) {
......
/** /**
* Created by rockyl on 2019-12-10. * Created by rockyl on 2019-12-10.
*/ */
import {env} from "./game-warpper/enviroment";
export let queryParams: any = {}; export let queryParams: any = {};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment