Returns std::nullopt on no need to paint
| 219 | |
| 220 | // Returns std::nullopt on no need to paint |
| 221 | static std::optional<Ui::viewport_pos> paintTileElementsSetup(PaintSession& session, const World::Pos2& loc) |
| 222 | { |
| 223 | session.setSegmentsSupportHeight(SegmentFlags::all, std::numeric_limits<uint16_t>::max(), 0); |
| 224 | session.setGeneralSupportHeight(std::numeric_limits<uint16_t>::max(), 0); |
| 225 | session.resetTunnels(); |
| 226 | session.setUnkPosition(loc); |
| 227 | session.setMapPosition(loc); |
| 228 | |
| 229 | session.setMaxHeight(loc); |
| 230 | |
| 231 | constexpr World::Pos2 kUnkOffsets[4] = { |
| 232 | { 0, 0 }, |
| 233 | { 32, 0 }, |
| 234 | { 32, 32 }, |
| 235 | { 0, 32 }, |
| 236 | }; |
| 237 | |
| 238 | const auto loc2 = loc + kUnkOffsets[session.getRotation()]; |
| 239 | const auto vpPos = World::gameToScreen(World::Pos3(loc2.x, loc2.y, 0), session.getRotation()); |
| 240 | paintConstructionArrow(session, loc2); |
| 241 | |
| 242 | if (vpPos.y + 52 <= session.getRenderTarget()->y) |
| 243 | { |
| 244 | return std::nullopt; |
| 245 | } |
| 246 | if (vpPos.y - session.getMaxHeight() > session.getRenderTarget()->y + session.getRenderTarget()->height) |
| 247 | { |
| 248 | return std::nullopt; |
| 249 | } |
| 250 | |
| 251 | session.setEntityPosition(loc2); |
| 252 | session.resetTileColumn({ vpPos.x, vpPos.y }); |
| 253 | return { vpPos }; |
| 254 | } |
| 255 | |
| 256 | static void paintTileElementsEndLoop(PaintSession& session, const World::TileElement& el) |
| 257 | { |
no test coverage detected