feat: camera-based state diff!

This commit is contained in:
cha0s 2019-04-05 12:59:14 -04:00
parent 00359fb6f9
commit e5f738202b
2 changed files with 5 additions and 12 deletions

View File

@ -24,6 +24,7 @@ export function createEntityForConnection(socket) {
},
},
existent: {},
followed: {},
graphical: {},
mobile: {
state: {

View File

@ -2,19 +2,12 @@ import * as I from 'immutable';
import isPlainObject from 'is-plain-object';
import {compose} from '@avocado/core';
import {StateProperty, Trait} from '@avocado/entity';
import {Trait} from '@avocado/entity';
const decorate = compose(
StateProperty('informSize'),
);
class InformedBase extends Trait {
static defaultState() {
return {
informSize: [640, 360],
};
}
export class Informed extends decorate(Trait) {
initialize() {
this.entityReducer = this.createIndexedReducer();
@ -81,11 +74,12 @@ class InformedBase extends Trait {
return diff
}
const room = this.entity.room;
const camera = this.entity.camera;
for (const index in diff.room.layers) {
// Index entities.
const layer = room.layer(index);
const visibleEntities = layer.visibleEntities(
[0, 0, 320, 180]
camera.rectangle
);
const indexedEntities = {};
for (const entity of visibleEntities) {
@ -135,5 +129,3 @@ class InformedBase extends Trait {
}
}
export class Informed extends decorate(InformedBase) {}