Initialize direction when placing actor tiles in the editor

This commit is contained in:
Eevee (Evelyn Woods) committed 2020-11-23 22:18:40 -07:00
1 parent ca4eaa86cb
commit fb301b3b3e
3 files changed
+10 -4

No files matched your search

+3 -1
View File
@@ -4,7 +4,9 @@ import TILE_TYPES from './tiletypes.js';
export class Tile {
constructor(type, direction = 'south') {
this.type = type;
this.direction = direction;
if (type.is_actor) {
this.direction = direction;
}
this.cell = null;
if (type.is_actor) {
+6 -2
View File
@@ -772,6 +772,10 @@ export class Editor extends PrimaryView {
return;
let type = TILE_TYPES[name];
let direction;
if (type.is_actor) {
direction = 'south';
}
let cell = this.stored_level.cells[y][x];
// For terrain tiles, erase the whole cell. For other tiles, only
// replace whatever's on the same layer
@@ -779,7 +783,7 @@ export class Editor extends PrimaryView {
// combine e.g. the tent with thin walls
if (type.draw_layer === 0) {
cell.length = 0;
cell.push({type});
cell.push({type, direction});
}
else {
for (let i = cell.length - 1; i >= 0; i--) {
@@ -787,7 +791,7 @@ export class Editor extends PrimaryView {
cell.splice(i, 1);
}
}
cell.push({type});
cell.push({type, direction});
cell.sort((a, b) => a.type.draw_layer - b.type.draw_layer);
}
}
+1 -1
View File
@@ -1428,7 +1428,7 @@ class Splash extends PrimaryView {
cell.push({type: TILE_TYPES['floor']});
stored_level.linear_cells.push(cell);
}
stored_level.linear_cells[0].push({type: TILE_TYPES['player']});
stored_level.linear_cells[0].push({type: TILE_TYPES['player'], direction: 'south'});
// FIXME definitely gonna need a name here chief
let stored_game = new format_base.StoredGame(null);