Separated anatomy from org / made species tracker
This commit is contained in:
@@ -4,7 +4,6 @@ const GridMap = require('../Grid/GridMap');
|
||||
const Renderer = require('../Rendering/Renderer');
|
||||
const CellStates = require('../Organism/Cell/CellStates');
|
||||
const EditorController = require("../Controllers/EditorController");
|
||||
const Directions = require('../Organism/Directions');
|
||||
|
||||
class OrganismEditor extends Environment{
|
||||
constructor() {
|
||||
@@ -37,13 +36,13 @@ class OrganismEditor extends Environment{
|
||||
var center = this.grid_map.getCenter();
|
||||
var loc_c = c - center[0];
|
||||
var loc_r = r - center[1];
|
||||
var prev_cell = this.organism.getLocalCell(loc_c, loc_r)
|
||||
var prev_cell = this.organism.anatomy.getLocalCell(loc_c, loc_r)
|
||||
if (prev_cell != null) {
|
||||
var new_cell = this.organism.replaceCell(state, prev_cell.loc_col, prev_cell.loc_row, false);
|
||||
var new_cell = this.organism.anatomy.replaceCell(state, prev_cell.loc_col, prev_cell.loc_row, false);
|
||||
this.changeCell(c, r, state, new_cell);
|
||||
}
|
||||
else if (this.organism.canAddCellAt(loc_c, loc_r)){
|
||||
this.changeCell(c, r, state, this.organism.addDefaultCell(state, loc_c, loc_r));
|
||||
else if (this.organism.anatomy.canAddCellAt(loc_c, loc_r)){
|
||||
this.changeCell(c, r, state, this.organism.anatomy.addDefaultCell(state, loc_c, loc_r));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -55,9 +54,9 @@ class OrganismEditor extends Environment{
|
||||
alert("Cannot remove center cell");
|
||||
return;
|
||||
}
|
||||
var prev_cell = this.organism.getLocalCell(loc_c, loc_r)
|
||||
var prev_cell = this.organism.anatomy.getLocalCell(loc_c, loc_r)
|
||||
if (prev_cell != null) {
|
||||
if (this.organism.removeCell(loc_c, loc_r)) {
|
||||
if (this.organism.anatomy.removeCell(loc_c, loc_r)) {
|
||||
this.changeCell(c, r, CellStates.empty, null);
|
||||
}
|
||||
}
|
||||
@@ -80,7 +79,7 @@ class OrganismEditor extends Environment{
|
||||
this.grid_map.fillGrid(CellStates.empty);
|
||||
var center = this.grid_map.getCenter();
|
||||
this.organism = new Organism(center[0], center[1], this, null);
|
||||
this.organism.addDefaultCell(CellStates.mouth, 0, 0);
|
||||
this.organism.anatomy.addDefaultCell(CellStates.mouth, 0, 0);
|
||||
this.organism.updateGrid();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user