Comparing version 0.7.2 to 0.7.3
{ | ||
"name": "squishjs", | ||
"version": "0.7.2", | ||
"version": "0.7.3", | ||
"description": "squish & unsquish stuff", | ||
@@ -5,0 +5,0 @@ "scripts": { |
@@ -22,3 +22,3 @@ const ASSET_TYPE = 1; | ||
this.state = this.squish(this.game.getLayers()); | ||
this.spectatorState = this.game.getSpectatorLayers ? this.squish(this.game.getSpectatorLayers()) : []; | ||
// this.spectatorState = this.game.getSpectatorLayers ? this.squish(this.game.getSpectatorLayers()) : []; | ||
this.assets = {}; | ||
@@ -84,3 +84,3 @@ if (this.game.tick) { | ||
if (this.customTopLayer) { | ||
if (this.customTopLayer) { | ||
const squishedLayer = []; | ||
@@ -100,3 +100,3 @@ this.squishHelper(this.customTopLayer.root, squishedLayer, this.customTopLayer.scale, playerMap); | ||
squishHelper(node, squishedNodes, scale = {x: 1, y: 1}, playerMap = {}) { | ||
squishHelper(node, squishedNodes, scale = {x: 1, y: 1}, playerMap = {}, playerIdFilter = new Set()) { | ||
if (!node.node.listeners.has(this)) { | ||
@@ -109,5 +109,8 @@ node.addListener(this); | ||
if (playerMap) { | ||
if (node.node.playerIds && node.node.playerIds.length) { | ||
node.node.playerIds.forEach(playerId => { | ||
if (node.node.playerIds && node.node.playerIds.length > 0) { | ||
node.node.playerIds.forEach(pId => playerIdFilter.add(pId)); | ||
} | ||
if (playerIdFilter.size > 0) { | ||
for (let playerId of playerIdFilter) { | ||
if (playerMap[playerId]) { | ||
@@ -118,12 +121,14 @@ playerMap[playerId].push(squished); | ||
} | ||
}); | ||
} else { | ||
Object.keys(playerMap).forEach(playerId => { | ||
playerMap[playerId].push(squished); | ||
}) | ||
} | ||
} | ||
} else { | ||
Object.keys(playerMap).forEach(playerId => { | ||
playerMap[playerId].push(squished); | ||
}) | ||
} | ||
for (let i = 0; i < node.node.children.length; i++) { | ||
this.squishHelper(node.node.children[i], squishedNodes, scale, playerMap); | ||
// make a new set so child calls within a single generation arent | ||
// modifying the same filter set | ||
const pathFilter = new Set(playerIdFilter); | ||
this.squishHelper(node.node.children[i], squishedNodes, scale, playerMap, pathFilter); | ||
} | ||
@@ -130,0 +135,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
159366
3837