fix: resilience
This commit is contained in:
parent
5db2e4905c
commit
89c32a2299
|
@ -10,6 +10,9 @@ class TestServer extends Server {
|
|||
super();
|
||||
this.data = {};
|
||||
}
|
||||
async readAsset() {
|
||||
return new ArrayBuffer(0);
|
||||
}
|
||||
async readData(path) {
|
||||
if (path in this.data) {
|
||||
return this.data[path];
|
||||
|
@ -34,16 +37,17 @@ test('visibility-based updates', async () => {
|
|||
Position: {x: (RESOLUTION.x * 1.5) + 32 - 3, y: 20},
|
||||
VisibleAabb: {},
|
||||
}));
|
||||
const {entity: mainEntity} = engine.connectedPlayers.get(0);
|
||||
// Tick and get update. Should be a full update.
|
||||
engine.tick(1);
|
||||
expect(engine.updateFor(0))
|
||||
.to.deep.include({2: {MainEntity: {}, ...ecs.get(2).toJSON()}, 3: ecs.get(3).toJSON()});
|
||||
.to.deep.include({[mainEntity.id]: {MainEntity: {}, ...ecs.get(mainEntity.id).toJSON()}, [entity.id]: ecs.get(entity.id).toJSON()});
|
||||
engine.setClean();
|
||||
// Tick and get update. Should be a partial update.
|
||||
engine.tick(1);
|
||||
expect(engine.updateFor(0))
|
||||
.to.deep.include({
|
||||
3: {
|
||||
[entity.id]: {
|
||||
Position: {x: (RESOLUTION.x * 1.5) + 32 - 1},
|
||||
VisibleAabb: {
|
||||
x0: 1199,
|
||||
|
@ -55,11 +59,11 @@ test('visibility-based updates', async () => {
|
|||
// Tick and get update. Should remove the entity.
|
||||
engine.tick(1);
|
||||
expect(engine.updateFor(0))
|
||||
.to.deep.include({3: false});
|
||||
.to.deep.include({[entity.id]: false});
|
||||
// Aim back toward visible area and tick. Should be a full update for that entity.
|
||||
engine.setClean();
|
||||
entity.Forces.forceX = -1;
|
||||
engine.tick(1);
|
||||
expect(engine.updateFor(0))
|
||||
.to.deep.include({3: ecs.get(3).toJSON()});
|
||||
.to.deep.include({[entity.id]: ecs.get(entity.id).toJSON()});
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue
Block a user