squishjs 1.0.9 → 1.0.10
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/Squisher.js +29 -3
package/package.json
CHANGED
package/src/Squisher.js
CHANGED
|
@@ -12,6 +12,7 @@ class Squisher {
|
|
|
12
12
|
this.game = game;
|
|
13
13
|
this.gameMetadata = game.constructor.metadata && game.constructor.metadata();
|
|
14
14
|
this.assets = {};
|
|
15
|
+
this.playerSettings = {};
|
|
15
16
|
|
|
16
17
|
this.customBottomLayer = customBottomLayer;
|
|
17
18
|
this.customTopLayer = customTopLayer;
|
|
@@ -114,7 +115,6 @@ class Squisher {
|
|
|
114
115
|
}
|
|
115
116
|
|
|
116
117
|
if (playerIdFilter.size > 0) {
|
|
117
|
-
|
|
118
118
|
let playerIdsToRemove = new Set();
|
|
119
119
|
for (let playerId of playerIdFilter) {
|
|
120
120
|
if (!playerMap[playerId]) {
|
|
@@ -122,7 +122,15 @@ class Squisher {
|
|
|
122
122
|
}
|
|
123
123
|
|
|
124
124
|
if (node.node.playerIds.length === 0 || node.node.playerIds.findIndex(i => Number(i) === Number(playerId)) >= 0) {
|
|
125
|
-
|
|
125
|
+
if (node.node.asset) {
|
|
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
|
+
}
|
|
126
134
|
} else {
|
|
127
135
|
playerIdsToRemove.add(playerId);
|
|
128
136
|
}
|
|
@@ -135,7 +143,15 @@ class Squisher {
|
|
|
135
143
|
if (!playerMap[playerId]) {
|
|
136
144
|
playerMap[Number(playerId)] = [];
|
|
137
145
|
}
|
|
138
|
-
|
|
146
|
+
if (node.node.asset) {
|
|
147
|
+
const assetInfo = this.gameAssets[Object.keys(node.node.asset)[0]]?.info;
|
|
148
|
+
if (assetInfo.type === 'audio' && this.playerSettings[playerId]?.SOUND && !this.playerSettings[playerId].SOUND.enabled) {
|
|
149
|
+
} else {
|
|
150
|
+
playerMap[playerId].push(squished);
|
|
151
|
+
}
|
|
152
|
+
} else {
|
|
153
|
+
playerMap[playerId].push(squished);
|
|
154
|
+
}
|
|
139
155
|
})
|
|
140
156
|
}
|
|
141
157
|
|
|
@@ -170,6 +186,7 @@ class Squisher {
|
|
|
170
186
|
const gameMetadata = this.game.constructor.metadata && this.game.constructor.metadata();
|
|
171
187
|
|
|
172
188
|
const gameAssets = gameMetadata && gameMetadata.assets ? gameMetadata.assets : {};
|
|
189
|
+
this.gameAssets = gameAssets;
|
|
173
190
|
|
|
174
191
|
if (this.customBottomLayer && this.customBottomLayer.assets) {
|
|
175
192
|
Object.assign(gameAssets, this.customBottomLayer.assets);
|
|
@@ -260,6 +277,15 @@ class Squisher {
|
|
|
260
277
|
}
|
|
261
278
|
}
|
|
262
279
|
|
|
280
|
+
updatePlayerSettings(playerId, settings) {
|
|
281
|
+
const currentSettings = Object.assign(this.playerSettings[playerId] || {}, settings);
|
|
282
|
+
this.playerSettings[playerId] = currentSettings;
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
deletePlayerSettings(playerId) {
|
|
286
|
+
delete this.playerSettings[playerId];
|
|
287
|
+
}
|
|
288
|
+
|
|
263
289
|
}
|
|
264
290
|
|
|
265
291
|
module.exports = Squisher;
|