diff options
author | Loek Le Blansch <loek@pipeframe.xyz> | 2024-10-23 19:16:19 +0200 |
---|---|---|
committer | Loek Le Blansch <loek@pipeframe.xyz> | 2024-10-23 19:16:19 +0200 |
commit | 1e0a52b03fe655d7073ef20703dbb2e7646f74d3 (patch) | |
tree | f1709c2e9565d78c791653e71e6a4b26b3138423 /SetNeighborTileBehavior.cpp | |
parent | 277157b3e06b2deeacbdbc8bf6190de19f88169d (diff) |
add XY struct for 2d points and offsets
Diffstat (limited to 'SetNeighborTileBehavior.cpp')
-rw-r--r-- | SetNeighborTileBehavior.cpp | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/SetNeighborTileBehavior.cpp b/SetNeighborTileBehavior.cpp index 7b7ede7..0314e42 100644 --- a/SetNeighborTileBehavior.cpp +++ b/SetNeighborTileBehavior.cpp @@ -8,16 +8,16 @@ using namespace std; void SetNeighborTileBehavior::step(Artist * artist) { this->interactions++; - if (dx != 0 || dy != 0) return; + if (this->offset.x != 0 || this->offset.y != 0) return; if (artist == nullptr) return; - if (artist->data.vx == 0) dx = 1; - if (artist->data.vy == 0) dy = 1; + if (artist->data.vx == 0) this->offset.x = 1; + if (artist->data.vy == 0) this->offset.y = 1; } -static void update_neighbor(Tile & here, int dx, int dy) { - if (dx == 0 && dy == 0) return; - Tile * neighbor = here.get_neighbor(dx, dy); +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; @@ -28,8 +28,8 @@ static void update_neighbor(Tile & here, int dx, int dy) { void SetNeighborTileBehavior::update(Tile & tile) { if (this->interactions < 1) return; - update_neighbor(tile, this->dx, this->dy); - update_neighbor(tile, -this->dx, -this->dy); + update_neighbor(tile, this->offset); + update_neighbor(tile, -this->offset); tile.set_type(CreateArtistTileBehavior::type); } |