feat: only send mergeDiff for EntityCreatePacket
This commit is contained in:
parent
b7cd05732d
commit
df89cbf51e
4
TODO.md
4
TODO.md
|
@ -2,9 +2,9 @@
|
||||||
|
|
||||||
- ✔ React UI
|
- ✔ React UI
|
||||||
- ❌ Multiple rooms
|
- ❌ Multiple rooms
|
||||||
- ❌ Send relevant entity URIs to client; cache and use instead of full transfer
|
- ✔ Send relevant entity URIs to client; cache and use instead of full transfer
|
||||||
- ✔ Forget remembered entities after a while
|
- ✔ Forget remembered entities after a while
|
||||||
- ❌ Optimize informed and Packer::pack: don't use .map on immutables
|
- ✔ Optimize informed and Packer::pack: don't use .map on immutables
|
||||||
- ✔ Optimize Damaging::tick
|
- ✔ Optimize Damaging::tick
|
||||||
- ✔ Manual state sync
|
- ✔ Manual state sync
|
||||||
- ✔ Informed tracks seen entities (etc?), responsible for upgrading updates
|
- ✔ Informed tracks seen entities (etc?), responsible for upgrading updates
|
||||||
|
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -346,7 +346,9 @@ function mamaKittyJSON(position) {
|
||||||
traits.spawner = {
|
traits.spawner = {
|
||||||
params: {
|
params: {
|
||||||
spawns: {
|
spawns: {
|
||||||
kitteh: kittyJSON([100, 100]),
|
kitteh: {
|
||||||
|
uri: '/kitty.entity.json',
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
state: {
|
state: {
|
||||||
|
@ -355,53 +357,7 @@ function mamaKittyJSON(position) {
|
||||||
};
|
};
|
||||||
return json;
|
return json;
|
||||||
}
|
}
|
||||||
// Room.
|
// Mama kitty spawner.
|
||||||
const roomTileSize = [24, 24];
|
|
||||||
const roomSize = Vector.mul([16, 16], roomTileSize);
|
|
||||||
const roomJSON = {
|
|
||||||
size: roomSize,
|
|
||||||
layers: [
|
|
||||||
{
|
|
||||||
entities: [],
|
|
||||||
tiles: {
|
|
||||||
size: roomTileSize,
|
|
||||||
data: [
|
|
||||||
1, 2, 3, 4, 1, 2, 3, 4, 1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
|
||||||
1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4,
|
|
||||||
1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4,
|
|
||||||
1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4,
|
|
||||||
1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4,
|
|
||||||
],
|
|
||||||
},
|
|
||||||
tilesetUri: '/tileset.json',
|
|
||||||
},
|
|
||||||
],
|
|
||||||
};
|
|
||||||
function mamaKittySpawnerJSON() {
|
function mamaKittySpawnerJSON() {
|
||||||
|
|
||||||
const storeJSON = buildTraversal(
|
const storeJSON = buildTraversal(
|
||||||
|
@ -468,7 +424,9 @@ function mamaKittySpawnerJSON() {
|
||||||
spawner: {
|
spawner: {
|
||||||
params: {
|
params: {
|
||||||
spawns: {
|
spawns: {
|
||||||
mama: mamaKittyJSON([0, 0]),
|
mama: {
|
||||||
|
uri: '/mama-kitty.entity.json',
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
state: {
|
state: {
|
||||||
|
@ -479,6 +437,54 @@ function mamaKittySpawnerJSON() {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Room.
|
||||||
|
const roomTileSize = [24, 24];
|
||||||
|
const roomSize = Vector.mul([16, 16], roomTileSize);
|
||||||
|
const roomJSON = {
|
||||||
|
size: roomSize,
|
||||||
|
layers: [
|
||||||
|
{
|
||||||
|
entities: [],
|
||||||
|
tiles: {
|
||||||
|
size: roomTileSize,
|
||||||
|
data: [
|
||||||
|
1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4,
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, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4,
|
||||||
|
1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4,
|
||||||
|
1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4,
|
||||||
|
1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4,
|
||||||
|
],
|
||||||
|
},
|
||||||
|
tilesetUri: '/tileset.json',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
};
|
||||||
|
|
||||||
const RESOURCE_PATH = path.resolve(process.cwd(), 'resource');
|
const RESOURCE_PATH = path.resolve(process.cwd(), 'resource');
|
||||||
|
|
||||||
fs.writeFileSync(
|
fs.writeFileSync(
|
||||||
|
|
|
@ -137,7 +137,7 @@ export class Informed extends decorate(Trait) {
|
||||||
packets.splice(
|
packets.splice(
|
||||||
i,
|
i,
|
||||||
0,
|
0,
|
||||||
new EntityCreatePacket(entity.toJSON(), entity)
|
new EntityCreatePacket(entity.mergeDiff(), entity)
|
||||||
);
|
);
|
||||||
i += 1;
|
i += 1;
|
||||||
// We've seen it.
|
// We've seen it.
|
||||||
|
@ -152,7 +152,7 @@ export class Informed extends decorate(Trait) {
|
||||||
const entity = visibleButNotYetSeen[i];
|
const entity = visibleButNotYetSeen[i];
|
||||||
// Skip any existing creates.
|
// Skip any existing creates.
|
||||||
if (-1 === allExistingCreatedEntities.indexOf(entity)) {
|
if (-1 === allExistingCreatedEntities.indexOf(entity)) {
|
||||||
packets.push(new EntityCreatePacket(entity.toJSON(), entity));
|
packets.push(new EntityCreatePacket(entity.mergeDiff(), entity));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return packets;
|
return packets;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user