MCPcopy Create free account
hub / github.com/OpenLoco/OpenLoco / paintTileElementsSetup

Function paintTileElementsSetup

src/OpenLoco/src/Paint/PaintTile.cpp:221–254  ·  view source on GitHub ↗

Returns std::nullopt on no need to paint

Source from the content-addressed store, hash-verified

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 {

Callers 2

paintTileElementsFunction · 0.85
paintTileElements2Function · 0.85

Calls 13

gameToScreenFunction · 0.85
paintConstructionArrowFunction · 0.85
resetTunnelsMethod · 0.80
setUnkPositionMethod · 0.80
setMapPositionMethod · 0.80
setMaxHeightMethod · 0.80
getRenderTargetMethod · 0.80
getMaxHeightMethod · 0.80
setEntityPositionMethod · 0.80
resetTileColumnMethod · 0.80

Tested by

no test coverage detected