refactor: followed handles room changes

This commit is contained in:
cha0s 2019-04-05 12:25:43 -04:00
parent 867262e81d
commit 00359fb6f9

View File

@ -41,11 +41,6 @@ const room = new Room();
room.world = new World();
const roomView = new RoomView(room, stage.renderer);
stage.addChild(roomView);
room.on('sizeChanged', () => {
if (hasSelfEntity() && selfEntity.is('followed')) {
selfEntity.camera.areaSize = room.size;
}
});
// Time.
const worldTime = new WorldTime();
let lastWorldTime = worldTime.humanReadable();
@ -65,7 +60,6 @@ room.on('entityAdded', (entity) => {
// Camera tracking.
entity.addTrait('followed');
const {camera} = entity;
camera.areaSize = room.size;
camera.on('realPositionChanged', () => {
roomView.position = Vector.round(
Vector.sub(halfVisibleSize, camera.realPosition)