Commit 5753aeeb authored by rockyl's avatar rockyl

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

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