| 99 | } |
| 100 | |
| 101 | void TileObjectShadow::setPosition(Vec3<float> newPosition) |
| 102 | { |
| 103 | static const std::set<TileObject::Type> mapPartSet = { |
| 104 | TileObject::Type::Ground, TileObject::Type::LeftWall, TileObject::Type::RightWall, |
| 105 | TileObject::Type::Feature, TileObject::Type::Scenery}; |
| 106 | |
| 107 | // This projects a line downwards and draws places the shadow at the z of the first thing hit |
| 108 | |
| 109 | auto shadowPosition = newPosition; |
| 110 | auto c = |
| 111 | map.findCollision(newPosition, Vec3<float>{newPosition.x, newPosition.y, -1}, mapPartSet); |
| 112 | if (c) |
| 113 | { |
| 114 | shadowPosition.z = c.position.z; |
| 115 | this->fellOffTheBottomOfTheMap = false; |
| 116 | } |
| 117 | else |
| 118 | { |
| 119 | shadowPosition.z = 0; |
| 120 | // Mark it as not to be drawn |
| 121 | this->fellOffTheBottomOfTheMap = true; |
| 122 | } |
| 123 | |
| 124 | this->shadowPosition = shadowPosition; |
| 125 | |
| 126 | auto unit = ownerBattleUnit.lock(); |
| 127 | if (unit) |
| 128 | { |
| 129 | setBounds({unit->tileObject->getBounds().x, unit->tileObject->getBounds().y, 0.0f}); |
| 130 | } |
| 131 | TileObject::setPosition(shadowPosition); |
| 132 | } |
| 133 | |
| 134 | TileObjectShadow::~TileObjectShadow() = default; |
| 135 |
nothing calls this directly
no test coverage detected