refactor: renderable
This commit is contained in:
parent
4489d96d0a
commit
0f128bcc3a
|
@ -3,7 +3,6 @@ import {gatherWithLatus} from '@latus/core';
|
||||||
export {default as Room} from './components/room';
|
export {default as Room} from './components/room';
|
||||||
|
|
||||||
export {default as Camera} from './camera';
|
export {default as Camera} from './camera';
|
||||||
export {default as RoomView} from './room-view';
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
hooks: {
|
hooks: {
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
import {EntityListView} from '@avocado/entity';
|
import {EntityListView} from '@avocado/entity';
|
||||||
import {Container} from '@avocado/graphics';
|
import {Container} from '@avocado/graphics';
|
||||||
|
|
||||||
import TilesView from './tiles-view';
|
import TilesRenderable from './tiles';
|
||||||
|
|
||||||
const views = new Set();
|
const views = new Set();
|
||||||
|
|
||||||
export default class RoomView extends Container {
|
export default class RoomRenderable extends Container {
|
||||||
|
|
||||||
layers = [];
|
layers = [];
|
||||||
|
|
||||||
|
@ -14,8 +14,8 @@ export default class RoomView extends Container {
|
||||||
this.lastExtent = [0, 0, 0, 0];
|
this.lastExtent = [0, 0, 0, 0];
|
||||||
this.renderer = renderer;
|
this.renderer = renderer;
|
||||||
this.entityListView = new EntityListView(room.entityList);
|
this.entityListView = new EntityListView(room.entityList);
|
||||||
this.tilesViews = room.tiles.map((tiles) => new TilesView(tiles, renderer));
|
this.tilesRenderables = room.tiles.map((tiles) => new TilesRenderable(tiles, renderer));
|
||||||
this.addChildren(this.tilesViews);
|
this.addChildren(this.tilesRenderables);
|
||||||
this.addChild(this.entityListView);
|
this.addChild(this.entityListView);
|
||||||
this.sort();
|
this.sort();
|
||||||
if (module.hot) {
|
if (module.hot) {
|
||||||
|
@ -31,24 +31,24 @@ export default class RoomView extends Container {
|
||||||
}
|
}
|
||||||
|
|
||||||
renderChunksForExtent(extent) {
|
renderChunksForExtent(extent) {
|
||||||
this.tilesViews.forEach((tilesView) => {
|
this.tilesRenderables.forEach((tilesRenderable) => {
|
||||||
tilesView.renderChunksForExtent(extent);
|
tilesRenderable.renderChunksForExtent(extent);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (module.hot) {
|
if (module.hot) {
|
||||||
module.hot.accept('./tiles-view', () => {
|
module.hot.accept('./tiles', () => {
|
||||||
const it = views.values();
|
const it = views.values();
|
||||||
for (let value = it.next(); value.done !== true; value = it.next()) {
|
for (let value = it.next(); value.done !== true; value = it.next()) {
|
||||||
const {value: view} = value;
|
const {value: view} = value;
|
||||||
const {lastExtent} = view;
|
const {lastExtent} = view;
|
||||||
view.removeChild(view.entityListView);
|
view.removeChild(view.entityListView);
|
||||||
view.removeChild(view.tilesView);
|
view.removeChild(view.tilesRenderable);
|
||||||
view.tilesView = new TilesView(view.room.tiles, view.renderer);
|
view.tilesRenderable = new TilesRenderable(view.room.tiles, view.renderer);
|
||||||
view.renderChunksForExtent(lastExtent);
|
view.renderChunksForExtent(lastExtent);
|
||||||
view.addChild(view.tilesView);
|
view.addChild(view.tilesRenderable);
|
||||||
view.addChild(view.entityListView);
|
view.addChild(view.entityListView);
|
||||||
}
|
}
|
||||||
});
|
});
|
|
@ -3,6 +3,8 @@ import {JsonResource} from '@avocado/resource';
|
||||||
import {Synchronized} from '@avocado/s13n';
|
import {Synchronized} from '@avocado/s13n';
|
||||||
import {compose, EventEmitter} from '@latus/core';
|
import {compose, EventEmitter} from '@latus/core';
|
||||||
|
|
||||||
|
import RoomRenderable from '../renderable/room';
|
||||||
|
|
||||||
let s13nId = 1;
|
let s13nId = 1;
|
||||||
|
|
||||||
export default (latus) => {
|
export default (latus) => {
|
||||||
|
@ -17,6 +19,8 @@ export default (latus) => {
|
||||||
|
|
||||||
entityList;
|
entityList;
|
||||||
|
|
||||||
|
static Renderable = RoomRenderable;
|
||||||
|
|
||||||
tiles = [];
|
tiles = [];
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user