squishjs 1.3.5 → 1.3.7
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/package.json +1 -1
- package/src/Asset.js +3 -3
- package/src/BaseNode.js +1 -1
- package/src/Game.js +1 -1
- package/src/Squisher.js +14 -18
package/package.json
CHANGED
package/src/Asset.js
CHANGED
|
@@ -95,7 +95,7 @@ class Asset {
|
|
|
95
95
|
existsLocally() {
|
|
96
96
|
return new Promise((resolve, reject) => {
|
|
97
97
|
if (this.data) {
|
|
98
|
-
resolve(true);
|
|
98
|
+
return resolve(true);
|
|
99
99
|
}
|
|
100
100
|
const fileLocation = this.getFileLocation(this.info.id);
|
|
101
101
|
this.fs.exists(fileLocation, (exists) => {
|
|
@@ -118,7 +118,7 @@ class Asset {
|
|
|
118
118
|
} else {
|
|
119
119
|
const fileLocation2 = await downloadFileSync(this.info.id, HG_ASSET_PATH);
|
|
120
120
|
this.initialized = true;
|
|
121
|
-
return
|
|
121
|
+
return fileLocation2;
|
|
122
122
|
}
|
|
123
123
|
}
|
|
124
124
|
|
|
@@ -170,7 +170,7 @@ class Asset {
|
|
|
170
170
|
const filePath = `${path}/${fileHash}`;
|
|
171
171
|
|
|
172
172
|
const writeStream = this.fs.createWriteStream(filePath);
|
|
173
|
-
const getModule = this.https;
|
|
173
|
+
const getModule = ASSET_URL.startsWith('https') ? this.https : this.http;
|
|
174
174
|
|
|
175
175
|
writeStream.on('close', () => {
|
|
176
176
|
resolve(filePath);
|
package/src/BaseNode.js
CHANGED
package/src/Game.js
CHANGED
package/src/Squisher.js
CHANGED
|
@@ -42,7 +42,7 @@ class Squisher {
|
|
|
42
42
|
}
|
|
43
43
|
|
|
44
44
|
removeListener(listener) {
|
|
45
|
-
this.listeners.
|
|
45
|
+
this.listeners.delete(listener);
|
|
46
46
|
}
|
|
47
47
|
|
|
48
48
|
unsquish(node) {
|
|
@@ -97,9 +97,7 @@ class Squisher {
|
|
|
97
97
|
}
|
|
98
98
|
|
|
99
99
|
handleNewAsset(key, asset) {
|
|
100
|
-
return
|
|
101
|
-
this.initialize().then(resolve);
|
|
102
|
-
});
|
|
100
|
+
return this.initialize();
|
|
103
101
|
}
|
|
104
102
|
|
|
105
103
|
squishHelper(node, squishedNodes, scale = {x: 1, y: 1}, playerMap = {}, playerIdFilter = new Set()) {
|
|
@@ -122,15 +120,7 @@ class Squisher {
|
|
|
122
120
|
}
|
|
123
121
|
|
|
124
122
|
if (node.node.playerIds.length === 0 || node.node.playerIds.findIndex(i => Number(i) === Number(playerId)) >= 0) {
|
|
125
|
-
|
|
126
|
-
const assetInfo = this.gameAssets[Object.keys(node.node.asset)[0]]?.info;
|
|
127
|
-
if (assetInfo.type === 'audio' && !this.playerSettings[playerId]?.SOUND?.ENABLED) {
|
|
128
|
-
} else {
|
|
129
|
-
playerMap[playerId].push(squished);
|
|
130
|
-
}
|
|
131
|
-
} else {
|
|
132
|
-
playerMap[playerId].push(squished);
|
|
133
|
-
}
|
|
123
|
+
playerMap[playerId].push(squished);
|
|
134
124
|
} else {
|
|
135
125
|
playerIdsToRemove.add(playerId);
|
|
136
126
|
}
|
|
@@ -205,6 +195,12 @@ class Squisher {
|
|
|
205
195
|
let assetBundleSize = 0;
|
|
206
196
|
let finishedCount = 0;
|
|
207
197
|
const totalCount = Object.keys(allAssets).length;
|
|
198
|
+
|
|
199
|
+
if (totalCount === 0) {
|
|
200
|
+
this.assetBundle = [];
|
|
201
|
+
resolve([]);
|
|
202
|
+
return;
|
|
203
|
+
}
|
|
208
204
|
|
|
209
205
|
for (const key in allAssets) {
|
|
210
206
|
allAssets[key].getData().then(buf => {
|
|
@@ -245,11 +241,10 @@ class Squisher {
|
|
|
245
241
|
|
|
246
242
|
if (finishedCount == totalCount) {
|
|
247
243
|
const newAssetBundle = new Array(assetBundleSize);
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
}
|
|
244
|
+
let index = 0;
|
|
245
|
+
for (const key in this.assets) {
|
|
246
|
+
for (let y = 0; y < this.assets[key].length; y++) {
|
|
247
|
+
newAssetBundle[index++] = this.assets[key][y];
|
|
253
248
|
}
|
|
254
249
|
}
|
|
255
250
|
this.assetBundle = newAssetBundle;
|
|
@@ -258,6 +253,7 @@ class Squisher {
|
|
|
258
253
|
}).catch(err => {
|
|
259
254
|
console.error('Unable to get asset data for key ' + key);
|
|
260
255
|
console.error(err);
|
|
256
|
+
reject(err);
|
|
261
257
|
});
|
|
262
258
|
}
|
|
263
259
|
|