Commit 672906ea authored by rockyl's avatar rockyl

修改过程属性链接方式

parent 3ef630dd
......@@ -7,7 +7,7 @@ import {VM} from "./VM";
import {linkedFlag, nodeScheme, objClone} from "../utils";
import {findNodeByUUID} from "../node-utils";
const log = false;
const log = true;
export class Process {
private _config;
......@@ -166,11 +166,12 @@ export class Process {
let props = this._config.props;
for (let key in props) {
let value = this._originProps[key];
if (value === linkedFlag) {
if (this._parent) {
props[key] = this._parent.getProps(key);
if (typeof value == 'object') {
let linkedValue = this.resolveLinkedProp(value, key);
if (linkedValue !== undefined) {
props[key] = linkedValue;
}
} else if (value.indexOf(nodeScheme) === 0) {
} else if (value && value.indexOf && value.indexOf(nodeScheme) === 0) {
let uuid = value.replace(nodeScheme, '');
if (uuid) {
props[key] = findNodeByUUID(this._vm.getGlobalContext().gameStage, uuid);
......@@ -179,10 +180,19 @@ export class Process {
}
}
}
resolveLinkedProp(data, key) {
let linkedKey = data.alias || key;
if (this._parent) {
return this._parent.getProps(linkedKey);
}
}
}
function warpAsyncScript(source) {
return `return new Promise(function(resolve, reject){
${source}
function next(type, payload){resolve({type: type, payload: payload})}
});`;
}
......@@ -2,7 +2,7 @@
* Created by rockyl on 2019-11-08.
*/
export const ESCAPE_REG_EXP = /\$\{[_a-zA-Z]\w*\}/g;
export const ESCAPE_REG_EXP = /\$\{[\u4e00-\u9fa5_a-zA-Z0-9]+\}/g;
export const linkedFlag = '$_linked_$';
export const nodeScheme = 'node://';
......
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