| 65 | } |
| 66 | |
| 67 | void TileObjectProjectile::addToDrawnTiles(Tile *) |
| 68 | { |
| 69 | auto p = this->projectile.lock(); |
| 70 | if (!p) |
| 71 | { |
| 72 | LogError("Called with no owning projectile object"); |
| 73 | return; |
| 74 | } |
| 75 | Vec3<float> maxCoords = {-1, -1, -1}; |
| 76 | for (auto &pos : p->spritePositions) |
| 77 | { |
| 78 | |
| 79 | // Projectiles are drawn in the tile that contains their point that is closest to camera |
| 80 | if (maxCoords.z * 1000 + maxCoords.x + maxCoords.y < pos.z * 1000 + pos.x + pos.y) |
| 81 | { |
| 82 | maxCoords = {pos.x, pos.y, pos.z}; |
| 83 | } |
| 84 | } |
| 85 | TileObject::addToDrawnTiles(map.getTile(maxCoords)); |
| 86 | } |
| 87 | |
| 88 | sp<Projectile> TileObjectProjectile::getProjectile() const { return projectile.lock(); } |
| 89 | |