summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2016-01-07 20:19:34 +0100
committerMatthias Schiffer <mschiffer@universe-factory.net>2016-01-07 20:19:34 +0100
commita09b58b54c19673d3b699b069d0c7683053e27d3 (patch)
treed0360ebae6ffd5adaf780684ad428b5c519b154e
parentf569eb788f0ac0f5d10e2b83e2f7f3c9cd0b2d68 (diff)
downloadrpgedit-a09b58b54c19673d3b699b069d0c7683053e27d3.tar
rpgedit-a09b58b54c19673d3b699b069d0c7683053e27d3.zip
Simplify entity list
-rw-r--r--src/control/MapContext.ts4
-rw-r--r--src/model/Position.ts4
-rw-r--r--src/view/MapView.ts10
3 files changed, 5 insertions, 13 deletions
diff --git a/src/control/MapContext.ts b/src/control/MapContext.ts
index ce82c5a..48e8b9e 100644
--- a/src/control/MapContext.ts
+++ b/src/control/MapContext.ts
@@ -15,7 +15,7 @@ import MapView from '../view/MapView';
export default class MapContext {
view: MapView;
- entities: {[key: string]: EntityPosition} = {};
+ entities: EntityPosition[] = [];
playerEntity: EntityPosition;
@@ -42,7 +42,7 @@ export default class MapContext {
}
private addEntity(entity: EntityPosition) {
- this.entities[entity.position.asString()] = entity;
+ this.entities.push(entity);
}
private addTransition(entity: EntityPosition, dest: Position, start: number, dur: number) {
diff --git a/src/model/Position.ts b/src/model/Position.ts
index 1f9b719..ebb3820 100644
--- a/src/model/Position.ts
+++ b/src/model/Position.ts
@@ -29,8 +29,4 @@ export default class Position {
return p;
}
-
- asString(): string {
- return `${this.x},${this.y}`;
- }
}
diff --git a/src/view/MapView.ts b/src/view/MapView.ts
index 5523f81..230ecf3 100644
--- a/src/view/MapView.ts
+++ b/src/view/MapView.ts
@@ -75,7 +75,7 @@ export default class MapView {
private entitySprites: {[key: string]: HTMLImageElement};
constructor(private map: MapData,
- private entities: {[key: string]: EntityPosition},
+ private entities: EntityPosition[],
private origin: EntityPosition,
private updateState: (time: number) => void) {
this.canvas = document.createElement('canvas');
@@ -91,7 +91,7 @@ export default class MapView {
this.tiles = tiles;
});
- var entitiesReady = loadEntities(this.getEntities()).then((entities) => {
+ var entitiesReady = loadEntities(this.entities).then((entities) => {
this.entitySprites = entities;
});
@@ -100,10 +100,6 @@ export default class MapView {
});
}
- private getEntities(): EntityPosition[] {
- return _.values<EntityPosition>(this.entities);
- }
-
private setSize() {
var e = document.documentElement;
var w = window.innerWidth || e.clientWidth || body.clientWidth;
@@ -197,7 +193,7 @@ export default class MapView {
var animate = false;
- this.getEntities().forEach(e => {
+ this.entities.forEach(e => {
if (this.drawEntity(e, time))
animate = true;
});