@eva/eva.js 2.0.0-beta.1 → 2.0.0-beta.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/EVA.js +811 -1514
- package/dist/EVA.min.js +1 -1
- package/dist/eva.js.cjs.js +724 -1265
- package/dist/eva.js.cjs.prod.js +3 -2
- package/dist/eva.js.d.ts +1 -1
- package/dist/eva.js.esm.js +733 -1274
- package/package.json +1 -1
package/dist/EVA.js
CHANGED
|
@@ -1,187 +1,7 @@
|
|
|
1
1
|
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
|
|
2
2
|
var _EVA_IIFE_EVA = function (exports, pixi_js) {
|
|
3
3
|
'use strict';
|
|
4
|
-
|
|
5
|
-
extendStatics$1 = Object.setPrototypeOf || {
|
|
6
|
-
__proto__: []
|
|
7
|
-
} instanceof Array && function (d, b) {
|
|
8
|
-
d.__proto__ = b;
|
|
9
|
-
} || function (d, b) {
|
|
10
|
-
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
|
|
11
|
-
};
|
|
12
|
-
return extendStatics$1(d, b);
|
|
13
|
-
};
|
|
14
|
-
function __extends$1(d, b) {
|
|
15
|
-
extendStatics$1(d, b);
|
|
16
|
-
function __() {
|
|
17
|
-
this.constructor = d;
|
|
18
|
-
}
|
|
19
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
20
|
-
}
|
|
21
|
-
function __decorate(decorators, target, key, desc) {
|
|
22
|
-
var c = arguments.length,
|
|
23
|
-
r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc,
|
|
24
|
-
d;
|
|
25
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
26
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
27
|
-
}
|
|
28
|
-
function __awaiter(thisArg, _arguments, P, generator) {
|
|
29
|
-
function adopt(value) {
|
|
30
|
-
return value instanceof P ? value : new P(function (resolve) {
|
|
31
|
-
resolve(value);
|
|
32
|
-
});
|
|
33
|
-
}
|
|
34
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
35
|
-
function fulfilled(value) {
|
|
36
|
-
try {
|
|
37
|
-
step(generator.next(value));
|
|
38
|
-
} catch (e) {
|
|
39
|
-
reject(e);
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
function rejected(value) {
|
|
43
|
-
try {
|
|
44
|
-
step(generator["throw"](value));
|
|
45
|
-
} catch (e) {
|
|
46
|
-
reject(e);
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
function step(result) {
|
|
50
|
-
result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
51
|
-
}
|
|
52
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
53
|
-
});
|
|
54
|
-
}
|
|
55
|
-
function __generator(thisArg, body) {
|
|
56
|
-
var _ = {
|
|
57
|
-
label: 0,
|
|
58
|
-
sent: function () {
|
|
59
|
-
if (t[0] & 1) throw t[1];
|
|
60
|
-
return t[1];
|
|
61
|
-
},
|
|
62
|
-
trys: [],
|
|
63
|
-
ops: []
|
|
64
|
-
},
|
|
65
|
-
f,
|
|
66
|
-
y,
|
|
67
|
-
t,
|
|
68
|
-
g;
|
|
69
|
-
return g = {
|
|
70
|
-
next: verb(0),
|
|
71
|
-
"throw": verb(1),
|
|
72
|
-
"return": verb(2)
|
|
73
|
-
}, typeof Symbol === "function" && (g[Symbol.iterator] = function () {
|
|
74
|
-
return this;
|
|
75
|
-
}), g;
|
|
76
|
-
function verb(n) {
|
|
77
|
-
return function (v) {
|
|
78
|
-
return step([n, v]);
|
|
79
|
-
};
|
|
80
|
-
}
|
|
81
|
-
function step(op) {
|
|
82
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
83
|
-
while (_) try {
|
|
84
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
85
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
86
|
-
switch (op[0]) {
|
|
87
|
-
case 0:
|
|
88
|
-
case 1:
|
|
89
|
-
t = op;
|
|
90
|
-
break;
|
|
91
|
-
case 4:
|
|
92
|
-
_.label++;
|
|
93
|
-
return {
|
|
94
|
-
value: op[1],
|
|
95
|
-
done: false
|
|
96
|
-
};
|
|
97
|
-
case 5:
|
|
98
|
-
_.label++;
|
|
99
|
-
y = op[1];
|
|
100
|
-
op = [0];
|
|
101
|
-
continue;
|
|
102
|
-
case 7:
|
|
103
|
-
op = _.ops.pop();
|
|
104
|
-
_.trys.pop();
|
|
105
|
-
continue;
|
|
106
|
-
default:
|
|
107
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
108
|
-
_ = 0;
|
|
109
|
-
continue;
|
|
110
|
-
}
|
|
111
|
-
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
112
|
-
_.label = op[1];
|
|
113
|
-
break;
|
|
114
|
-
}
|
|
115
|
-
if (op[0] === 6 && _.label < t[1]) {
|
|
116
|
-
_.label = t[1];
|
|
117
|
-
t = op;
|
|
118
|
-
break;
|
|
119
|
-
}
|
|
120
|
-
if (t && _.label < t[2]) {
|
|
121
|
-
_.label = t[2];
|
|
122
|
-
_.ops.push(op);
|
|
123
|
-
break;
|
|
124
|
-
}
|
|
125
|
-
if (t[2]) _.ops.pop();
|
|
126
|
-
_.trys.pop();
|
|
127
|
-
continue;
|
|
128
|
-
}
|
|
129
|
-
op = body.call(thisArg, _);
|
|
130
|
-
} catch (e) {
|
|
131
|
-
op = [6, e];
|
|
132
|
-
y = 0;
|
|
133
|
-
} finally {
|
|
134
|
-
f = t = 0;
|
|
135
|
-
}
|
|
136
|
-
if (op[0] & 5) throw op[1];
|
|
137
|
-
return {
|
|
138
|
-
value: op[0] ? op[1] : void 0,
|
|
139
|
-
done: true
|
|
140
|
-
};
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
function __values(o) {
|
|
144
|
-
var s = typeof Symbol === "function" && Symbol.iterator,
|
|
145
|
-
m = s && o[s],
|
|
146
|
-
i = 0;
|
|
147
|
-
if (m) return m.call(o);
|
|
148
|
-
if (o && typeof o.length === "number") return {
|
|
149
|
-
next: function () {
|
|
150
|
-
if (o && i >= o.length) o = void 0;
|
|
151
|
-
return {
|
|
152
|
-
value: o && o[i++],
|
|
153
|
-
done: !o
|
|
154
|
-
};
|
|
155
|
-
}
|
|
156
|
-
};
|
|
157
|
-
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
158
|
-
}
|
|
159
|
-
function __read(o, n) {
|
|
160
|
-
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
161
|
-
if (!m) return o;
|
|
162
|
-
var i = m.call(o),
|
|
163
|
-
r,
|
|
164
|
-
ar = [],
|
|
165
|
-
e;
|
|
166
|
-
try {
|
|
167
|
-
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
168
|
-
} catch (error) {
|
|
169
|
-
e = {
|
|
170
|
-
error: error
|
|
171
|
-
};
|
|
172
|
-
} finally {
|
|
173
|
-
try {
|
|
174
|
-
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
175
|
-
} finally {
|
|
176
|
-
if (e) throw e.error;
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
return ar;
|
|
180
|
-
}
|
|
181
|
-
function __spread() {
|
|
182
|
-
for (var ar = [], i = 0; i < arguments.length; i++) ar = ar.concat(__read(arguments[i]));
|
|
183
|
-
return ar;
|
|
184
|
-
}
|
|
4
|
+
|
|
185
5
|
function createCommonjsModule(fn) {
|
|
186
6
|
var module = {
|
|
187
7
|
exports: {}
|
|
@@ -357,29 +177,26 @@ var _EVA_IIFE_EVA = function (exports, pixi_js) {
|
|
|
357
177
|
return component.componentName;
|
|
358
178
|
}
|
|
359
179
|
}
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
_this.__componentDefaultParams = params;
|
|
367
|
-
return _this;
|
|
180
|
+
class Component extends EE {
|
|
181
|
+
constructor(params) {
|
|
182
|
+
super();
|
|
183
|
+
this.started = false;
|
|
184
|
+
this.name = this.constructor.componentName;
|
|
185
|
+
this.__componentDefaultParams = params;
|
|
368
186
|
}
|
|
369
|
-
|
|
370
|
-
}(EE);
|
|
187
|
+
}
|
|
371
188
|
var Component$1 = Component;
|
|
372
189
|
var freeGlobal = typeof global == 'object' && global && global.Object === Object && global;
|
|
373
190
|
var freeGlobal$1 = freeGlobal;
|
|
374
191
|
var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
|
|
375
192
|
var root = freeGlobal$1 || freeSelf || Function('return this')();
|
|
376
193
|
var root$1 = root;
|
|
377
|
-
var Symbol
|
|
378
|
-
var Symbol$
|
|
194
|
+
var Symbol = root$1.Symbol;
|
|
195
|
+
var Symbol$1 = Symbol;
|
|
379
196
|
var objectProto$b = Object.prototype;
|
|
380
197
|
var hasOwnProperty$8 = objectProto$b.hasOwnProperty;
|
|
381
198
|
var nativeObjectToString$1 = objectProto$b.toString;
|
|
382
|
-
var symToStringTag$1 = Symbol$
|
|
199
|
+
var symToStringTag$1 = Symbol$1 ? Symbol$1.toStringTag : undefined;
|
|
383
200
|
function getRawTag(value) {
|
|
384
201
|
var isOwn = hasOwnProperty$8.call(value, symToStringTag$1),
|
|
385
202
|
tag = value[symToStringTag$1];
|
|
@@ -404,7 +221,7 @@ var _EVA_IIFE_EVA = function (exports, pixi_js) {
|
|
|
404
221
|
}
|
|
405
222
|
var nullTag = '[object Null]',
|
|
406
223
|
undefinedTag = '[object Undefined]';
|
|
407
|
-
var symToStringTag = Symbol$
|
|
224
|
+
var symToStringTag = Symbol$1 ? Symbol$1.toStringTag : undefined;
|
|
408
225
|
function baseGetTag(value) {
|
|
409
226
|
if (value == null) {
|
|
410
227
|
return value === undefined ? undefinedTag : nullTag;
|
|
@@ -1024,7 +841,7 @@ var _EVA_IIFE_EVA = function (exports, pixi_js) {
|
|
|
1024
841
|
symbolTag = '[object Symbol]';
|
|
1025
842
|
var arrayBufferTag = '[object ArrayBuffer]',
|
|
1026
843
|
dataViewTag = '[object DataView]';
|
|
1027
|
-
var symbolProto = Symbol$
|
|
844
|
+
var symbolProto = Symbol$1 ? Symbol$1.prototype : undefined,
|
|
1028
845
|
symbolValueOf = symbolProto ? symbolProto.valueOf : undefined;
|
|
1029
846
|
function equalByTag(object, other, tag, bitmask, customizer, equalFunc, stack) {
|
|
1030
847
|
switch (tag) {
|
|
@@ -1185,26 +1002,26 @@ var _EVA_IIFE_EVA = function (exports, pixi_js) {
|
|
|
1185
1002
|
ObserverType["REMOVE"] = "REMOVE";
|
|
1186
1003
|
ObserverType["CHANGE"] = "CHANGE";
|
|
1187
1004
|
})(exports.OBSERVER_TYPE || (exports.OBSERVER_TYPE = {}));
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1005
|
+
const objectCache = {};
|
|
1006
|
+
const systemInstance = {};
|
|
1007
|
+
const observerInfos = {};
|
|
1008
|
+
const componentProps = {};
|
|
1192
1009
|
function getObjectCache(component, keys) {
|
|
1193
1010
|
if (!objectCache[component.gameObject.id]) {
|
|
1194
1011
|
objectCache[component.gameObject.id] = {};
|
|
1195
1012
|
}
|
|
1196
|
-
|
|
1197
|
-
|
|
1013
|
+
const cache = objectCache[component.gameObject.id];
|
|
1014
|
+
const key = component.name + '_' + keys.join(',');
|
|
1198
1015
|
if (cache[key]) {
|
|
1199
1016
|
return cache[key];
|
|
1200
1017
|
}
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
for (
|
|
1018
|
+
const keyIndex = keys.length - 1;
|
|
1019
|
+
let property = component;
|
|
1020
|
+
for (let i = 0; i < keyIndex; i++) {
|
|
1204
1021
|
property = property[keys[i]];
|
|
1205
1022
|
}
|
|
1206
1023
|
cache[key] = {
|
|
1207
|
-
property
|
|
1024
|
+
property,
|
|
1208
1025
|
key: keys[keyIndex]
|
|
1209
1026
|
};
|
|
1210
1027
|
return cache[key];
|
|
@@ -1214,98 +1031,87 @@ var _EVA_IIFE_EVA = function (exports, pixi_js) {
|
|
|
1214
1031
|
delete objectCache[component.gameObject.id];
|
|
1215
1032
|
}
|
|
1216
1033
|
}
|
|
1217
|
-
function addObserver(
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1034
|
+
function addObserver({
|
|
1035
|
+
systemName,
|
|
1036
|
+
componentName,
|
|
1037
|
+
component,
|
|
1038
|
+
prop,
|
|
1039
|
+
type
|
|
1040
|
+
}) {
|
|
1041
|
+
var _a, _b;
|
|
1042
|
+
(_b = (_a = systemInstance[systemName]) === null || _a === void 0 ? void 0 : _a.componentObserver) === null || _b === void 0 ? void 0 : _b.add({
|
|
1043
|
+
component,
|
|
1044
|
+
prop,
|
|
1045
|
+
type,
|
|
1046
|
+
componentName
|
|
1229
1047
|
});
|
|
1230
1048
|
}
|
|
1231
|
-
function pushToQueue(
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1049
|
+
function pushToQueue({
|
|
1050
|
+
prop,
|
|
1051
|
+
component,
|
|
1052
|
+
componentName
|
|
1053
|
+
}) {
|
|
1054
|
+
for (const systemName in observerInfos) {
|
|
1055
|
+
const observerInfo = observerInfos[systemName] || {};
|
|
1056
|
+
const info = observerInfo[componentName];
|
|
1238
1057
|
if (!info) continue;
|
|
1239
|
-
|
|
1058
|
+
const index = info.findIndex(p => {
|
|
1240
1059
|
return isEqual(p, prop);
|
|
1241
1060
|
});
|
|
1242
1061
|
if (index > -1) {
|
|
1243
1062
|
addObserver({
|
|
1244
|
-
systemName
|
|
1245
|
-
componentName
|
|
1246
|
-
component
|
|
1247
|
-
prop
|
|
1063
|
+
systemName,
|
|
1064
|
+
componentName,
|
|
1065
|
+
component,
|
|
1066
|
+
prop,
|
|
1248
1067
|
type: exports.OBSERVER_TYPE.CHANGE
|
|
1249
1068
|
});
|
|
1250
1069
|
}
|
|
1251
1070
|
}
|
|
1252
1071
|
}
|
|
1253
|
-
function defineProperty(
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1072
|
+
function defineProperty({
|
|
1073
|
+
obj,
|
|
1074
|
+
key,
|
|
1075
|
+
prop,
|
|
1076
|
+
component,
|
|
1077
|
+
componentName
|
|
1078
|
+
}) {
|
|
1260
1079
|
if (obj === undefined) {
|
|
1261
1080
|
return;
|
|
1262
1081
|
}
|
|
1263
1082
|
if (!(key in obj)) {
|
|
1264
|
-
console.error(
|
|
1083
|
+
console.error(`prop ${key} not in component: ${componentName}, Can not observer`);
|
|
1265
1084
|
return;
|
|
1266
1085
|
}
|
|
1267
|
-
Object.defineProperty(obj,
|
|
1086
|
+
Object.defineProperty(obj, `_${key}`, {
|
|
1268
1087
|
enumerable: false,
|
|
1269
1088
|
writable: true,
|
|
1270
1089
|
value: obj[key]
|
|
1271
1090
|
});
|
|
1272
1091
|
if (prop.deep && isObject(obj[key])) {
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
componentName: componentName
|
|
1282
|
-
});
|
|
1283
|
-
}
|
|
1284
|
-
} catch (e_1_1) {
|
|
1285
|
-
e_1 = {
|
|
1286
|
-
error: e_1_1
|
|
1287
|
-
};
|
|
1288
|
-
} finally {
|
|
1289
|
-
try {
|
|
1290
|
-
if (_d && !_d.done && (_b = _c.return)) _b.call(_c);
|
|
1291
|
-
} finally {
|
|
1292
|
-
if (e_1) throw e_1.error;
|
|
1293
|
-
}
|
|
1092
|
+
for (const childKey of Object.keys(obj[key])) {
|
|
1093
|
+
defineProperty({
|
|
1094
|
+
obj: obj[key],
|
|
1095
|
+
key: childKey,
|
|
1096
|
+
prop,
|
|
1097
|
+
component,
|
|
1098
|
+
componentName
|
|
1099
|
+
});
|
|
1294
1100
|
}
|
|
1295
1101
|
}
|
|
1296
1102
|
Object.defineProperty(obj, key, {
|
|
1297
1103
|
enumerable: true,
|
|
1298
|
-
set
|
|
1299
|
-
if (obj[
|
|
1300
|
-
obj[
|
|
1104
|
+
set(val) {
|
|
1105
|
+
if (obj[`_${key}`] === val) return;
|
|
1106
|
+
obj[`_${key}`] = val;
|
|
1301
1107
|
pushToQueue({
|
|
1302
|
-
prop
|
|
1303
|
-
component
|
|
1304
|
-
componentName
|
|
1108
|
+
prop,
|
|
1109
|
+
component,
|
|
1110
|
+
componentName
|
|
1305
1111
|
});
|
|
1306
1112
|
},
|
|
1307
|
-
get
|
|
1308
|
-
return obj[
|
|
1113
|
+
get() {
|
|
1114
|
+
return obj[`_${key}`];
|
|
1309
1115
|
}
|
|
1310
1116
|
});
|
|
1311
1117
|
}
|
|
@@ -1313,62 +1119,28 @@ var _EVA_IIFE_EVA = function (exports, pixi_js) {
|
|
|
1313
1119
|
return comp && comp.constructor && 'componentName' in comp.constructor;
|
|
1314
1120
|
}
|
|
1315
1121
|
function initObserver(Systems) {
|
|
1316
|
-
|
|
1317
|
-
var Ss = [];
|
|
1122
|
+
const Ss = [];
|
|
1318
1123
|
if (Systems instanceof Array) {
|
|
1319
|
-
Ss.push
|
|
1124
|
+
Ss.push(...Systems);
|
|
1320
1125
|
} else {
|
|
1321
1126
|
Ss.push(Systems);
|
|
1322
1127
|
}
|
|
1323
|
-
|
|
1324
|
-
for (
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
if (index === -1) {
|
|
1334
|
-
componentProps[componentName].push(prop);
|
|
1335
|
-
}
|
|
1336
|
-
};
|
|
1337
|
-
try {
|
|
1338
|
-
for (var _c = (e_3 = void 0, __values(S.observerInfo[componentName])), _d = _c.next(); !_d.done; _d = _c.next()) {
|
|
1339
|
-
var prop = _d.value;
|
|
1340
|
-
_loop_1(prop);
|
|
1341
|
-
}
|
|
1342
|
-
} catch (e_3_1) {
|
|
1343
|
-
e_3 = {
|
|
1344
|
-
error: e_3_1
|
|
1345
|
-
};
|
|
1346
|
-
} finally {
|
|
1347
|
-
try {
|
|
1348
|
-
if (_d && !_d.done && (_b = _c.return)) _b.call(_c);
|
|
1349
|
-
} finally {
|
|
1350
|
-
if (e_3) throw e_3.error;
|
|
1351
|
-
}
|
|
1128
|
+
for (const S of Ss) {
|
|
1129
|
+
for (const componentName in S.observerInfo) {
|
|
1130
|
+
componentProps[componentName] = componentProps[componentName] || [];
|
|
1131
|
+
const props = componentProps[componentName];
|
|
1132
|
+
for (const prop of S.observerInfo[componentName]) {
|
|
1133
|
+
const index = props.findIndex(p => {
|
|
1134
|
+
return isEqual(p, prop);
|
|
1135
|
+
});
|
|
1136
|
+
if (index === -1) {
|
|
1137
|
+
componentProps[componentName].push(prop);
|
|
1352
1138
|
}
|
|
1353
1139
|
}
|
|
1354
1140
|
}
|
|
1355
|
-
} catch (e_2_1) {
|
|
1356
|
-
e_2 = {
|
|
1357
|
-
error: e_2_1
|
|
1358
|
-
};
|
|
1359
|
-
} finally {
|
|
1360
|
-
try {
|
|
1361
|
-
if (Ss_1_1 && !Ss_1_1.done && (_a = Ss_1.return)) _a.call(Ss_1);
|
|
1362
|
-
} finally {
|
|
1363
|
-
if (e_2) throw e_2.error;
|
|
1364
|
-
}
|
|
1365
1141
|
}
|
|
1366
1142
|
}
|
|
1367
|
-
function observer(component, componentName) {
|
|
1368
|
-
var e_4, _a;
|
|
1369
|
-
if (componentName === void 0) {
|
|
1370
|
-
componentName = component.name;
|
|
1371
|
-
}
|
|
1143
|
+
function observer(component, componentName = component.name) {
|
|
1372
1144
|
if (!componentName || !componentProps[componentName]) {
|
|
1373
1145
|
return;
|
|
1374
1146
|
}
|
|
@@ -1378,62 +1150,44 @@ var _EVA_IIFE_EVA = function (exports, pixi_js) {
|
|
|
1378
1150
|
if (!component.gameObject || !component.gameObject.id) {
|
|
1379
1151
|
throw new Error('component should be add to a gameObject');
|
|
1380
1152
|
}
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
});
|
|
1394
|
-
}
|
|
1395
|
-
} catch (e_4_1) {
|
|
1396
|
-
e_4 = {
|
|
1397
|
-
error: e_4_1
|
|
1398
|
-
};
|
|
1399
|
-
} finally {
|
|
1400
|
-
try {
|
|
1401
|
-
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
1402
|
-
} finally {
|
|
1403
|
-
if (e_4) throw e_4.error;
|
|
1404
|
-
}
|
|
1153
|
+
for (const item of componentProps[componentName]) {
|
|
1154
|
+
const {
|
|
1155
|
+
property,
|
|
1156
|
+
key
|
|
1157
|
+
} = getObjectCache(component, item.prop);
|
|
1158
|
+
defineProperty({
|
|
1159
|
+
obj: property,
|
|
1160
|
+
key,
|
|
1161
|
+
prop: item,
|
|
1162
|
+
component,
|
|
1163
|
+
componentName
|
|
1164
|
+
});
|
|
1405
1165
|
}
|
|
1406
1166
|
}
|
|
1407
|
-
function observerAdded(component, componentName) {
|
|
1167
|
+
function observerAdded(component, componentName = component.name) {
|
|
1408
1168
|
var _a, _b;
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
for (var systemName in observerInfos) {
|
|
1413
|
-
var observerInfo = observerInfos[systemName] || {};
|
|
1414
|
-
var info = observerInfo[componentName];
|
|
1169
|
+
for (const systemName in observerInfos) {
|
|
1170
|
+
const observerInfo = observerInfos[systemName] || {};
|
|
1171
|
+
const info = observerInfo[componentName];
|
|
1415
1172
|
if (info) {
|
|
1416
1173
|
(_b = (_a = systemInstance[systemName]) === null || _a === void 0 ? void 0 : _a.componentObserver) === null || _b === void 0 ? void 0 : _b.add({
|
|
1417
|
-
component
|
|
1174
|
+
component,
|
|
1418
1175
|
type: exports.OBSERVER_TYPE.ADD,
|
|
1419
|
-
componentName
|
|
1176
|
+
componentName
|
|
1420
1177
|
});
|
|
1421
1178
|
}
|
|
1422
1179
|
}
|
|
1423
1180
|
}
|
|
1424
|
-
function observerRemoved(component, componentName) {
|
|
1181
|
+
function observerRemoved(component, componentName = component.name) {
|
|
1425
1182
|
var _a, _b;
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
for (var systemName in observerInfos) {
|
|
1430
|
-
var observerInfo = observerInfos[systemName] || {};
|
|
1431
|
-
var info = observerInfo[componentName];
|
|
1183
|
+
for (const systemName in observerInfos) {
|
|
1184
|
+
const observerInfo = observerInfos[systemName] || {};
|
|
1185
|
+
const info = observerInfo[componentName];
|
|
1432
1186
|
if (info) {
|
|
1433
1187
|
(_b = (_a = systemInstance[systemName]) === null || _a === void 0 ? void 0 : _a.componentObserver) === null || _b === void 0 ? void 0 : _b.add({
|
|
1434
|
-
component
|
|
1188
|
+
component,
|
|
1435
1189
|
type: exports.OBSERVER_TYPE.REMOVE,
|
|
1436
|
-
componentName
|
|
1190
|
+
componentName
|
|
1437
1191
|
});
|
|
1438
1192
|
}
|
|
1439
1193
|
}
|
|
@@ -1443,6 +1197,40 @@ var _EVA_IIFE_EVA = function (exports, pixi_js) {
|
|
|
1443
1197
|
observerInfos[S.systemName] = S.observerInfo;
|
|
1444
1198
|
systemInstance[S.systemName] = system;
|
|
1445
1199
|
}
|
|
1200
|
+
function __decorate(decorators, target, key, desc) {
|
|
1201
|
+
var c = arguments.length,
|
|
1202
|
+
r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc,
|
|
1203
|
+
d;
|
|
1204
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
1205
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1206
|
+
}
|
|
1207
|
+
function __awaiter(thisArg, _arguments, P, generator) {
|
|
1208
|
+
function adopt(value) {
|
|
1209
|
+
return value instanceof P ? value : new P(function (resolve) {
|
|
1210
|
+
resolve(value);
|
|
1211
|
+
});
|
|
1212
|
+
}
|
|
1213
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
1214
|
+
function fulfilled(value) {
|
|
1215
|
+
try {
|
|
1216
|
+
step(generator.next(value));
|
|
1217
|
+
} catch (e) {
|
|
1218
|
+
reject(e);
|
|
1219
|
+
}
|
|
1220
|
+
}
|
|
1221
|
+
function rejected(value) {
|
|
1222
|
+
try {
|
|
1223
|
+
step(generator["throw"](value));
|
|
1224
|
+
} catch (e) {
|
|
1225
|
+
reject(e);
|
|
1226
|
+
}
|
|
1227
|
+
}
|
|
1228
|
+
function step(result) {
|
|
1229
|
+
result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
1230
|
+
}
|
|
1231
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
1232
|
+
});
|
|
1233
|
+
}
|
|
1446
1234
|
function getIDEPropsPropertyObj(target, propertyKey) {
|
|
1447
1235
|
if (!target.constructor.IDEProps) {
|
|
1448
1236
|
target.constructor.IDEProps = {};
|
|
@@ -1466,120 +1254,92 @@ var _EVA_IIFE_EVA = function (exports, pixi_js) {
|
|
|
1466
1254
|
prop.step = step;
|
|
1467
1255
|
};
|
|
1468
1256
|
}
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
_this.position = {
|
|
1257
|
+
class Transform extends Component$1 {
|
|
1258
|
+
constructor() {
|
|
1259
|
+
super(...arguments);
|
|
1260
|
+
this.name = 'Transform';
|
|
1261
|
+
this._parent = null;
|
|
1262
|
+
this.inScene = false;
|
|
1263
|
+
this.children = [];
|
|
1264
|
+
this.position = {
|
|
1478
1265
|
x: 0,
|
|
1479
1266
|
y: 0
|
|
1480
1267
|
};
|
|
1481
|
-
|
|
1268
|
+
this.size = {
|
|
1482
1269
|
width: 0,
|
|
1483
1270
|
height: 0
|
|
1484
1271
|
};
|
|
1485
|
-
|
|
1272
|
+
this.origin = {
|
|
1486
1273
|
x: 0,
|
|
1487
1274
|
y: 0
|
|
1488
1275
|
};
|
|
1489
|
-
|
|
1276
|
+
this.anchor = {
|
|
1490
1277
|
x: 0,
|
|
1491
1278
|
y: 0
|
|
1492
1279
|
};
|
|
1493
|
-
|
|
1280
|
+
this.scale = {
|
|
1494
1281
|
x: 1,
|
|
1495
1282
|
y: 1
|
|
1496
1283
|
};
|
|
1497
|
-
|
|
1284
|
+
this.skew = {
|
|
1498
1285
|
x: 0,
|
|
1499
1286
|
y: 0
|
|
1500
1287
|
};
|
|
1501
|
-
|
|
1502
|
-
return _this;
|
|
1288
|
+
this.rotation = 0;
|
|
1503
1289
|
}
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
params
|
|
1508
|
-
}
|
|
1509
|
-
var props = ['position', 'size', 'origin', 'anchor', 'scale', 'skew'];
|
|
1510
|
-
try {
|
|
1511
|
-
for (var props_1 = __values(props), props_1_1 = props_1.next(); !props_1_1.done; props_1_1 = props_1.next()) {
|
|
1512
|
-
var key = props_1_1.value;
|
|
1513
|
-
_extends(this[key], params[key]);
|
|
1514
|
-
}
|
|
1515
|
-
} catch (e_1_1) {
|
|
1516
|
-
e_1 = {
|
|
1517
|
-
error: e_1_1
|
|
1518
|
-
};
|
|
1519
|
-
} finally {
|
|
1520
|
-
try {
|
|
1521
|
-
if (props_1_1 && !props_1_1.done && (_a = props_1.return)) _a.call(props_1);
|
|
1522
|
-
} finally {
|
|
1523
|
-
if (e_1) throw e_1.error;
|
|
1524
|
-
}
|
|
1290
|
+
init(params = {}) {
|
|
1291
|
+
const props = ['position', 'size', 'origin', 'anchor', 'scale', 'skew'];
|
|
1292
|
+
for (const key of props) {
|
|
1293
|
+
_extends(this[key], params[key]);
|
|
1525
1294
|
}
|
|
1526
1295
|
this.rotation = params.rotation || this.rotation;
|
|
1527
|
-
}
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
}
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
enumerable: false,
|
|
1540
|
-
configurable: true
|
|
1541
|
-
});
|
|
1542
|
-
Transform.prototype.addChild = function (child) {
|
|
1296
|
+
}
|
|
1297
|
+
set parent(val) {
|
|
1298
|
+
if (val) {
|
|
1299
|
+
val.addChild(this);
|
|
1300
|
+
} else if (this.parent) {
|
|
1301
|
+
this.parent.removeChild(this);
|
|
1302
|
+
}
|
|
1303
|
+
}
|
|
1304
|
+
get parent() {
|
|
1305
|
+
return this._parent;
|
|
1306
|
+
}
|
|
1307
|
+
addChild(child) {
|
|
1543
1308
|
if (child.parent === this) {
|
|
1544
|
-
|
|
1545
|
-
return item === child;
|
|
1546
|
-
});
|
|
1309
|
+
const index = this.children.findIndex(item => item === child);
|
|
1547
1310
|
this.children.splice(index, 1);
|
|
1548
1311
|
} else if (child.parent) {
|
|
1549
1312
|
child.parent.removeChild(child);
|
|
1550
1313
|
}
|
|
1551
1314
|
child._parent = this;
|
|
1552
1315
|
this.children.push(child);
|
|
1553
|
-
}
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
return item === child;
|
|
1557
|
-
});
|
|
1316
|
+
}
|
|
1317
|
+
removeChild(child) {
|
|
1318
|
+
const index = this.children.findIndex(item => item === child);
|
|
1558
1319
|
if (index > -1) {
|
|
1559
1320
|
this.children.splice(index, 1);
|
|
1560
1321
|
child._parent = null;
|
|
1561
1322
|
}
|
|
1562
|
-
}
|
|
1563
|
-
|
|
1323
|
+
}
|
|
1324
|
+
clearChildren() {
|
|
1564
1325
|
this.children.length = 0;
|
|
1565
|
-
}
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
}(Component$1);
|
|
1326
|
+
}
|
|
1327
|
+
}
|
|
1328
|
+
Transform.componentName = 'Transform';
|
|
1329
|
+
__decorate([type('vector2'), step(1)], Transform.prototype, "position", void 0);
|
|
1330
|
+
__decorate([type('size'), step(1)], Transform.prototype, "size", void 0);
|
|
1331
|
+
__decorate([type('vector2'), step(0.1)], Transform.prototype, "origin", void 0);
|
|
1332
|
+
__decorate([type('vector2'), step(0.1)], Transform.prototype, "anchor", void 0);
|
|
1333
|
+
__decorate([type('vector2'), step(0.1)], Transform.prototype, "scale", void 0);
|
|
1334
|
+
__decorate([type('vector2'), step(0.1)], Transform.prototype, "skew", void 0);
|
|
1335
|
+
__decorate([type('number'), step(0.1)], Transform.prototype, "rotation", void 0);
|
|
1576
1336
|
var Transform$1 = Transform;
|
|
1577
|
-
|
|
1337
|
+
let _id = 0;
|
|
1578
1338
|
function getId() {
|
|
1579
1339
|
return ++_id;
|
|
1580
1340
|
}
|
|
1581
|
-
|
|
1582
|
-
|
|
1341
|
+
class GameObject {
|
|
1342
|
+
constructor(name, obj) {
|
|
1583
1343
|
this._componentCache = {};
|
|
1584
1344
|
this.components = [];
|
|
1585
1345
|
this.destroyed = false;
|
|
@@ -1587,87 +1347,57 @@ var _EVA_IIFE_EVA = function (exports, pixi_js) {
|
|
|
1587
1347
|
this.id = getId();
|
|
1588
1348
|
this.addComponent(Transform$1, obj);
|
|
1589
1349
|
}
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
return this._name;
|
|
1607
|
-
},
|
|
1608
|
-
enumerable: false,
|
|
1609
|
-
configurable: true
|
|
1610
|
-
});
|
|
1611
|
-
Object.defineProperty(GameObject.prototype, "scene", {
|
|
1612
|
-
get: function () {
|
|
1613
|
-
return this._scene;
|
|
1614
|
-
},
|
|
1615
|
-
set: function (val) {
|
|
1616
|
-
var e_1, _a;
|
|
1617
|
-
if (this._scene === val) return;
|
|
1618
|
-
var scene = this._scene;
|
|
1619
|
-
this._scene = val;
|
|
1620
|
-
if (this.transform && this.transform.children) {
|
|
1621
|
-
try {
|
|
1622
|
-
for (var _b = __values(this.transform.children), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
1623
|
-
var child = _c.value;
|
|
1624
|
-
child.gameObject.scene = val;
|
|
1625
|
-
}
|
|
1626
|
-
} catch (e_1_1) {
|
|
1627
|
-
e_1 = {
|
|
1628
|
-
error: e_1_1
|
|
1629
|
-
};
|
|
1630
|
-
} finally {
|
|
1631
|
-
try {
|
|
1632
|
-
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
1633
|
-
} finally {
|
|
1634
|
-
if (e_1) throw e_1.error;
|
|
1635
|
-
}
|
|
1636
|
-
}
|
|
1637
|
-
}
|
|
1638
|
-
if (val) {
|
|
1639
|
-
val.addGameObject(this);
|
|
1640
|
-
} else {
|
|
1641
|
-
scene && scene.removeGameObject(this);
|
|
1350
|
+
get transform() {
|
|
1351
|
+
return this.getComponent(Transform$1);
|
|
1352
|
+
}
|
|
1353
|
+
get parent() {
|
|
1354
|
+
return this.transform && this.transform.parent && this.transform.parent.gameObject;
|
|
1355
|
+
}
|
|
1356
|
+
get name() {
|
|
1357
|
+
return this._name;
|
|
1358
|
+
}
|
|
1359
|
+
set scene(val) {
|
|
1360
|
+
if (this._scene === val) return;
|
|
1361
|
+
const scene = this._scene;
|
|
1362
|
+
this._scene = val;
|
|
1363
|
+
if (this.transform && this.transform.children) {
|
|
1364
|
+
for (const child of this.transform.children) {
|
|
1365
|
+
child.gameObject.scene = val;
|
|
1642
1366
|
}
|
|
1643
|
-
}
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
|
|
1367
|
+
}
|
|
1368
|
+
if (val) {
|
|
1369
|
+
val.addGameObject(this);
|
|
1370
|
+
} else {
|
|
1371
|
+
scene && scene.removeGameObject(this);
|
|
1372
|
+
}
|
|
1373
|
+
}
|
|
1374
|
+
get scene() {
|
|
1375
|
+
return this._scene;
|
|
1376
|
+
}
|
|
1377
|
+
addChild(gameObject) {
|
|
1648
1378
|
if (!gameObject || !gameObject.transform || gameObject === this) return;
|
|
1649
1379
|
if (!(gameObject instanceof GameObject)) {
|
|
1650
1380
|
throw new Error('addChild only receive GameObject');
|
|
1651
1381
|
}
|
|
1652
1382
|
if (!this.transform) {
|
|
1653
|
-
throw new Error(
|
|
1383
|
+
throw new Error(`gameObject '${this.name}' has been destroy`);
|
|
1654
1384
|
}
|
|
1655
1385
|
gameObject.transform.parent = this.transform;
|
|
1656
1386
|
gameObject.scene = this.scene;
|
|
1657
|
-
}
|
|
1658
|
-
|
|
1387
|
+
}
|
|
1388
|
+
removeChild(gameObject) {
|
|
1659
1389
|
if (!(gameObject instanceof GameObject) || !gameObject.parent || gameObject.parent !== this) {
|
|
1660
1390
|
return gameObject;
|
|
1661
1391
|
}
|
|
1662
1392
|
gameObject.transform.parent = null;
|
|
1663
1393
|
gameObject.scene = null;
|
|
1664
1394
|
return gameObject;
|
|
1665
|
-
}
|
|
1666
|
-
|
|
1395
|
+
}
|
|
1396
|
+
addComponent(C, obj) {
|
|
1667
1397
|
if (this.destroyed) return;
|
|
1668
|
-
|
|
1398
|
+
const componentName = getComponentName(C);
|
|
1669
1399
|
if (this._componentCache[componentName]) return;
|
|
1670
|
-
|
|
1400
|
+
let component;
|
|
1671
1401
|
if (C instanceof Function) {
|
|
1672
1402
|
component = new C(obj);
|
|
1673
1403
|
} else if (C instanceof Component$1) {
|
|
@@ -1676,7 +1406,7 @@ var _EVA_IIFE_EVA = function (exports, pixi_js) {
|
|
|
1676
1406
|
throw new Error('addComponent recieve Component and Component Constructor');
|
|
1677
1407
|
}
|
|
1678
1408
|
if (component.gameObject) {
|
|
1679
|
-
throw new Error(
|
|
1409
|
+
throw new Error(`component has been added on gameObject ${component.gameObject.name}`);
|
|
1680
1410
|
}
|
|
1681
1411
|
component.gameObject = this;
|
|
1682
1412
|
component.init && component.init(component.__componentDefaultParams);
|
|
@@ -1686,9 +1416,9 @@ var _EVA_IIFE_EVA = function (exports, pixi_js) {
|
|
|
1686
1416
|
this._componentCache[componentName] = component;
|
|
1687
1417
|
component.awake && component.awake();
|
|
1688
1418
|
return component;
|
|
1689
|
-
}
|
|
1690
|
-
|
|
1691
|
-
|
|
1419
|
+
}
|
|
1420
|
+
removeComponent(c) {
|
|
1421
|
+
let componentName;
|
|
1692
1422
|
if (typeof c === 'string') {
|
|
1693
1423
|
componentName = c;
|
|
1694
1424
|
} else if (c instanceof Component$1) {
|
|
@@ -1700,23 +1430,22 @@ var _EVA_IIFE_EVA = function (exports, pixi_js) {
|
|
|
1700
1430
|
throw new Error("Transform can't be removed");
|
|
1701
1431
|
}
|
|
1702
1432
|
return this._removeComponent(componentName);
|
|
1703
|
-
}
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
});
|
|
1433
|
+
}
|
|
1434
|
+
_removeComponent(componentName) {
|
|
1435
|
+
const index = this.components.findIndex(({
|
|
1436
|
+
name
|
|
1437
|
+
}) => name === componentName);
|
|
1709
1438
|
if (index === -1) return;
|
|
1710
|
-
|
|
1439
|
+
const component = this.components.splice(index, 1)[0];
|
|
1711
1440
|
delete this._componentCache[componentName];
|
|
1712
1441
|
delete component.__componentDefaultParams;
|
|
1713
1442
|
component.onDestroy && component.onDestroy();
|
|
1714
1443
|
observerRemoved(component, componentName);
|
|
1715
1444
|
component.gameObject = undefined;
|
|
1716
1445
|
return component;
|
|
1717
|
-
}
|
|
1718
|
-
|
|
1719
|
-
|
|
1446
|
+
}
|
|
1447
|
+
getComponent(c) {
|
|
1448
|
+
let componentName;
|
|
1720
1449
|
if (typeof c === 'string') {
|
|
1721
1450
|
componentName = c;
|
|
1722
1451
|
} else if (c instanceof Component$1) {
|
|
@@ -1729,118 +1458,103 @@ var _EVA_IIFE_EVA = function (exports, pixi_js) {
|
|
|
1729
1458
|
} else {
|
|
1730
1459
|
return;
|
|
1731
1460
|
}
|
|
1732
|
-
}
|
|
1733
|
-
|
|
1461
|
+
}
|
|
1462
|
+
remove() {
|
|
1734
1463
|
if (this.parent) return this.parent.removeChild(this);
|
|
1735
|
-
}
|
|
1736
|
-
|
|
1464
|
+
}
|
|
1465
|
+
destroy() {
|
|
1737
1466
|
if (!this.transform) {
|
|
1738
1467
|
console.error('Cannot destroy gameObject that have already been destroyed.');
|
|
1739
1468
|
return;
|
|
1740
1469
|
}
|
|
1741
|
-
Array.from(this.transform.children).forEach(
|
|
1742
|
-
|
|
1470
|
+
Array.from(this.transform.children).forEach(({
|
|
1471
|
+
gameObject
|
|
1472
|
+
}) => {
|
|
1743
1473
|
gameObject.destroy();
|
|
1744
1474
|
});
|
|
1745
1475
|
this.remove();
|
|
1746
1476
|
this.transform.clearChildren();
|
|
1747
|
-
for (
|
|
1477
|
+
for (const key in this._componentCache) {
|
|
1748
1478
|
this._removeComponent(key);
|
|
1749
1479
|
}
|
|
1750
1480
|
this.components.length = 0;
|
|
1751
1481
|
this.destroyed = true;
|
|
1752
|
-
}
|
|
1753
|
-
|
|
1754
|
-
}();
|
|
1482
|
+
}
|
|
1483
|
+
}
|
|
1755
1484
|
var GameObject$1 = GameObject;
|
|
1756
|
-
|
|
1757
|
-
|
|
1485
|
+
class ComponentObserver {
|
|
1486
|
+
constructor() {
|
|
1758
1487
|
this.events = [];
|
|
1759
1488
|
}
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
|
|
1763
|
-
|
|
1764
|
-
|
|
1489
|
+
add({
|
|
1490
|
+
component,
|
|
1491
|
+
prop,
|
|
1492
|
+
type,
|
|
1493
|
+
componentName
|
|
1494
|
+
}) {
|
|
1765
1495
|
if (type === exports.OBSERVER_TYPE.REMOVE) {
|
|
1766
|
-
if (this.events.find(
|
|
1767
|
-
|
|
1768
|
-
})) {
|
|
1769
|
-
this.events = this.events.filter(function (changed) {
|
|
1770
|
-
return changed.component !== component;
|
|
1771
|
-
});
|
|
1496
|
+
if (this.events.find(changed => changed.component === component && changed.type === exports.OBSERVER_TYPE.ADD)) {
|
|
1497
|
+
this.events = this.events.filter(changed => changed.component !== component);
|
|
1772
1498
|
return;
|
|
1773
1499
|
}
|
|
1774
|
-
this.events = this.events.filter(
|
|
1775
|
-
return changed.component !== component;
|
|
1776
|
-
});
|
|
1500
|
+
this.events = this.events.filter(changed => changed.component !== component);
|
|
1777
1501
|
}
|
|
1778
|
-
|
|
1779
|
-
return changed.component === component && isEqual(changed.prop, prop) && changed.type === type;
|
|
1780
|
-
});
|
|
1502
|
+
const index = this.events.findIndex(changed => changed.component === component && isEqual(changed.prop, prop) && changed.type === type);
|
|
1781
1503
|
if (index > -1) {
|
|
1782
1504
|
this.events.splice(index, 1);
|
|
1783
1505
|
}
|
|
1784
1506
|
this.events.push({
|
|
1785
1507
|
gameObject: component.gameObject,
|
|
1786
|
-
component
|
|
1508
|
+
component,
|
|
1787
1509
|
prop: prop,
|
|
1788
|
-
type
|
|
1789
|
-
componentName
|
|
1510
|
+
type,
|
|
1511
|
+
componentName
|
|
1790
1512
|
});
|
|
1791
|
-
}
|
|
1792
|
-
|
|
1513
|
+
}
|
|
1514
|
+
getChanged() {
|
|
1793
1515
|
return this.events;
|
|
1794
|
-
}
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
configurable: true
|
|
1801
|
-
});
|
|
1802
|
-
ComponentObserver.prototype.clear = function () {
|
|
1803
|
-
var events = this.events;
|
|
1516
|
+
}
|
|
1517
|
+
get changed() {
|
|
1518
|
+
return this.events;
|
|
1519
|
+
}
|
|
1520
|
+
clear() {
|
|
1521
|
+
const events = this.events;
|
|
1804
1522
|
this.events = [];
|
|
1805
1523
|
return events;
|
|
1806
|
-
}
|
|
1807
|
-
|
|
1808
|
-
}();
|
|
1524
|
+
}
|
|
1525
|
+
}
|
|
1809
1526
|
var ComponentObserver$1 = ComponentObserver;
|
|
1810
|
-
|
|
1811
|
-
|
|
1527
|
+
class System {
|
|
1528
|
+
constructor(params) {
|
|
1812
1529
|
this.started = false;
|
|
1813
1530
|
this.componentObserver = new ComponentObserver$1();
|
|
1814
1531
|
this.__systemDefaultParams = params;
|
|
1815
1532
|
this.name = this.constructor.systemName;
|
|
1816
1533
|
}
|
|
1817
|
-
|
|
1534
|
+
destroy() {
|
|
1818
1535
|
var _a;
|
|
1819
1536
|
this.componentObserver = null;
|
|
1820
1537
|
this.__systemDefaultParams = null;
|
|
1821
1538
|
(_a = this.onDestroy) === null || _a === void 0 ? void 0 : _a.call(this);
|
|
1822
|
-
}
|
|
1823
|
-
|
|
1824
|
-
}();
|
|
1539
|
+
}
|
|
1540
|
+
}
|
|
1825
1541
|
var System$1 = System;
|
|
1826
1542
|
function createNowTime() {
|
|
1827
|
-
|
|
1543
|
+
let nowtime = null;
|
|
1828
1544
|
if (Date.now) {
|
|
1829
1545
|
nowtime = Date.now;
|
|
1830
1546
|
} else {
|
|
1831
|
-
nowtime =
|
|
1832
|
-
return new Date().getTime();
|
|
1833
|
-
};
|
|
1547
|
+
nowtime = () => new Date().getTime();
|
|
1834
1548
|
}
|
|
1835
1549
|
return nowtime;
|
|
1836
1550
|
}
|
|
1837
|
-
|
|
1838
|
-
|
|
1551
|
+
const _nowtime = createNowTime();
|
|
1552
|
+
const defaultOptions$1 = {
|
|
1839
1553
|
originTime: 0,
|
|
1840
1554
|
playbackRate: 1.0
|
|
1841
1555
|
};
|
|
1842
|
-
|
|
1843
|
-
|
|
1556
|
+
class Timeline {
|
|
1557
|
+
constructor(options, parent) {
|
|
1844
1558
|
if (options instanceof Timeline) {
|
|
1845
1559
|
parent = options;
|
|
1846
1560
|
options = {};
|
|
@@ -1862,110 +1576,89 @@ var _EVA_IIFE_EVA = function (exports, pixi_js) {
|
|
|
1862
1576
|
}
|
|
1863
1577
|
this._playbackRate = options.playbackRate;
|
|
1864
1578
|
}
|
|
1865
|
-
|
|
1866
|
-
|
|
1867
|
-
|
|
1868
|
-
|
|
1869
|
-
|
|
1870
|
-
|
|
1871
|
-
|
|
1872
|
-
|
|
1873
|
-
|
|
1874
|
-
|
|
1875
|
-
|
|
1876
|
-
|
|
1877
|
-
|
|
1878
|
-
})
|
|
1879
|
-
|
|
1880
|
-
get: function () {
|
|
1881
|
-
return this._timeMark[this._timeMark.length - 1];
|
|
1882
|
-
},
|
|
1883
|
-
enumerable: false,
|
|
1884
|
-
configurable: true
|
|
1885
|
-
});
|
|
1886
|
-
Timeline.prototype.markTime = function (_a) {
|
|
1887
|
-
var _b = _a === void 0 ? {} : _a,
|
|
1888
|
-
_c = _b.time,
|
|
1889
|
-
time = _c === void 0 ? this.currentTime : _c,
|
|
1890
|
-
_d = _b.entropy,
|
|
1891
|
-
entropy = _d === void 0 ? this.entropy : _d,
|
|
1892
|
-
_e = _b.playbackRate,
|
|
1893
|
-
playbackRate = _e === void 0 ? this.playbackRate : _e;
|
|
1894
|
-
var timeMark = {
|
|
1579
|
+
get globalTime() {
|
|
1580
|
+
return this.parent ? this.parent.currentTime : _nowtime() - this._createTime;
|
|
1581
|
+
}
|
|
1582
|
+
get parent() {
|
|
1583
|
+
return this._parent;
|
|
1584
|
+
}
|
|
1585
|
+
get lastTimeMark() {
|
|
1586
|
+
return this._timeMark[this._timeMark.length - 1];
|
|
1587
|
+
}
|
|
1588
|
+
markTime({
|
|
1589
|
+
time = this.currentTime,
|
|
1590
|
+
entropy = this.entropy,
|
|
1591
|
+
playbackRate = this.playbackRate
|
|
1592
|
+
} = {}) {
|
|
1593
|
+
const timeMark = {
|
|
1895
1594
|
globalTime: this.globalTime,
|
|
1896
1595
|
localTime: time,
|
|
1897
|
-
entropy
|
|
1898
|
-
playbackRate
|
|
1596
|
+
entropy,
|
|
1597
|
+
playbackRate,
|
|
1899
1598
|
globalEntropy: this.globalEntropy
|
|
1900
1599
|
};
|
|
1901
1600
|
this._timeMark.push(timeMark);
|
|
1902
|
-
}
|
|
1903
|
-
|
|
1904
|
-
|
|
1905
|
-
|
|
1906
|
-
|
|
1907
|
-
|
|
1908
|
-
|
|
1909
|
-
|
|
1910
|
-
|
|
1911
|
-
|
|
1912
|
-
|
|
1913
|
-
|
|
1914
|
-
|
|
1915
|
-
|
|
1916
|
-
|
|
1917
|
-
}
|
|
1918
|
-
|
|
1919
|
-
|
|
1920
|
-
|
|
1921
|
-
|
|
1922
|
-
|
|
1923
|
-
|
|
1924
|
-
}
|
|
1925
|
-
|
|
1926
|
-
|
|
1927
|
-
|
|
1928
|
-
|
|
1929
|
-
|
|
1930
|
-
|
|
1931
|
-
|
|
1932
|
-
|
|
1933
|
-
|
|
1934
|
-
|
|
1935
|
-
this._timeMark.length = idx + 1;
|
|
1936
|
-
}
|
|
1937
|
-
this.markTime({
|
|
1938
|
-
entropy: entropy
|
|
1939
|
-
});
|
|
1940
|
-
},
|
|
1941
|
-
enumerable: false,
|
|
1942
|
-
configurable: true
|
|
1943
|
-
});
|
|
1944
|
-
Timeline.prototype.fork = function (options) {
|
|
1601
|
+
}
|
|
1602
|
+
get currentTime() {
|
|
1603
|
+
const {
|
|
1604
|
+
localTime,
|
|
1605
|
+
globalTime
|
|
1606
|
+
} = this.lastTimeMark;
|
|
1607
|
+
return localTime + (this.globalTime - globalTime) * this.playbackRate;
|
|
1608
|
+
}
|
|
1609
|
+
set currentTime(time) {
|
|
1610
|
+
this.markTime({
|
|
1611
|
+
time
|
|
1612
|
+
});
|
|
1613
|
+
}
|
|
1614
|
+
get globalEntropy() {
|
|
1615
|
+
return this._parent ? this._parent.entropy : this.globalTime;
|
|
1616
|
+
}
|
|
1617
|
+
get entropy() {
|
|
1618
|
+
const {
|
|
1619
|
+
entropy,
|
|
1620
|
+
globalEntropy
|
|
1621
|
+
} = this.lastTimeMark;
|
|
1622
|
+
return entropy + Math.abs((this.globalEntropy - globalEntropy) * this.playbackRate);
|
|
1623
|
+
}
|
|
1624
|
+
set entropy(entropy) {
|
|
1625
|
+
if (this.entropy > entropy) {
|
|
1626
|
+
const idx = this.seekTimeMark(entropy);
|
|
1627
|
+
this._timeMark.length = idx + 1;
|
|
1628
|
+
}
|
|
1629
|
+
this.markTime({
|
|
1630
|
+
entropy
|
|
1631
|
+
});
|
|
1632
|
+
}
|
|
1633
|
+
fork(options) {
|
|
1945
1634
|
return new Timeline(options, this);
|
|
1946
|
-
}
|
|
1947
|
-
|
|
1948
|
-
|
|
1635
|
+
}
|
|
1636
|
+
seekGlobalTime(seekEntropy) {
|
|
1637
|
+
const idx = this.seekTimeMark(seekEntropy),
|
|
1949
1638
|
timeMark = this._timeMark[idx];
|
|
1950
|
-
|
|
1951
|
-
|
|
1952
|
-
|
|
1639
|
+
const {
|
|
1640
|
+
entropy,
|
|
1641
|
+
playbackRate,
|
|
1642
|
+
globalTime
|
|
1643
|
+
} = timeMark;
|
|
1953
1644
|
return globalTime + (seekEntropy - entropy) / Math.abs(playbackRate);
|
|
1954
|
-
}
|
|
1955
|
-
|
|
1956
|
-
|
|
1645
|
+
}
|
|
1646
|
+
seekLocalTime(seekEntropy) {
|
|
1647
|
+
const idx = this.seekTimeMark(seekEntropy),
|
|
1957
1648
|
timeMark = this._timeMark[idx];
|
|
1958
|
-
|
|
1959
|
-
|
|
1960
|
-
|
|
1649
|
+
const {
|
|
1650
|
+
localTime,
|
|
1651
|
+
entropy,
|
|
1652
|
+
playbackRate
|
|
1653
|
+
} = timeMark;
|
|
1961
1654
|
if (playbackRate > 0) {
|
|
1962
1655
|
return localTime + (seekEntropy - entropy);
|
|
1963
1656
|
}
|
|
1964
1657
|
return localTime - (seekEntropy - entropy);
|
|
1965
|
-
}
|
|
1966
|
-
|
|
1967
|
-
|
|
1968
|
-
|
|
1658
|
+
}
|
|
1659
|
+
seekTimeMark(entropy) {
|
|
1660
|
+
const timeMark = this._timeMark;
|
|
1661
|
+
let l = 0,
|
|
1969
1662
|
r = timeMark.length - 1;
|
|
1970
1663
|
if (entropy <= timeMark[l].entropy) {
|
|
1971
1664
|
return l;
|
|
@@ -1973,7 +1666,7 @@ var _EVA_IIFE_EVA = function (exports, pixi_js) {
|
|
|
1973
1666
|
if (entropy >= timeMark[r].entropy) {
|
|
1974
1667
|
return r;
|
|
1975
1668
|
}
|
|
1976
|
-
|
|
1669
|
+
let m = Math.floor((l + r) / 2);
|
|
1977
1670
|
while (m > l && m < r) {
|
|
1978
1671
|
if (entropy === timeMark[m].entropy) {
|
|
1979
1672
|
return m;
|
|
@@ -1986,45 +1679,35 @@ var _EVA_IIFE_EVA = function (exports, pixi_js) {
|
|
|
1986
1679
|
m = Math.floor((l + r) / 2);
|
|
1987
1680
|
}
|
|
1988
1681
|
return l;
|
|
1989
|
-
}
|
|
1990
|
-
|
|
1991
|
-
|
|
1992
|
-
|
|
1993
|
-
|
|
1994
|
-
|
|
1995
|
-
|
|
1996
|
-
|
|
1997
|
-
|
|
1998
|
-
|
|
1999
|
-
|
|
2000
|
-
|
|
2001
|
-
|
|
2002
|
-
|
|
2003
|
-
|
|
2004
|
-
|
|
2005
|
-
|
|
2006
|
-
|
|
2007
|
-
|
|
2008
|
-
|
|
2009
|
-
|
|
2010
|
-
|
|
2011
|
-
parent = parent.parent;
|
|
2012
|
-
}
|
|
2013
|
-
return false;
|
|
2014
|
-
},
|
|
2015
|
-
enumerable: false,
|
|
2016
|
-
configurable: true
|
|
2017
|
-
});
|
|
2018
|
-
return Timeline;
|
|
2019
|
-
}();
|
|
1682
|
+
}
|
|
1683
|
+
get playbackRate() {
|
|
1684
|
+
return this._playbackRate;
|
|
1685
|
+
}
|
|
1686
|
+
set playbackRate(rate) {
|
|
1687
|
+
if (rate !== this.playbackRate) {
|
|
1688
|
+
this.markTime({
|
|
1689
|
+
playbackRate: rate
|
|
1690
|
+
});
|
|
1691
|
+
this._playbackRate = rate;
|
|
1692
|
+
}
|
|
1693
|
+
}
|
|
1694
|
+
get paused() {
|
|
1695
|
+
if (this.playbackRate === 0) return true;
|
|
1696
|
+
let parent = this.parent;
|
|
1697
|
+
while (parent) {
|
|
1698
|
+
if (parent.playbackRate === 0) return true;
|
|
1699
|
+
parent = parent.parent;
|
|
1700
|
+
}
|
|
1701
|
+
return false;
|
|
1702
|
+
}
|
|
1703
|
+
}
|
|
2020
1704
|
var Timeline$1 = Timeline;
|
|
2021
|
-
|
|
1705
|
+
const defaultOptions = {
|
|
2022
1706
|
autoStart: true,
|
|
2023
1707
|
frameRate: 60
|
|
2024
1708
|
};
|
|
2025
|
-
|
|
2026
|
-
|
|
2027
|
-
var _this = this;
|
|
1709
|
+
class Ticker {
|
|
1710
|
+
constructor(options) {
|
|
2028
1711
|
options = _extends({}, defaultOptions, options);
|
|
2029
1712
|
this._frameCount = 0;
|
|
2030
1713
|
this._frameDuration = 1000 / options.frameRate;
|
|
@@ -2037,603 +1720,325 @@ var _EVA_IIFE_EVA = function (exports, pixi_js) {
|
|
|
2037
1720
|
this._lastFrameTime = this.timeline.currentTime;
|
|
2038
1721
|
this._tickers = new Set();
|
|
2039
1722
|
this._requestId = null;
|
|
2040
|
-
this._ticker =
|
|
2041
|
-
if (
|
|
2042
|
-
|
|
2043
|
-
|
|
1723
|
+
this._ticker = () => {
|
|
1724
|
+
if (this._started) {
|
|
1725
|
+
this._requestId = requestAnimationFrame(this._ticker);
|
|
1726
|
+
this.update();
|
|
2044
1727
|
}
|
|
2045
1728
|
};
|
|
2046
1729
|
if (this.autoStart) {
|
|
2047
1730
|
this.start();
|
|
2048
1731
|
}
|
|
2049
1732
|
}
|
|
2050
|
-
|
|
2051
|
-
|
|
2052
|
-
|
|
2053
|
-
var durationTime = currentTime - this._lastFrameTime;
|
|
1733
|
+
update() {
|
|
1734
|
+
const currentTime = this.timeline.currentTime;
|
|
1735
|
+
const durationTime = currentTime - this._lastFrameTime;
|
|
2054
1736
|
if (durationTime >= this._frameDuration) {
|
|
2055
|
-
|
|
2056
|
-
|
|
1737
|
+
const frameTime = currentTime - durationTime % this._frameDuration;
|
|
1738
|
+
const deltaTime = frameTime - this._lastFrameTime;
|
|
2057
1739
|
this._lastFrameTime = frameTime;
|
|
2058
|
-
|
|
2059
|
-
deltaTime
|
|
1740
|
+
const options = {
|
|
1741
|
+
deltaTime,
|
|
2060
1742
|
time: frameTime,
|
|
2061
1743
|
currentTime: frameTime,
|
|
2062
1744
|
frameCount: ++this._frameCount,
|
|
2063
1745
|
fps: Math.round(1000 / deltaTime)
|
|
2064
1746
|
};
|
|
2065
|
-
|
|
2066
|
-
|
|
2067
|
-
|
|
2068
|
-
if (typeof func === 'function') {
|
|
2069
|
-
func(options);
|
|
2070
|
-
}
|
|
2071
|
-
}
|
|
2072
|
-
} catch (e_1_1) {
|
|
2073
|
-
e_1 = {
|
|
2074
|
-
error: e_1_1
|
|
2075
|
-
};
|
|
2076
|
-
} finally {
|
|
2077
|
-
try {
|
|
2078
|
-
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
2079
|
-
} finally {
|
|
2080
|
-
if (e_1) throw e_1.error;
|
|
1747
|
+
for (const func of this._tickers) {
|
|
1748
|
+
if (typeof func === 'function') {
|
|
1749
|
+
func(options);
|
|
2081
1750
|
}
|
|
2082
1751
|
}
|
|
2083
1752
|
}
|
|
2084
|
-
}
|
|
2085
|
-
|
|
1753
|
+
}
|
|
1754
|
+
add(fn) {
|
|
2086
1755
|
this._tickers.add(fn);
|
|
2087
|
-
}
|
|
2088
|
-
|
|
1756
|
+
}
|
|
1757
|
+
remove(fn) {
|
|
2089
1758
|
this._tickers.delete(fn);
|
|
2090
|
-
}
|
|
2091
|
-
|
|
1759
|
+
}
|
|
1760
|
+
start() {
|
|
2092
1761
|
if (this._started) return;
|
|
2093
1762
|
this._started = true;
|
|
2094
1763
|
this.timeline.playbackRate = 1.0;
|
|
2095
1764
|
this._requestId = requestAnimationFrame(this._ticker);
|
|
2096
|
-
}
|
|
2097
|
-
|
|
1765
|
+
}
|
|
1766
|
+
pause() {
|
|
2098
1767
|
this._started = false;
|
|
2099
1768
|
this.timeline.playbackRate = 0;
|
|
2100
|
-
}
|
|
2101
|
-
|
|
1769
|
+
}
|
|
1770
|
+
setPlaybackRate(rate) {
|
|
2102
1771
|
this.timeline.playbackRate = rate;
|
|
2103
|
-
}
|
|
2104
|
-
|
|
2105
|
-
}();
|
|
1772
|
+
}
|
|
1773
|
+
}
|
|
2106
1774
|
var Ticker$1 = Ticker;
|
|
2107
|
-
|
|
2108
|
-
|
|
2109
|
-
|
|
2110
|
-
|
|
2111
|
-
|
|
2112
|
-
_this.scene = _this;
|
|
2113
|
-
return _this;
|
|
1775
|
+
class Scene extends GameObject$1 {
|
|
1776
|
+
constructor(name, obj) {
|
|
1777
|
+
super(name, obj);
|
|
1778
|
+
this.gameObjects = [];
|
|
1779
|
+
this.scene = this;
|
|
2114
1780
|
}
|
|
2115
|
-
|
|
1781
|
+
addGameObject(gameObject) {
|
|
2116
1782
|
this.gameObjects.push(gameObject);
|
|
2117
1783
|
if (gameObject.transform) {
|
|
2118
1784
|
gameObject.transform.inScene = true;
|
|
2119
1785
|
}
|
|
2120
|
-
}
|
|
2121
|
-
|
|
2122
|
-
|
|
1786
|
+
}
|
|
1787
|
+
removeGameObject(gameObject) {
|
|
1788
|
+
const index = this.gameObjects.indexOf(gameObject);
|
|
2123
1789
|
if (index === -1) return;
|
|
2124
1790
|
if (gameObject.transform) {
|
|
2125
1791
|
gameObject.transform.inScene = false;
|
|
2126
1792
|
}
|
|
2127
1793
|
this.gameObjects.splice(index, 1);
|
|
2128
|
-
}
|
|
2129
|
-
|
|
1794
|
+
}
|
|
1795
|
+
destroy() {
|
|
2130
1796
|
this.scene = null;
|
|
2131
|
-
|
|
1797
|
+
super.destroy();
|
|
2132
1798
|
this.gameObjects = null;
|
|
2133
1799
|
this.canvas = null;
|
|
2134
|
-
}
|
|
2135
|
-
|
|
2136
|
-
}(GameObject$1);
|
|
1800
|
+
}
|
|
1801
|
+
}
|
|
2137
1802
|
var Scene$1 = Scene;
|
|
2138
1803
|
exports.LOAD_SCENE_MODE = void 0;
|
|
2139
1804
|
(function (LOAD_SCENE_MODE) {
|
|
2140
1805
|
LOAD_SCENE_MODE["SINGLE"] = "SINGLE";
|
|
2141
1806
|
LOAD_SCENE_MODE["MULTI_CANVAS"] = "MULTI_CANVAS";
|
|
2142
1807
|
})(exports.LOAD_SCENE_MODE || (exports.LOAD_SCENE_MODE = {}));
|
|
2143
|
-
|
|
1808
|
+
const triggerStart = obj => {
|
|
2144
1809
|
if (!(obj instanceof System$1) && !(obj instanceof Component$1)) return;
|
|
2145
1810
|
if (obj.started) return;
|
|
2146
1811
|
obj.started = true;
|
|
2147
|
-
try {
|
|
2148
|
-
obj.start && obj.start();
|
|
2149
|
-
} catch (e) {
|
|
2150
|
-
if (obj instanceof Component$1) {
|
|
2151
|
-
console.error(obj.constructor.componentName
|
|
2152
|
-
} else {
|
|
2153
|
-
console.error(obj.constructor.systemName
|
|
2154
|
-
}
|
|
2155
|
-
}
|
|
2156
|
-
};
|
|
2157
|
-
var getAllGameObjects = function (game) {
|
|
2158
|
-
var e_1, _a;
|
|
2159
|
-
var _b;
|
|
2160
|
-
var mainSceneGameObjects = ((_b = game === null || game === void 0 ? void 0 : game.scene) === null || _b === void 0 ? void 0 : _b.gameObjects) || [];
|
|
2161
|
-
var gameObjectsArray = game === null || game === void 0 ? void 0 : game.multiScenes.map(function (_a) {
|
|
2162
|
-
var gameObjects = _a.gameObjects;
|
|
2163
|
-
return gameObjects;
|
|
2164
|
-
});
|
|
2165
|
-
var otherSceneGameObjects = [];
|
|
2166
|
-
try {
|
|
2167
|
-
for (var gameObjectsArray_1 = __values(gameObjectsArray), gameObjectsArray_1_1 = gameObjectsArray_1.next(); !gameObjectsArray_1_1.done; gameObjectsArray_1_1 = gameObjectsArray_1.next()) {
|
|
2168
|
-
var gameObjects = gameObjectsArray_1_1.value;
|
|
2169
|
-
otherSceneGameObjects = __spread(otherSceneGameObjects, gameObjects);
|
|
2170
|
-
}
|
|
2171
|
-
} catch (e_1_1) {
|
|
2172
|
-
e_1 = {
|
|
2173
|
-
error: e_1_1
|
|
2174
|
-
};
|
|
2175
|
-
} finally {
|
|
2176
|
-
try {
|
|
2177
|
-
if (gameObjectsArray_1_1 && !gameObjectsArray_1_1.done && (_a = gameObjectsArray_1.return)) _a.call(gameObjectsArray_1);
|
|
2178
|
-
} finally {
|
|
2179
|
-
if (e_1) throw e_1.error;
|
|
1812
|
+
try {
|
|
1813
|
+
obj.start && obj.start();
|
|
1814
|
+
} catch (e) {
|
|
1815
|
+
if (obj instanceof Component$1) {
|
|
1816
|
+
console.error(`${obj.constructor.componentName} start error`, e);
|
|
1817
|
+
} else {
|
|
1818
|
+
console.error(`${obj.constructor.systemName} start error`, e);
|
|
2180
1819
|
}
|
|
2181
1820
|
}
|
|
2182
|
-
return __spread(mainSceneGameObjects, otherSceneGameObjects);
|
|
2183
1821
|
};
|
|
2184
|
-
|
|
2185
|
-
var
|
|
2186
|
-
|
|
2187
|
-
|
|
2188
|
-
|
|
2189
|
-
|
|
2190
|
-
|
|
2191
|
-
|
|
1822
|
+
const getAllGameObjects = game => {
|
|
1823
|
+
var _a;
|
|
1824
|
+
const mainSceneGameObjects = ((_a = game === null || game === void 0 ? void 0 : game.scene) === null || _a === void 0 ? void 0 : _a.gameObjects) || [];
|
|
1825
|
+
const gameObjectsArray = game === null || game === void 0 ? void 0 : game.multiScenes.map(({
|
|
1826
|
+
gameObjects
|
|
1827
|
+
}) => gameObjects);
|
|
1828
|
+
let otherSceneGameObjects = [];
|
|
1829
|
+
for (const gameObjects of gameObjectsArray) {
|
|
1830
|
+
otherSceneGameObjects = [...otherSceneGameObjects, ...gameObjects];
|
|
1831
|
+
}
|
|
1832
|
+
return [...mainSceneGameObjects, ...otherSceneGameObjects];
|
|
1833
|
+
};
|
|
1834
|
+
const gameObjectLoop = (e, gameObjects = []) => {
|
|
1835
|
+
for (const gameObject of gameObjects) {
|
|
1836
|
+
for (const component of gameObject.components) {
|
|
2192
1837
|
try {
|
|
2193
|
-
|
|
2194
|
-
|
|
2195
|
-
|
|
2196
|
-
|
|
2197
|
-
component.update && component.update(e);
|
|
2198
|
-
} catch (e) {
|
|
2199
|
-
console.error("gameObject: " + gameObject.name + " " + component.name + " update error", e);
|
|
2200
|
-
}
|
|
2201
|
-
}
|
|
2202
|
-
} catch (e_3_1) {
|
|
2203
|
-
e_3 = {
|
|
2204
|
-
error: e_3_1
|
|
2205
|
-
};
|
|
2206
|
-
} finally {
|
|
2207
|
-
try {
|
|
2208
|
-
if (_f && !_f.done && (_b = _e.return)) _b.call(_e);
|
|
2209
|
-
} finally {
|
|
2210
|
-
if (e_3) throw e_3.error;
|
|
2211
|
-
}
|
|
1838
|
+
triggerStart(component);
|
|
1839
|
+
component.update && component.update(e);
|
|
1840
|
+
} catch (e) {
|
|
1841
|
+
console.error(`gameObject: ${gameObject.name} ${component.name} update error`, e);
|
|
2212
1842
|
}
|
|
2213
1843
|
}
|
|
2214
|
-
} catch (e_2_1) {
|
|
2215
|
-
e_2 = {
|
|
2216
|
-
error: e_2_1
|
|
2217
|
-
};
|
|
2218
|
-
} finally {
|
|
2219
|
-
try {
|
|
2220
|
-
if (gameObjects_1_1 && !gameObjects_1_1.done && (_a = gameObjects_1.return)) _a.call(gameObjects_1);
|
|
2221
|
-
} finally {
|
|
2222
|
-
if (e_2) throw e_2.error;
|
|
2223
|
-
}
|
|
2224
1844
|
}
|
|
2225
|
-
|
|
2226
|
-
for (
|
|
2227
|
-
var gameObject = gameObjects_2_1.value;
|
|
1845
|
+
for (const gameObject of gameObjects) {
|
|
1846
|
+
for (const component of gameObject.components) {
|
|
2228
1847
|
try {
|
|
2229
|
-
|
|
2230
|
-
|
|
2231
|
-
|
|
2232
|
-
component.lateUpdate && component.lateUpdate(e);
|
|
2233
|
-
} catch (e) {
|
|
2234
|
-
console.error("gameObject: " + gameObject.name + " " + component.name + " lateUpdate error", e);
|
|
2235
|
-
}
|
|
2236
|
-
}
|
|
2237
|
-
} catch (e_5_1) {
|
|
2238
|
-
e_5 = {
|
|
2239
|
-
error: e_5_1
|
|
2240
|
-
};
|
|
2241
|
-
} finally {
|
|
2242
|
-
try {
|
|
2243
|
-
if (_h && !_h.done && (_d = _g.return)) _d.call(_g);
|
|
2244
|
-
} finally {
|
|
2245
|
-
if (e_5) throw e_5.error;
|
|
2246
|
-
}
|
|
1848
|
+
component.lateUpdate && component.lateUpdate(e);
|
|
1849
|
+
} catch (e) {
|
|
1850
|
+
console.error(`gameObject: ${gameObject.name} ${component.name} lateUpdate error`, e);
|
|
2247
1851
|
}
|
|
2248
1852
|
}
|
|
2249
|
-
} catch (e_4_1) {
|
|
2250
|
-
e_4 = {
|
|
2251
|
-
error: e_4_1
|
|
2252
|
-
};
|
|
2253
|
-
} finally {
|
|
2254
|
-
try {
|
|
2255
|
-
if (gameObjects_2_1 && !gameObjects_2_1.done && (_c = gameObjects_2.return)) _c.call(gameObjects_2);
|
|
2256
|
-
} finally {
|
|
2257
|
-
if (e_4) throw e_4.error;
|
|
2258
|
-
}
|
|
2259
1853
|
}
|
|
2260
1854
|
};
|
|
2261
|
-
|
|
2262
|
-
|
|
2263
|
-
|
|
2264
|
-
for (var gameObjects_3 = __values(gameObjects), gameObjects_3_1 = gameObjects_3.next(); !gameObjects_3_1.done; gameObjects_3_1 = gameObjects_3.next()) {
|
|
2265
|
-
var gameObject = gameObjects_3_1.value;
|
|
1855
|
+
const gameObjectResume = gameObjects => {
|
|
1856
|
+
for (const gameObject of gameObjects) {
|
|
1857
|
+
for (const component of gameObject.components) {
|
|
2266
1858
|
try {
|
|
2267
|
-
|
|
2268
|
-
|
|
2269
|
-
|
|
2270
|
-
component.onResume && component.onResume();
|
|
2271
|
-
} catch (e) {
|
|
2272
|
-
console.error("gameObject: " + gameObject.name + ", " + component.name + ", onResume error", e);
|
|
2273
|
-
}
|
|
2274
|
-
}
|
|
2275
|
-
} catch (e_7_1) {
|
|
2276
|
-
e_7 = {
|
|
2277
|
-
error: e_7_1
|
|
2278
|
-
};
|
|
2279
|
-
} finally {
|
|
2280
|
-
try {
|
|
2281
|
-
if (_d && !_d.done && (_b = _c.return)) _b.call(_c);
|
|
2282
|
-
} finally {
|
|
2283
|
-
if (e_7) throw e_7.error;
|
|
2284
|
-
}
|
|
1859
|
+
component.onResume && component.onResume();
|
|
1860
|
+
} catch (e) {
|
|
1861
|
+
console.error(`gameObject: ${gameObject.name}, ${component.name}, onResume error`, e);
|
|
2285
1862
|
}
|
|
2286
1863
|
}
|
|
2287
|
-
} catch (e_6_1) {
|
|
2288
|
-
e_6 = {
|
|
2289
|
-
error: e_6_1
|
|
2290
|
-
};
|
|
2291
|
-
} finally {
|
|
2292
|
-
try {
|
|
2293
|
-
if (gameObjects_3_1 && !gameObjects_3_1.done && (_a = gameObjects_3.return)) _a.call(gameObjects_3);
|
|
2294
|
-
} finally {
|
|
2295
|
-
if (e_6) throw e_6.error;
|
|
2296
|
-
}
|
|
2297
1864
|
}
|
|
2298
1865
|
};
|
|
2299
|
-
|
|
2300
|
-
|
|
2301
|
-
|
|
2302
|
-
for (var gameObjects_4 = __values(gameObjects), gameObjects_4_1 = gameObjects_4.next(); !gameObjects_4_1.done; gameObjects_4_1 = gameObjects_4.next()) {
|
|
2303
|
-
var gameObject = gameObjects_4_1.value;
|
|
1866
|
+
const gameObjectPause = gameObjects => {
|
|
1867
|
+
for (const gameObject of gameObjects) {
|
|
1868
|
+
for (const component of gameObject.components) {
|
|
2304
1869
|
try {
|
|
2305
|
-
|
|
2306
|
-
|
|
2307
|
-
|
|
2308
|
-
component.onPause && component.onPause();
|
|
2309
|
-
} catch (e) {
|
|
2310
|
-
console.error("gameObject: " + gameObject.name + ", " + component.name + ", onResume error", e);
|
|
2311
|
-
}
|
|
2312
|
-
}
|
|
2313
|
-
} catch (e_9_1) {
|
|
2314
|
-
e_9 = {
|
|
2315
|
-
error: e_9_1
|
|
2316
|
-
};
|
|
2317
|
-
} finally {
|
|
2318
|
-
try {
|
|
2319
|
-
if (_d && !_d.done && (_b = _c.return)) _b.call(_c);
|
|
2320
|
-
} finally {
|
|
2321
|
-
if (e_9) throw e_9.error;
|
|
2322
|
-
}
|
|
1870
|
+
component.onPause && component.onPause();
|
|
1871
|
+
} catch (e) {
|
|
1872
|
+
console.error(`gameObject: ${gameObject.name}, ${component.name}, onResume error`, e);
|
|
2323
1873
|
}
|
|
2324
1874
|
}
|
|
2325
|
-
} catch (e_8_1) {
|
|
2326
|
-
e_8 = {
|
|
2327
|
-
error: e_8_1
|
|
2328
|
-
};
|
|
2329
|
-
} finally {
|
|
2330
|
-
try {
|
|
2331
|
-
if (gameObjects_4_1 && !gameObjects_4_1.done && (_a = gameObjects_4.return)) _a.call(gameObjects_4);
|
|
2332
|
-
} finally {
|
|
2333
|
-
if (e_8) throw e_8.error;
|
|
2334
|
-
}
|
|
2335
1875
|
}
|
|
2336
1876
|
};
|
|
2337
|
-
|
|
2338
|
-
|
|
2339
|
-
|
|
2340
|
-
|
|
2341
|
-
|
|
2342
|
-
|
|
2343
|
-
|
|
2344
|
-
|
|
2345
|
-
|
|
2346
|
-
|
|
2347
|
-
|
|
2348
|
-
|
|
2349
|
-
|
|
2350
|
-
|
|
2351
|
-
|
|
2352
|
-
|
|
2353
|
-
|
|
2354
|
-
|
|
2355
|
-
|
|
2356
|
-
|
|
2357
|
-
|
|
2358
|
-
var e_10, _f;
|
|
2359
|
-
return __generator(this, function (_g) {
|
|
2360
|
-
switch (_g.label) {
|
|
2361
|
-
case 0:
|
|
2362
|
-
if (window.__EVA_INSPECTOR_ENV__) {
|
|
2363
|
-
window.__EVA_GAME_INSTANCE__ = this;
|
|
2364
|
-
}
|
|
2365
|
-
this.ticker = new Ticker$1({
|
|
2366
|
-
autoStart: false,
|
|
2367
|
-
frameRate: frameRate
|
|
2368
|
-
});
|
|
2369
|
-
this.initTicker();
|
|
2370
|
-
if (!(systems && systems.length)) return [3, 8];
|
|
2371
|
-
_g.label = 1;
|
|
2372
|
-
case 1:
|
|
2373
|
-
_g.trys.push([1, 6, 7, 8]);
|
|
2374
|
-
systems_1 = __values(systems), systems_1_1 = systems_1.next();
|
|
2375
|
-
_g.label = 2;
|
|
2376
|
-
case 2:
|
|
2377
|
-
if (!!systems_1_1.done) return [3, 5];
|
|
2378
|
-
system = systems_1_1.value;
|
|
2379
|
-
return [4, this.addSystem(system)];
|
|
2380
|
-
case 3:
|
|
2381
|
-
_g.sent();
|
|
2382
|
-
_g.label = 4;
|
|
2383
|
-
case 4:
|
|
2384
|
-
systems_1_1 = systems_1.next();
|
|
2385
|
-
return [3, 2];
|
|
2386
|
-
case 5:
|
|
2387
|
-
return [3, 8];
|
|
2388
|
-
case 6:
|
|
2389
|
-
e_10_1 = _g.sent();
|
|
2390
|
-
e_10 = {
|
|
2391
|
-
error: e_10_1
|
|
2392
|
-
};
|
|
2393
|
-
return [3, 8];
|
|
2394
|
-
case 7:
|
|
2395
|
-
try {
|
|
2396
|
-
if (systems_1_1 && !systems_1_1.done && (_f = systems_1.return)) _f.call(systems_1);
|
|
2397
|
-
} finally {
|
|
2398
|
-
if (e_10) throw e_10.error;
|
|
2399
|
-
}
|
|
2400
|
-
return [7];
|
|
2401
|
-
case 8:
|
|
2402
|
-
if (needScene) {
|
|
2403
|
-
this.loadScene(new Scene$1('scene'));
|
|
2404
|
-
}
|
|
2405
|
-
if (autoStart) {
|
|
2406
|
-
this.start();
|
|
2407
|
-
}
|
|
2408
|
-
return [2];
|
|
2409
|
-
}
|
|
1877
|
+
class Game extends EE {
|
|
1878
|
+
constructor() {
|
|
1879
|
+
super(...arguments);
|
|
1880
|
+
this.playing = false;
|
|
1881
|
+
this.started = false;
|
|
1882
|
+
this.multiScenes = [];
|
|
1883
|
+
this.systems = [];
|
|
1884
|
+
}
|
|
1885
|
+
init({
|
|
1886
|
+
systems,
|
|
1887
|
+
frameRate = 60,
|
|
1888
|
+
autoStart = true,
|
|
1889
|
+
needScene = true
|
|
1890
|
+
} = {}) {
|
|
1891
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1892
|
+
if (window.__EVA_INSPECTOR_ENV__) {
|
|
1893
|
+
window.__EVA_GAME_INSTANCE__ = this;
|
|
1894
|
+
}
|
|
1895
|
+
this.ticker = new Ticker$1({
|
|
1896
|
+
autoStart: false,
|
|
1897
|
+
frameRate
|
|
2410
1898
|
});
|
|
2411
|
-
|
|
2412
|
-
|
|
2413
|
-
|
|
2414
|
-
|
|
2415
|
-
return this._scene;
|
|
2416
|
-
},
|
|
2417
|
-
set: function (scene) {
|
|
2418
|
-
this._scene = scene;
|
|
2419
|
-
},
|
|
2420
|
-
enumerable: false,
|
|
2421
|
-
configurable: true
|
|
2422
|
-
});
|
|
2423
|
-
Object.defineProperty(Game.prototype, "gameObjects", {
|
|
2424
|
-
get: function () {
|
|
2425
|
-
return getAllGameObjects(this);
|
|
2426
|
-
},
|
|
2427
|
-
enumerable: false,
|
|
2428
|
-
configurable: true
|
|
2429
|
-
});
|
|
2430
|
-
Game.prototype.addSystem = function (S, obj) {
|
|
2431
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
2432
|
-
var system, hasTheSystem, _a;
|
|
2433
|
-
return __generator(this, function (_b) {
|
|
2434
|
-
switch (_b.label) {
|
|
2435
|
-
case 0:
|
|
2436
|
-
if (S instanceof Function) {
|
|
2437
|
-
system = new S(obj);
|
|
2438
|
-
} else if (S instanceof System$1) {
|
|
2439
|
-
system = S;
|
|
2440
|
-
} else {
|
|
2441
|
-
console.warn('can only add System');
|
|
2442
|
-
return [2];
|
|
2443
|
-
}
|
|
2444
|
-
hasTheSystem = this.systems.find(function (item) {
|
|
2445
|
-
return item.constructor === system.constructor;
|
|
2446
|
-
});
|
|
2447
|
-
if (hasTheSystem) {
|
|
2448
|
-
console.warn(system.constructor.systemName + " System has been added");
|
|
2449
|
-
return [2];
|
|
2450
|
-
}
|
|
2451
|
-
system.game = this;
|
|
2452
|
-
_a = system.init;
|
|
2453
|
-
if (!_a) return [3, 2];
|
|
2454
|
-
return [4, system.init(system.__systemDefaultParams)];
|
|
2455
|
-
case 1:
|
|
2456
|
-
_a = _b.sent();
|
|
2457
|
-
_b.label = 2;
|
|
2458
|
-
case 2:
|
|
2459
|
-
setSystemObserver(system, system.constructor);
|
|
2460
|
-
initObserver(system.constructor);
|
|
2461
|
-
try {
|
|
2462
|
-
system.awake && system.awake();
|
|
2463
|
-
} catch (e) {
|
|
2464
|
-
console.error(system.constructor.systemName + " awake error", e);
|
|
2465
|
-
}
|
|
2466
|
-
this.systems.push(system);
|
|
2467
|
-
return [2, system];
|
|
1899
|
+
this.initTicker();
|
|
1900
|
+
if (systems && systems.length) {
|
|
1901
|
+
for (const system of systems) {
|
|
1902
|
+
yield this.addSystem(system);
|
|
2468
1903
|
}
|
|
1904
|
+
}
|
|
1905
|
+
if (needScene) {
|
|
1906
|
+
this.loadScene(new Scene$1('scene'));
|
|
1907
|
+
}
|
|
1908
|
+
if (autoStart) {
|
|
1909
|
+
this.start();
|
|
1910
|
+
}
|
|
1911
|
+
});
|
|
1912
|
+
}
|
|
1913
|
+
get scene() {
|
|
1914
|
+
return this._scene;
|
|
1915
|
+
}
|
|
1916
|
+
set scene(scene) {
|
|
1917
|
+
this._scene = scene;
|
|
1918
|
+
}
|
|
1919
|
+
get gameObjects() {
|
|
1920
|
+
return getAllGameObjects(this);
|
|
1921
|
+
}
|
|
1922
|
+
addSystem(S, obj) {
|
|
1923
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1924
|
+
let system;
|
|
1925
|
+
if (S instanceof Function) {
|
|
1926
|
+
system = new S(obj);
|
|
1927
|
+
} else if (S instanceof System$1) {
|
|
1928
|
+
system = S;
|
|
1929
|
+
} else {
|
|
1930
|
+
console.warn('can only add System');
|
|
1931
|
+
return;
|
|
1932
|
+
}
|
|
1933
|
+
const hasTheSystem = this.systems.find(item => {
|
|
1934
|
+
return item.constructor === system.constructor;
|
|
2469
1935
|
});
|
|
1936
|
+
if (hasTheSystem) {
|
|
1937
|
+
console.warn(`${system.constructor.systemName} System has been added`);
|
|
1938
|
+
return;
|
|
1939
|
+
}
|
|
1940
|
+
system.game = this;
|
|
1941
|
+
system.init && (yield system.init(system.__systemDefaultParams));
|
|
1942
|
+
setSystemObserver(system, system.constructor);
|
|
1943
|
+
initObserver(system.constructor);
|
|
1944
|
+
try {
|
|
1945
|
+
system.awake && system.awake();
|
|
1946
|
+
} catch (e) {
|
|
1947
|
+
console.error(`${system.constructor.systemName} awake error`, e);
|
|
1948
|
+
}
|
|
1949
|
+
this.systems.push(system);
|
|
1950
|
+
return system;
|
|
2470
1951
|
});
|
|
2471
|
-
}
|
|
2472
|
-
|
|
1952
|
+
}
|
|
1953
|
+
removeSystem(system) {
|
|
2473
1954
|
if (!system) return;
|
|
2474
|
-
|
|
1955
|
+
let index = -1;
|
|
2475
1956
|
if (typeof system === 'string') {
|
|
2476
|
-
index = this.systems.findIndex(
|
|
2477
|
-
return s.name === system;
|
|
2478
|
-
});
|
|
1957
|
+
index = this.systems.findIndex(s => s.name === system);
|
|
2479
1958
|
} else if (system instanceof Function) {
|
|
2480
|
-
index = this.systems.findIndex(
|
|
2481
|
-
return s.constructor === system;
|
|
2482
|
-
});
|
|
1959
|
+
index = this.systems.findIndex(s => s.constructor === system);
|
|
2483
1960
|
} else if (system instanceof System$1) {
|
|
2484
|
-
index = this.systems.findIndex(
|
|
2485
|
-
return s === system;
|
|
2486
|
-
});
|
|
1961
|
+
index = this.systems.findIndex(s => s === system);
|
|
2487
1962
|
}
|
|
2488
1963
|
if (index > -1) {
|
|
2489
1964
|
this.systems[index].destroy && this.systems[index].destroy();
|
|
2490
1965
|
this.systems.splice(index, 1);
|
|
2491
1966
|
}
|
|
2492
|
-
}
|
|
2493
|
-
|
|
2494
|
-
return this.systems.find(
|
|
1967
|
+
}
|
|
1968
|
+
getSystem(S) {
|
|
1969
|
+
return this.systems.find(system => {
|
|
2495
1970
|
if (typeof S === 'string') {
|
|
2496
1971
|
return system.name === S;
|
|
2497
1972
|
} else {
|
|
2498
1973
|
return system instanceof S;
|
|
2499
1974
|
}
|
|
2500
1975
|
});
|
|
2501
|
-
}
|
|
2502
|
-
|
|
1976
|
+
}
|
|
1977
|
+
pause() {
|
|
2503
1978
|
if (!this.playing) return;
|
|
2504
1979
|
this.playing = false;
|
|
2505
1980
|
this.ticker.pause();
|
|
2506
1981
|
this.triggerPause();
|
|
2507
|
-
}
|
|
2508
|
-
|
|
1982
|
+
}
|
|
1983
|
+
start() {
|
|
2509
1984
|
if (this.playing) return;
|
|
2510
1985
|
this.playing = true;
|
|
2511
1986
|
this.started = true;
|
|
2512
1987
|
this.ticker.start();
|
|
2513
|
-
}
|
|
2514
|
-
|
|
1988
|
+
}
|
|
1989
|
+
resume() {
|
|
2515
1990
|
if (this.playing) return;
|
|
2516
1991
|
this.playing = true;
|
|
2517
1992
|
this.ticker.start();
|
|
2518
1993
|
this.triggerResume();
|
|
2519
|
-
}
|
|
2520
|
-
|
|
2521
|
-
|
|
2522
|
-
|
|
2523
|
-
|
|
2524
|
-
_this.scene && gameObjectLoop(e, _this.gameObjects);
|
|
2525
|
-
try {
|
|
2526
|
-
for (var _c = __values(_this.systems), _d = _c.next(); !_d.done; _d = _c.next()) {
|
|
2527
|
-
var system = _d.value;
|
|
2528
|
-
try {
|
|
2529
|
-
triggerStart(system);
|
|
2530
|
-
system.update && system.update(e);
|
|
2531
|
-
} catch (e) {
|
|
2532
|
-
console.error(system.constructor.systemName + " update error", e);
|
|
2533
|
-
}
|
|
2534
|
-
}
|
|
2535
|
-
} catch (e_11_1) {
|
|
2536
|
-
e_11 = {
|
|
2537
|
-
error: e_11_1
|
|
2538
|
-
};
|
|
2539
|
-
} finally {
|
|
1994
|
+
}
|
|
1995
|
+
initTicker() {
|
|
1996
|
+
this.ticker.add(e => {
|
|
1997
|
+
this.scene && gameObjectLoop(e, this.gameObjects);
|
|
1998
|
+
for (const system of this.systems) {
|
|
2540
1999
|
try {
|
|
2541
|
-
|
|
2542
|
-
|
|
2543
|
-
|
|
2000
|
+
triggerStart(system);
|
|
2001
|
+
system.update && system.update(e);
|
|
2002
|
+
} catch (e) {
|
|
2003
|
+
console.error(`${system.constructor.systemName} update error`, e);
|
|
2544
2004
|
}
|
|
2545
2005
|
}
|
|
2546
|
-
|
|
2547
|
-
for (var _e = __values(_this.systems), _f = _e.next(); !_f.done; _f = _e.next()) {
|
|
2548
|
-
var system = _f.value;
|
|
2549
|
-
try {
|
|
2550
|
-
system.lateUpdate && system.lateUpdate(e);
|
|
2551
|
-
} catch (e) {
|
|
2552
|
-
console.error(system.constructor.systemName + " lateUpdate error", e);
|
|
2553
|
-
}
|
|
2554
|
-
}
|
|
2555
|
-
} catch (e_12_1) {
|
|
2556
|
-
e_12 = {
|
|
2557
|
-
error: e_12_1
|
|
2558
|
-
};
|
|
2559
|
-
} finally {
|
|
2006
|
+
for (const system of this.systems) {
|
|
2560
2007
|
try {
|
|
2561
|
-
|
|
2562
|
-
}
|
|
2563
|
-
|
|
2008
|
+
system.lateUpdate && system.lateUpdate(e);
|
|
2009
|
+
} catch (e) {
|
|
2010
|
+
console.error(`${system.constructor.systemName} lateUpdate error`, e);
|
|
2564
2011
|
}
|
|
2565
2012
|
}
|
|
2566
2013
|
});
|
|
2567
|
-
}
|
|
2568
|
-
|
|
2569
|
-
var e_13, _a;
|
|
2014
|
+
}
|
|
2015
|
+
triggerResume() {
|
|
2570
2016
|
gameObjectResume(this.gameObjects);
|
|
2571
|
-
|
|
2572
|
-
for (var _b = __values(this.systems), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
2573
|
-
var system = _c.value;
|
|
2574
|
-
try {
|
|
2575
|
-
system.onResume && system.onResume();
|
|
2576
|
-
} catch (e) {
|
|
2577
|
-
console.error(system.constructor.systemName + ", onResume error", e);
|
|
2578
|
-
}
|
|
2579
|
-
}
|
|
2580
|
-
} catch (e_13_1) {
|
|
2581
|
-
e_13 = {
|
|
2582
|
-
error: e_13_1
|
|
2583
|
-
};
|
|
2584
|
-
} finally {
|
|
2017
|
+
for (const system of this.systems) {
|
|
2585
2018
|
try {
|
|
2586
|
-
|
|
2587
|
-
}
|
|
2588
|
-
|
|
2019
|
+
system.onResume && system.onResume();
|
|
2020
|
+
} catch (e) {
|
|
2021
|
+
console.error(`${system.constructor.systemName}, onResume error`, e);
|
|
2589
2022
|
}
|
|
2590
2023
|
}
|
|
2591
|
-
}
|
|
2592
|
-
|
|
2593
|
-
var e_14, _a;
|
|
2024
|
+
}
|
|
2025
|
+
triggerPause() {
|
|
2594
2026
|
gameObjectPause(this.gameObjects);
|
|
2595
|
-
|
|
2596
|
-
for (var _b = __values(this.systems), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
2597
|
-
var system = _c.value;
|
|
2598
|
-
try {
|
|
2599
|
-
system.onPause && system.onPause();
|
|
2600
|
-
} catch (e) {
|
|
2601
|
-
console.error(system.constructor.systemName + ", onPause error", e);
|
|
2602
|
-
}
|
|
2603
|
-
}
|
|
2604
|
-
} catch (e_14_1) {
|
|
2605
|
-
e_14 = {
|
|
2606
|
-
error: e_14_1
|
|
2607
|
-
};
|
|
2608
|
-
} finally {
|
|
2027
|
+
for (const system of this.systems) {
|
|
2609
2028
|
try {
|
|
2610
|
-
|
|
2611
|
-
}
|
|
2612
|
-
|
|
2029
|
+
system.onPause && system.onPause();
|
|
2030
|
+
} catch (e) {
|
|
2031
|
+
console.error(`${system.constructor.systemName}, onPause error`, e);
|
|
2613
2032
|
}
|
|
2614
2033
|
}
|
|
2615
|
-
}
|
|
2616
|
-
|
|
2617
|
-
|
|
2618
|
-
|
|
2619
|
-
for (var _b = __values(__spread(this.systems)), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
2620
|
-
var system = _c.value;
|
|
2621
|
-
this.removeSystem(system);
|
|
2622
|
-
}
|
|
2623
|
-
} catch (e_15_1) {
|
|
2624
|
-
e_15 = {
|
|
2625
|
-
error: e_15_1
|
|
2626
|
-
};
|
|
2627
|
-
} finally {
|
|
2628
|
-
try {
|
|
2629
|
-
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
2630
|
-
} finally {
|
|
2631
|
-
if (e_15) throw e_15.error;
|
|
2632
|
-
}
|
|
2034
|
+
}
|
|
2035
|
+
destroySystems() {
|
|
2036
|
+
for (const system of [...this.systems]) {
|
|
2037
|
+
this.removeSystem(system);
|
|
2633
2038
|
}
|
|
2634
2039
|
this.systems.length = 0;
|
|
2635
|
-
}
|
|
2636
|
-
|
|
2040
|
+
}
|
|
2041
|
+
destroy() {
|
|
2637
2042
|
this.removeAllListeners();
|
|
2638
2043
|
this.pause();
|
|
2639
2044
|
this.scene.destroy();
|
|
@@ -2642,13 +2047,12 @@ var _EVA_IIFE_EVA = function (exports, pixi_js) {
|
|
|
2642
2047
|
this.scene = null;
|
|
2643
2048
|
this.canvas = null;
|
|
2644
2049
|
this.multiScenes = null;
|
|
2645
|
-
}
|
|
2646
|
-
|
|
2647
|
-
|
|
2648
|
-
|
|
2649
|
-
|
|
2650
|
-
|
|
2651
|
-
params = _c === void 0 ? {} : _c;
|
|
2050
|
+
}
|
|
2051
|
+
loadScene({
|
|
2052
|
+
scene,
|
|
2053
|
+
mode = exports.LOAD_SCENE_MODE.SINGLE,
|
|
2054
|
+
params = {}
|
|
2055
|
+
}) {
|
|
2652
2056
|
if (!scene) {
|
|
2653
2057
|
return;
|
|
2654
2058
|
}
|
|
@@ -2661,13 +2065,12 @@ var _EVA_IIFE_EVA = function (exports, pixi_js) {
|
|
|
2661
2065
|
break;
|
|
2662
2066
|
}
|
|
2663
2067
|
this.emit('sceneChanged', {
|
|
2664
|
-
scene
|
|
2665
|
-
mode
|
|
2666
|
-
params
|
|
2068
|
+
scene,
|
|
2069
|
+
mode,
|
|
2070
|
+
params
|
|
2667
2071
|
});
|
|
2668
|
-
}
|
|
2669
|
-
|
|
2670
|
-
}(EE);
|
|
2072
|
+
}
|
|
2073
|
+
}
|
|
2671
2074
|
var Game$1 = Game;
|
|
2672
2075
|
function IDEProp(target, propertyKey) {
|
|
2673
2076
|
if (!target.constructor.IDEProps) {
|
|
@@ -2675,18 +2078,15 @@ var _EVA_IIFE_EVA = function (exports, pixi_js) {
|
|
|
2675
2078
|
}
|
|
2676
2079
|
target.constructor.IDEProps.push(propertyKey);
|
|
2677
2080
|
}
|
|
2678
|
-
function componentObserver(observerInfo) {
|
|
2679
|
-
if (observerInfo === void 0) {
|
|
2680
|
-
observerInfo = {};
|
|
2681
|
-
}
|
|
2081
|
+
function componentObserver(observerInfo = {}) {
|
|
2682
2082
|
return function (constructor) {
|
|
2683
2083
|
if (!constructor.observerInfo) {
|
|
2684
|
-
for (
|
|
2685
|
-
for (
|
|
2084
|
+
for (const key in observerInfo) {
|
|
2085
|
+
for (const index in observerInfo[key]) {
|
|
2686
2086
|
if (typeof observerInfo[key][index] === 'string') {
|
|
2687
2087
|
observerInfo[key][index] = [observerInfo[key][index]];
|
|
2688
2088
|
}
|
|
2689
|
-
|
|
2089
|
+
let observerProp;
|
|
2690
2090
|
if (Array.isArray(observerInfo[key][index])) {
|
|
2691
2091
|
observerProp = {
|
|
2692
2092
|
prop: observerInfo[key][index],
|
|
@@ -2704,26 +2104,25 @@ var _EVA_IIFE_EVA = function (exports, pixi_js) {
|
|
|
2704
2104
|
}
|
|
2705
2105
|
};
|
|
2706
2106
|
}
|
|
2707
|
-
|
|
2708
|
-
|
|
2709
|
-
|
|
2710
|
-
|
|
2711
|
-
|
|
2712
|
-
|
|
2713
|
-
|
|
2714
|
-
|
|
2715
|
-
|
|
2716
|
-
|
|
2717
|
-
|
|
2107
|
+
class Progress extends EE {
|
|
2108
|
+
constructor({
|
|
2109
|
+
resource,
|
|
2110
|
+
resourceTotal
|
|
2111
|
+
}) {
|
|
2112
|
+
super();
|
|
2113
|
+
this.progress = 0;
|
|
2114
|
+
this.resourceTotal = 0;
|
|
2115
|
+
this.resourceLoadedCount = 0;
|
|
2116
|
+
this.resource = resource;
|
|
2117
|
+
this.resourceTotal = resourceTotal;
|
|
2718
2118
|
if (resourceTotal === 0) {
|
|
2719
|
-
|
|
2119
|
+
this.resource.emit(exports.LOAD_EVENT.COMPLETE, this);
|
|
2720
2120
|
}
|
|
2721
|
-
return _this;
|
|
2722
2121
|
}
|
|
2723
|
-
|
|
2122
|
+
onStart() {
|
|
2724
2123
|
this.resource.emit(exports.LOAD_EVENT.START, this);
|
|
2725
|
-
}
|
|
2726
|
-
|
|
2124
|
+
}
|
|
2125
|
+
onProgress(param) {
|
|
2727
2126
|
this.resourceLoadedCount++;
|
|
2728
2127
|
this.progress = Math.floor(this.resourceLoadedCount / this.resourceTotal * 100) / 100;
|
|
2729
2128
|
if (param.success) {
|
|
@@ -2735,10 +2134,8 @@ var _EVA_IIFE_EVA = function (exports, pixi_js) {
|
|
|
2735
2134
|
if (this.resourceLoadedCount === this.resourceTotal) {
|
|
2736
2135
|
this.resource.emit(exports.LOAD_EVENT.COMPLETE, this);
|
|
2737
2136
|
}
|
|
2738
|
-
}
|
|
2739
|
-
|
|
2740
|
-
}(EE);
|
|
2741
|
-
var Progress$1 = Progress;
|
|
2137
|
+
}
|
|
2138
|
+
}
|
|
2742
2139
|
var SignalBindingImpl = function () {
|
|
2743
2140
|
function SignalBindingImpl(fn, once, thisArg) {
|
|
2744
2141
|
if (once === void 0) {
|
|
@@ -3806,17 +3203,17 @@ var _EVA_IIFE_EVA = function (exports, pixi_js) {
|
|
|
3806
3203
|
Loader._defaultMiddleware = [];
|
|
3807
3204
|
return Loader;
|
|
3808
3205
|
}();
|
|
3809
|
-
|
|
3810
|
-
AbstractLoadStrategy
|
|
3811
|
-
AudioLoadStrategy
|
|
3812
|
-
ImageLoadStrategy
|
|
3813
|
-
XhrResponseType
|
|
3814
|
-
MediaElementLoadStrategy
|
|
3815
|
-
VideoLoadStrategy
|
|
3816
|
-
Loader
|
|
3206
|
+
const resourceLoader = {
|
|
3207
|
+
AbstractLoadStrategy,
|
|
3208
|
+
AudioLoadStrategy,
|
|
3209
|
+
ImageLoadStrategy,
|
|
3210
|
+
XhrResponseType,
|
|
3211
|
+
MediaElementLoadStrategy,
|
|
3212
|
+
VideoLoadStrategy,
|
|
3213
|
+
Loader,
|
|
3817
3214
|
Resource: Resource$1,
|
|
3818
|
-
ResourceType
|
|
3819
|
-
ResourceState
|
|
3215
|
+
ResourceType,
|
|
3216
|
+
ResourceState
|
|
3820
3217
|
};
|
|
3821
3218
|
exports.LOAD_EVENT = void 0;
|
|
3822
3219
|
(function (LOAD_EVENT) {
|
|
@@ -3834,225 +3231,144 @@ var _EVA_IIFE_EVA = function (exports, pixi_js) {
|
|
|
3834
3231
|
RESOURCE_TYPE["AUDIO"] = "AUDIO";
|
|
3835
3232
|
RESOURCE_TYPE["VIDEO"] = "VIDEO";
|
|
3836
3233
|
})(exports.RESOURCE_TYPE || (exports.RESOURCE_TYPE = {}));
|
|
3837
|
-
|
|
3838
|
-
|
|
3839
|
-
|
|
3840
|
-
|
|
3841
|
-
|
|
3842
|
-
|
|
3843
|
-
|
|
3844
|
-
|
|
3845
|
-
|
|
3846
|
-
_this.promiseMap = {};
|
|
3234
|
+
class Resource extends EE {
|
|
3235
|
+
constructor(options) {
|
|
3236
|
+
super();
|
|
3237
|
+
this.timeout = 6000;
|
|
3238
|
+
this.preProcessResourceHandlers = [];
|
|
3239
|
+
this.resourcesMap = {};
|
|
3240
|
+
this.makeInstanceFunctions = {};
|
|
3241
|
+
this.destroyInstanceFunctions = {};
|
|
3242
|
+
this.promiseMap = {};
|
|
3847
3243
|
if (options && typeof options.timeout === 'number') {
|
|
3848
|
-
|
|
3244
|
+
this.timeout = options.timeout;
|
|
3849
3245
|
}
|
|
3850
|
-
return _this;
|
|
3851
3246
|
}
|
|
3852
|
-
|
|
3247
|
+
loadConfig(resources) {
|
|
3853
3248
|
this.addResource(resources);
|
|
3854
3249
|
this.preload();
|
|
3855
|
-
}
|
|
3856
|
-
|
|
3250
|
+
}
|
|
3251
|
+
loadSingle(resource) {
|
|
3857
3252
|
this.addResource([resource]);
|
|
3858
3253
|
return this.getResource(resource.name);
|
|
3859
|
-
}
|
|
3860
|
-
|
|
3861
|
-
var e_1, _a;
|
|
3254
|
+
}
|
|
3255
|
+
addResource(resources) {
|
|
3862
3256
|
if (!resources || resources.length < 1) {
|
|
3863
3257
|
console.warn('no resources');
|
|
3864
3258
|
return;
|
|
3865
3259
|
}
|
|
3866
|
-
|
|
3867
|
-
|
|
3868
|
-
|
|
3869
|
-
|
|
3870
|
-
console.warn(res.name + ' was already added');
|
|
3871
|
-
continue;
|
|
3872
|
-
}
|
|
3873
|
-
this.resourcesMap[res.name] = res;
|
|
3874
|
-
this.resourcesMap[res.name].data = {};
|
|
3875
|
-
}
|
|
3876
|
-
} catch (e_1_1) {
|
|
3877
|
-
e_1 = {
|
|
3878
|
-
error: e_1_1
|
|
3879
|
-
};
|
|
3880
|
-
} finally {
|
|
3881
|
-
try {
|
|
3882
|
-
if (resources_1_1 && !resources_1_1.done && (_a = resources_1.return)) _a.call(resources_1);
|
|
3883
|
-
} finally {
|
|
3884
|
-
if (e_1) throw e_1.error;
|
|
3260
|
+
for (const res of resources) {
|
|
3261
|
+
if (this.resourcesMap[res.name]) {
|
|
3262
|
+
console.warn(res.name + ' was already added');
|
|
3263
|
+
continue;
|
|
3885
3264
|
}
|
|
3265
|
+
this.resourcesMap[res.name] = res;
|
|
3266
|
+
this.resourcesMap[res.name].data = {};
|
|
3886
3267
|
}
|
|
3887
|
-
}
|
|
3888
|
-
|
|
3268
|
+
}
|
|
3269
|
+
addPreProcessResourceHandler(handler) {
|
|
3889
3270
|
this.preProcessResourceHandlers.push(handler);
|
|
3890
|
-
}
|
|
3891
|
-
|
|
3271
|
+
}
|
|
3272
|
+
removePreProcessResourceHandler(handler) {
|
|
3892
3273
|
this.preProcessResourceHandlers.splice(this.preProcessResourceHandlers.indexOf(handler), 1);
|
|
3893
|
-
}
|
|
3894
|
-
|
|
3895
|
-
|
|
3896
|
-
for (
|
|
3897
|
-
|
|
3898
|
-
if (
|
|
3899
|
-
names.push(
|
|
3274
|
+
}
|
|
3275
|
+
preload() {
|
|
3276
|
+
const names = [];
|
|
3277
|
+
for (const key in this.resourcesMap) {
|
|
3278
|
+
const resource = this.resourcesMap[key];
|
|
3279
|
+
if (resource.preload && !resource.complete && !this.promiseMap[key]) {
|
|
3280
|
+
names.push(resource.name);
|
|
3900
3281
|
}
|
|
3901
3282
|
}
|
|
3902
|
-
this.progress = new Progress
|
|
3283
|
+
this.progress = new Progress({
|
|
3903
3284
|
resource: this,
|
|
3904
3285
|
resourceTotal: names.length
|
|
3905
3286
|
});
|
|
3906
3287
|
this.loadResource({
|
|
3907
|
-
names
|
|
3288
|
+
names,
|
|
3908
3289
|
preload: true
|
|
3909
3290
|
});
|
|
3910
|
-
}
|
|
3911
|
-
|
|
3912
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
3913
|
-
|
|
3914
|
-
|
|
3915
|
-
names: [name]
|
|
3916
|
-
});
|
|
3917
|
-
return [2, this.promiseMap[name] || Promise.resolve({})];
|
|
3291
|
+
}
|
|
3292
|
+
getResource(name) {
|
|
3293
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
3294
|
+
this.loadResource({
|
|
3295
|
+
names: [name]
|
|
3918
3296
|
});
|
|
3297
|
+
return this.promiseMap[name] || Promise.resolve({});
|
|
3919
3298
|
});
|
|
3920
|
-
}
|
|
3921
|
-
|
|
3922
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
3923
|
-
|
|
3924
|
-
return
|
|
3925
|
-
switch (_b.label) {
|
|
3926
|
-
case 0:
|
|
3927
|
-
res = this.resourcesMap[name];
|
|
3928
|
-
_a = this.makeInstanceFunctions[res.type];
|
|
3929
|
-
if (!_a) return [3, 2];
|
|
3930
|
-
return [4, this.makeInstanceFunctions[res.type](res)];
|
|
3931
|
-
case 1:
|
|
3932
|
-
_a = _b.sent();
|
|
3933
|
-
_b.label = 2;
|
|
3934
|
-
case 2:
|
|
3935
|
-
return [2, _a];
|
|
3936
|
-
}
|
|
3937
|
-
});
|
|
3299
|
+
}
|
|
3300
|
+
instance(name) {
|
|
3301
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
3302
|
+
const res = this.resourcesMap[name];
|
|
3303
|
+
return this.makeInstanceFunctions[res.type] && (yield this.makeInstanceFunctions[res.type](res));
|
|
3938
3304
|
});
|
|
3939
|
-
}
|
|
3940
|
-
|
|
3941
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
3942
|
-
|
|
3943
|
-
switch (_a.label) {
|
|
3944
|
-
case 0:
|
|
3945
|
-
return [4, this._destroy(name)];
|
|
3946
|
-
case 1:
|
|
3947
|
-
_a.sent();
|
|
3948
|
-
return [2];
|
|
3949
|
-
}
|
|
3950
|
-
});
|
|
3305
|
+
}
|
|
3306
|
+
destroy(name) {
|
|
3307
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
3308
|
+
yield this._destroy(name);
|
|
3951
3309
|
});
|
|
3952
|
-
}
|
|
3953
|
-
|
|
3954
|
-
|
|
3955
|
-
|
|
3956
|
-
|
|
3957
|
-
|
|
3958
|
-
|
|
3959
|
-
|
|
3960
|
-
|
|
3961
|
-
|
|
3962
|
-
|
|
3963
|
-
|
|
3964
|
-
if (!!loadError) return [3, 5];
|
|
3965
|
-
_a.label = 1;
|
|
3966
|
-
case 1:
|
|
3967
|
-
_a.trys.push([1, 4,, 5]);
|
|
3968
|
-
if (!this.destroyInstanceFunctions[resource.type]) return [3, 3];
|
|
3969
|
-
return [4, this.destroyInstanceFunctions[resource.type](resource)];
|
|
3970
|
-
case 2:
|
|
3971
|
-
_a.sent();
|
|
3972
|
-
_a.label = 3;
|
|
3973
|
-
case 3:
|
|
3974
|
-
return [3, 5];
|
|
3975
|
-
case 4:
|
|
3976
|
-
e_2 = _a.sent();
|
|
3977
|
-
console.warn("destroy resource " + resource.name + " error with '" + e_2.message + "'");
|
|
3978
|
-
return [3, 5];
|
|
3979
|
-
case 5:
|
|
3980
|
-
delete this.promiseMap[name];
|
|
3981
|
-
resource.data = {};
|
|
3982
|
-
resource.complete = false;
|
|
3983
|
-
resource.instance = undefined;
|
|
3984
|
-
return [2];
|
|
3310
|
+
}
|
|
3311
|
+
_destroy(name, loadError = false) {
|
|
3312
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
3313
|
+
const resource = this.resourcesMap[name];
|
|
3314
|
+
if (!resource) return;
|
|
3315
|
+
if (!loadError) {
|
|
3316
|
+
try {
|
|
3317
|
+
if (this.destroyInstanceFunctions[resource.type]) {
|
|
3318
|
+
yield this.destroyInstanceFunctions[resource.type](resource);
|
|
3319
|
+
}
|
|
3320
|
+
} catch (e) {
|
|
3321
|
+
console.warn(`destroy resource ${resource.name} error with '${e.message}'`);
|
|
3985
3322
|
}
|
|
3986
|
-
}
|
|
3323
|
+
}
|
|
3324
|
+
delete this.promiseMap[name];
|
|
3325
|
+
resource.data = {};
|
|
3326
|
+
resource.complete = false;
|
|
3327
|
+
resource.instance = undefined;
|
|
3987
3328
|
});
|
|
3988
|
-
}
|
|
3989
|
-
|
|
3990
|
-
if (value === void 0) {
|
|
3991
|
-
value = type;
|
|
3992
|
-
}
|
|
3329
|
+
}
|
|
3330
|
+
registerResourceType(type, value = type) {
|
|
3993
3331
|
if (exports.RESOURCE_TYPE[type]) {
|
|
3994
|
-
throw new Error(
|
|
3332
|
+
throw new Error(`The type ${type} already exists in RESOURCE_TYPE`);
|
|
3995
3333
|
}
|
|
3996
3334
|
exports.RESOURCE_TYPE[type] = value;
|
|
3997
|
-
}
|
|
3998
|
-
|
|
3335
|
+
}
|
|
3336
|
+
registerInstance(type, callback) {
|
|
3999
3337
|
this.makeInstanceFunctions[type] = callback;
|
|
4000
|
-
}
|
|
4001
|
-
|
|
3338
|
+
}
|
|
3339
|
+
registerDestroy(type, callback) {
|
|
4002
3340
|
this.destroyInstanceFunctions[type] = callback;
|
|
4003
|
-
}
|
|
4004
|
-
|
|
4005
|
-
|
|
4006
|
-
|
|
4007
|
-
|
|
4008
|
-
|
|
4009
|
-
preload = _c === void 0 ? false : _c;
|
|
4010
|
-
var unLoadNames = names.filter(function (name) {
|
|
4011
|
-
return !_this.promiseMap[name] && _this.resourcesMap[name];
|
|
4012
|
-
});
|
|
3341
|
+
}
|
|
3342
|
+
loadResource({
|
|
3343
|
+
names = [],
|
|
3344
|
+
preload = false
|
|
3345
|
+
}) {
|
|
3346
|
+
const unLoadNames = names.filter(name => !this.promiseMap[name] && this.resourcesMap[name]);
|
|
4013
3347
|
if (!unLoadNames.length) return;
|
|
4014
|
-
|
|
4015
|
-
unLoadNames.forEach(
|
|
4016
|
-
var
|
|
4017
|
-
|
|
4018
|
-
|
|
4019
|
-
|
|
4020
|
-
|
|
4021
|
-
var res = _this.resourcesMap[name];
|
|
4022
|
-
try {
|
|
4023
|
-
for (var _c = __values(_this.preProcessResourceHandlers), _d = _c.next(); !_d.done; _d = _c.next()) {
|
|
4024
|
-
var handler = _d.value;
|
|
4025
|
-
handler(res);
|
|
4026
|
-
}
|
|
4027
|
-
} catch (e_3_1) {
|
|
4028
|
-
e_3 = {
|
|
4029
|
-
error: e_3_1
|
|
4030
|
-
};
|
|
4031
|
-
} finally {
|
|
4032
|
-
try {
|
|
4033
|
-
if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
|
|
4034
|
-
} finally {
|
|
4035
|
-
if (e_3) throw e_3.error;
|
|
4036
|
-
}
|
|
3348
|
+
const resolves = {};
|
|
3349
|
+
unLoadNames.forEach(name => {
|
|
3350
|
+
var _a;
|
|
3351
|
+
this.promiseMap[name] = new Promise(r => resolves[name] = r);
|
|
3352
|
+
const res = this.resourcesMap[name];
|
|
3353
|
+
for (const handler of this.preProcessResourceHandlers) {
|
|
3354
|
+
handler(res);
|
|
4037
3355
|
}
|
|
4038
|
-
|
|
4039
|
-
|
|
3356
|
+
for (const key in res.src) {
|
|
3357
|
+
const resourceType = res.src[key].type;
|
|
4040
3358
|
if (resourceType === 'data') {
|
|
4041
3359
|
res.data[key] = res.src[key].data;
|
|
4042
|
-
|
|
3360
|
+
this.doComplete(name, resolves[name], preload);
|
|
4043
3361
|
} else {
|
|
4044
|
-
|
|
3362
|
+
let url = (_a = res.src[key]) === null || _a === void 0 ? void 0 : _a.url;
|
|
4045
3363
|
if (typeof url === 'string' && url.startsWith('//')) {
|
|
4046
|
-
url =
|
|
3364
|
+
url = `${window.location.protocol}${res.src[key].url}`;
|
|
4047
3365
|
}
|
|
4048
3366
|
if (key === 'atlas') {
|
|
4049
3367
|
pixi_js.Assets.add({
|
|
4050
3368
|
alias: url,
|
|
4051
3369
|
src: url,
|
|
4052
3370
|
data: {
|
|
4053
|
-
resolve:
|
|
4054
|
-
return pixi_js.Assets.load(res.src['image'].url);
|
|
4055
|
-
}
|
|
3371
|
+
resolve: () => pixi_js.Assets.load(res.src['image'].url)
|
|
4056
3372
|
}
|
|
4057
3373
|
});
|
|
4058
3374
|
} else {
|
|
@@ -4061,141 +3377,122 @@ var _EVA_IIFE_EVA = function (exports, pixi_js) {
|
|
|
4061
3377
|
src: url
|
|
4062
3378
|
});
|
|
4063
3379
|
}
|
|
4064
|
-
pixi_js.Assets.load(url).then(
|
|
4065
|
-
|
|
4066
|
-
preload
|
|
3380
|
+
pixi_js.Assets.load(url).then(data => {
|
|
3381
|
+
this.onLoad({
|
|
3382
|
+
preload,
|
|
4067
3383
|
resource: {
|
|
4068
3384
|
metadata: {
|
|
4069
|
-
key
|
|
4070
|
-
name
|
|
4071
|
-
resolves
|
|
3385
|
+
key,
|
|
3386
|
+
name,
|
|
3387
|
+
resolves
|
|
4072
3388
|
},
|
|
4073
3389
|
data: data
|
|
4074
3390
|
}
|
|
4075
3391
|
});
|
|
4076
|
-
}).catch(
|
|
3392
|
+
}).catch(e => {
|
|
4077
3393
|
console.log('>>>E', e);
|
|
4078
|
-
|
|
4079
|
-
preload
|
|
3394
|
+
this.onError({
|
|
3395
|
+
preload,
|
|
4080
3396
|
errMsg: e.message,
|
|
4081
3397
|
resource: {
|
|
4082
3398
|
metadata: {
|
|
4083
|
-
key
|
|
4084
|
-
name
|
|
4085
|
-
resolves
|
|
3399
|
+
key,
|
|
3400
|
+
name,
|
|
3401
|
+
resolves
|
|
4086
3402
|
}
|
|
4087
3403
|
}
|
|
4088
3404
|
});
|
|
4089
3405
|
});
|
|
4090
3406
|
}
|
|
4091
|
-
};
|
|
4092
|
-
for (var key in res.src) {
|
|
4093
|
-
_loop_1(key);
|
|
4094
3407
|
}
|
|
4095
3408
|
});
|
|
4096
|
-
}
|
|
4097
|
-
|
|
4098
|
-
|
|
4099
|
-
|
|
4100
|
-
|
|
4101
|
-
|
|
4102
|
-
|
|
4103
|
-
|
|
4104
|
-
|
|
4105
|
-
|
|
4106
|
-
|
|
4107
|
-
|
|
4108
|
-
|
|
4109
|
-
|
|
4110
|
-
|
|
4111
|
-
|
|
4112
|
-
|
|
4113
|
-
|
|
4114
|
-
|
|
4115
|
-
|
|
4116
|
-
|
|
4117
|
-
|
|
4118
|
-
|
|
4119
|
-
|
|
4120
|
-
|
|
4121
|
-
|
|
4122
|
-
this.progress.onProgress(param);
|
|
4123
|
-
}
|
|
4124
|
-
resolve(res);
|
|
4125
|
-
return [3, 4];
|
|
4126
|
-
case 3:
|
|
4127
|
-
err_1 = _b.sent();
|
|
4128
|
-
console.error(err_1);
|
|
4129
|
-
res.complete = false;
|
|
4130
|
-
if (preload) {
|
|
4131
|
-
param.errMsg = err_1.message;
|
|
4132
|
-
param.success = false;
|
|
4133
|
-
this.progress.onProgress(param);
|
|
4134
|
-
}
|
|
4135
|
-
resolve({});
|
|
4136
|
-
return [3, 4];
|
|
4137
|
-
case 4:
|
|
4138
|
-
return [2];
|
|
3409
|
+
}
|
|
3410
|
+
doComplete(name, resolve, preload = false) {
|
|
3411
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
3412
|
+
const res = this.resourcesMap[name];
|
|
3413
|
+
const param = {
|
|
3414
|
+
name,
|
|
3415
|
+
resource: this.resourcesMap[name],
|
|
3416
|
+
success: true
|
|
3417
|
+
};
|
|
3418
|
+
if (this.checkAllLoaded(name)) {
|
|
3419
|
+
try {
|
|
3420
|
+
res.instance = yield this.instance(name);
|
|
3421
|
+
res.complete = true;
|
|
3422
|
+
if (preload) {
|
|
3423
|
+
this.progress.onProgress(param);
|
|
3424
|
+
}
|
|
3425
|
+
resolve(res);
|
|
3426
|
+
} catch (err) {
|
|
3427
|
+
console.error(err);
|
|
3428
|
+
res.complete = false;
|
|
3429
|
+
if (preload) {
|
|
3430
|
+
param.errMsg = err.message;
|
|
3431
|
+
param.success = false;
|
|
3432
|
+
this.progress.onProgress(param);
|
|
3433
|
+
}
|
|
3434
|
+
resolve({});
|
|
4139
3435
|
}
|
|
4140
|
-
}
|
|
4141
|
-
});
|
|
4142
|
-
};
|
|
4143
|
-
Resource.prototype.checkAllLoaded = function (name) {
|
|
4144
|
-
var res = this.resourcesMap[name];
|
|
4145
|
-
return Array.from(Object.keys(res.src)).every(function (resourceKey) {
|
|
4146
|
-
return res.data[resourceKey];
|
|
3436
|
+
}
|
|
4147
3437
|
});
|
|
4148
|
-
}
|
|
4149
|
-
|
|
4150
|
-
|
|
4151
|
-
|
|
4152
|
-
|
|
4153
|
-
|
|
4154
|
-
|
|
4155
|
-
|
|
4156
|
-
|
|
4157
|
-
|
|
4158
|
-
|
|
4159
|
-
|
|
4160
|
-
|
|
4161
|
-
|
|
4162
|
-
|
|
3438
|
+
}
|
|
3439
|
+
checkAllLoaded(name) {
|
|
3440
|
+
const res = this.resourcesMap[name];
|
|
3441
|
+
return Array.from(Object.keys(res.src)).every(resourceKey => res.data[resourceKey]);
|
|
3442
|
+
}
|
|
3443
|
+
getLoader(_preload = false) {}
|
|
3444
|
+
onLoad({
|
|
3445
|
+
preload = false,
|
|
3446
|
+
resource
|
|
3447
|
+
}) {
|
|
3448
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
3449
|
+
const {
|
|
3450
|
+
metadata: {
|
|
3451
|
+
key,
|
|
3452
|
+
name,
|
|
3453
|
+
resolves
|
|
3454
|
+
},
|
|
3455
|
+
data
|
|
3456
|
+
} = resource;
|
|
3457
|
+
const res = this.resourcesMap[name];
|
|
3458
|
+
res.data[key] = data;
|
|
3459
|
+
this.doComplete(name, resolves[name], preload);
|
|
4163
3460
|
});
|
|
4164
|
-
}
|
|
4165
|
-
|
|
4166
|
-
|
|
4167
|
-
|
|
4168
|
-
|
|
4169
|
-
|
|
4170
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
4171
|
-
|
|
4172
|
-
|
|
4173
|
-
|
|
4174
|
-
|
|
4175
|
-
resolves[name]({});
|
|
4176
|
-
if (preload) {
|
|
4177
|
-
param = {
|
|
4178
|
-
name: name,
|
|
4179
|
-
resource: this.resourcesMap[name],
|
|
4180
|
-
success: false,
|
|
4181
|
-
errMsg: errMsg
|
|
4182
|
-
};
|
|
4183
|
-
this.progress.onProgress(param);
|
|
3461
|
+
}
|
|
3462
|
+
onError({
|
|
3463
|
+
errMsg,
|
|
3464
|
+
preload = false,
|
|
3465
|
+
resource
|
|
3466
|
+
}) {
|
|
3467
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
3468
|
+
const {
|
|
3469
|
+
metadata: {
|
|
3470
|
+
name,
|
|
3471
|
+
resolves
|
|
4184
3472
|
}
|
|
4185
|
-
|
|
4186
|
-
|
|
3473
|
+
} = resource;
|
|
3474
|
+
this._destroy(name, true);
|
|
3475
|
+
resolves[name]({});
|
|
3476
|
+
if (preload) {
|
|
3477
|
+
const param = {
|
|
3478
|
+
name,
|
|
3479
|
+
resource: this.resourcesMap[name],
|
|
3480
|
+
success: false,
|
|
3481
|
+
errMsg
|
|
3482
|
+
};
|
|
3483
|
+
this.progress.onProgress(param);
|
|
3484
|
+
}
|
|
4187
3485
|
});
|
|
4188
|
-
}
|
|
4189
|
-
|
|
4190
|
-
|
|
4191
|
-
|
|
4192
|
-
|
|
4193
|
-
|
|
4194
|
-
componentObserver: componentObserver
|
|
3486
|
+
}
|
|
3487
|
+
}
|
|
3488
|
+
const resource = new Resource();
|
|
3489
|
+
const decorators = {
|
|
3490
|
+
IDEProp,
|
|
3491
|
+
componentObserver
|
|
4195
3492
|
};
|
|
4196
|
-
|
|
4197
|
-
console.log(
|
|
4198
|
-
|
|
3493
|
+
const version = '2.0.0-beta.3';
|
|
3494
|
+
console.log(`Eva.js version: ${version}`);
|
|
3495
|
+
const RESOURCE_TYPE_STRATEGY = {};
|
|
4199
3496
|
exports.Component = Component$1;
|
|
4200
3497
|
exports.Game = Game$1;
|
|
4201
3498
|
exports.GameObject = GameObject$1;
|