diff options
Diffstat (limited to 'Tile.cpp')
-rw-r--r-- | Tile.cpp | 17 |
1 files changed, 10 insertions, 7 deletions
@@ -4,18 +4,21 @@ #include "TileAppearance.h" #include "TileBehavior.h" -Tile::Tile() { - this->data = {}; - this->update(); +Tile::Tile(Museum & museum, TileData data) : museum(museum) { + this->set_data(data); } -Tile::Tile(TileData data) { +void Tile::set_data(TileData data) { this->data = data; - this->update(); + this->color = TileAppearance::get_color(this->data.type); + this->behavior = TileBehavior::get_strategy(this->data.type).clone(this->museum); } void Tile::update() { - this->color = TileAppearance::get_color(this->data.type); - this->behavior = TileBehavior::get_strategy(this->data.type).clone(); + this->behavior->update(*this); +} + +void Tile::step() { + this->behavior->step(); } |