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

Function paintEntitiesWithFilter

src/OpenLoco/src/Paint/PaintEntity.cpp:18–77  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

16{
17 template<typename FilterType>
18 static void paintEntitiesWithFilter(PaintSession& session, const World::Pos2& loc, FilterType&& filter)
19 {
20 auto* rt = session.getRenderTarget();
21 if (Config::get().vehiclesMinScale < rt->zoomLevel)
22 {
23 return;
24 }
25
26 if (loc.x >= 0x4000 || loc.y >= 0x4000)
27 {
28 return;
29 }
30
31 EntityManager::EntityTileList entities(loc);
32 for (auto* entity : entities)
33 {
34 // TODO: Create a rect from context dims
35 auto left = rt->x;
36 auto top = rt->y;
37 auto right = left + rt->width;
38 auto bottom = top + rt->height;
39
40 // TODO: Create a rect from sprite dims and use a contains function
41 if (entity->spriteTop > bottom)
42 {
43 continue;
44 }
45 if (entity->spriteBottom <= top)
46 {
47 continue;
48 }
49 if (entity->spriteLeft > right)
50 {
51 continue;
52 }
53 if (entity->spriteRight <= left)
54 {
55 continue;
56 }
57 if (!filter(entity))
58 {
59 continue;
60 }
61 session.setCurrentItem(entity);
62 session.setEntityPosition(entity->position);
63 session.setItemType(InteractionItem::entity);
64 switch (entity->baseType)
65 {
66 case EntityBaseType::vehicle:
67 paintVehicleEntity(session, entity->asBase<Vehicles::VehicleBase>());
68 break;
69 case EntityBaseType::effect:
70 paintEffectEntity(session, entity->asBase<EffectEntity>());
71 break;
72 case EntityBaseType::null:
73 // Nothing to paint
74 break;
75 }

Callers 2

paintEntitiesFunction · 0.85
paintEntities2Function · 0.85

Calls 7

paintVehicleEntityFunction · 0.85
paintEffectEntityFunction · 0.85
getRenderTargetMethod · 0.80
setCurrentItemMethod · 0.80
setEntityPositionMethod · 0.80
setItemTypeMethod · 0.80
getFunction · 0.50

Tested by

no test coverage detected