squishjs 0.7.67 → 1.0.0

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "squishjs",
3
- "version": "0.7.67",
3
+ "version": "1.0.0",
4
4
  "description": "squish & unsquish stuff",
5
5
  "scripts": {
6
6
  "test": "node testRunner.js"
package/src/Squisher.js CHANGED
@@ -10,6 +10,7 @@ class Squisher {
10
10
  this.ids = new Set();
11
11
 
12
12
  this.game = game;
13
+ this.gameMetadata = game.constructor.metadata && game.constructor.metadata();
13
14
  this.assets = {};
14
15
 
15
16
  this.customBottomLayer = customBottomLayer;
@@ -113,12 +114,21 @@ class Squisher {
113
114
  }
114
115
 
115
116
  if (playerIdFilter.size > 0) {
117
+
118
+ let playerIdsToRemove = new Set();
116
119
  for (let playerId of playerIdFilter) {
117
120
  if (!playerMap[playerId]) {
118
121
  playerMap[Number(playerId)] = [];
119
122
  }
120
123
 
121
- playerMap[playerId].push(squished);
124
+ if (node.node.playerIds.length === 0 || node.node.playerIds.findIndex(i => Number(i) === Number(playerId)) >= 0) {
125
+ playerMap[playerId].push(squished);
126
+ } else {
127
+ playerIdsToRemove.add(playerId);
128
+ }
129
+ }
130
+ for (let id of playerIdsToRemove) {
131
+ playerIdFilter.delete(id);
122
132
  }
123
133
  } else {
124
134
  Object.keys(playerMap).forEach(playerId => {
@@ -130,12 +140,28 @@ class Squisher {
130
140
  }
131
141
 
132
142
  for (let i = 0; i < node.node.children.length; i++) {
143
+ // if (node.node.children[i].node.playerIds
133
144
  // make a new set so child calls within a single generation arent
134
145
  // modifying the same filter set
135
146
  const pathFilter = new Set(playerIdFilter);
136
147
  this.squishHelper(node.node.children[i], squishedNodes, scale, playerMap, pathFilter);
137
148
  }
138
149
 
150
+ // debug
151
+ for (let k in playerMap) {
152
+ for (let squished in playerMap[k]) {
153
+ const unsquished = unsquish(playerMap[k][squished]);
154
+ if (unsquished.node.playerIds.length > 0 && unsquished.node.playerIds.findIndex(i => Number(i) === Number(k)) < 0) {
155
+ console.log(unsquished.node.playerIds);
156
+ console.log(k);
157
+ console.log(unsquished.node.playerIds.indexOf(k));
158
+ if (k != 254) {
159
+ throw new Error('fuk');
160
+ }
161
+ }
162
+ }
163
+ }
164
+
139
165
  }
140
166
 
141
167
  getJson() {
@@ -43,6 +43,9 @@ test("test layer with child added", () => {
43
43
  ]);
44
44
 
45
45
  const squisher = new Squisher({ game });
46
+
47
+ // add listener so squisher cares about update
48
+ squisher.addListener(() => {});
46
49
 
47
50
  const initialState = Array.from(squisher.state);
48
51
  assert(initialState.length === 2);