#include "SetNeighborTileBehavior.h" #include "CreateArtistTileBehavior.h" #include "Artist.h" #include "DeleteArtistTileBehavior.h" #include "Tile.h" using namespace std; void SetNeighborTileBehavior::step(Artist * artist) { this->interactions++; if (this->offset.x != 0 || this->offset.y != 0) return; if (artist == nullptr) return; if (artist->data.vx == 0) this->offset.x = 1; if (artist->data.vy == 0) this->offset.y = 1; } static void update_neighbor(Tile & here, const XY & offset) { if (offset.x == 0 && offset.y == 0) return; Tile * neighbor = here.get_neighbor(offset); if (neighbor == &here) return; if (neighbor == nullptr) return; neighbor->set_type(SetNeighborTileBehavior::type); // neighbor->set_type(DeleteArtistTileBehavior::type); } void SetNeighborTileBehavior::update(Tile & tile) { if (this->interactions < 1) return; update_neighbor(tile, this->offset); update_neighbor(tile, -this->offset); tile.set_type(CreateArtistTileBehavior::type); }