Position for items and units to be located on
| 37 | |
| 38 | // Position for items and units to be located on |
| 39 | Vec3<float> Tile::getRestingPosition(bool large, bool overlay) |
| 40 | { |
| 41 | if (large) |
| 42 | { |
| 43 | if (position.x < 1 || position.y < 1) |
| 44 | { |
| 45 | LogError( |
| 46 | "Trying to get resting position for a large unit when it can't fit! %d, %d, %d", |
| 47 | position.x, position.y, position.z); |
| 48 | return Vec3<float>{position.x + 0.5, position.y + 0.5, position.z}; |
| 49 | } |
| 50 | float maxHeight = overlay ? overlayHeight : height; |
| 51 | if (overlay) |
| 52 | { |
| 53 | maxHeight = std::max( |
| 54 | maxHeight, map.getTile(position.x - 1, position.y, position.z)->overlayHeight); |
| 55 | maxHeight = std::max( |
| 56 | maxHeight, map.getTile(position.x, position.y - 1, position.z)->overlayHeight); |
| 57 | maxHeight = std::max( |
| 58 | maxHeight, map.getTile(position.x - 1, position.y - 1, position.z)->overlayHeight); |
| 59 | } |
| 60 | else |
| 61 | { |
| 62 | maxHeight = |
| 63 | std::max(maxHeight, map.getTile(position.x - 1, position.y, position.z)->height); |
| 64 | maxHeight = |
| 65 | std::max(maxHeight, map.getTile(position.x, position.y - 1, position.z)->height); |
| 66 | maxHeight = std::max(maxHeight, |
| 67 | map.getTile(position.x - 1, position.y - 1, position.z)->height); |
| 68 | } |
| 69 | |
| 70 | return Vec3<float>{position.x, position.y, position.z + maxHeight}; |
| 71 | } |
| 72 | return Vec3<float>{position.x + 0.5f, position.y + 0.5f, |
| 73 | position.z + (overlay ? overlayHeight : height)}; |
| 74 | } |
| 75 | |
| 76 | sp<BattleMapPart> Tile::getItemSupportingObject() { return supportProviderForItems; } |
| 77 |
no test coverage detected