feat: camera-based state diff!
This commit is contained in:
parent
00359fb6f9
commit
e5f738202b
|
@ -24,6 +24,7 @@ export function createEntityForConnection(socket) {
|
|||
},
|
||||
},
|
||||
existent: {},
|
||||
followed: {},
|
||||
graphical: {},
|
||||
mobile: {
|
||||
state: {
|
||||
|
|
|
@ -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) {}
|
||||
|
|
Loading…
Reference in New Issue
Block a user