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

Function updateStationAnimation

src/OpenLoco/src/Map/StationElement.cpp:14–59  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

12{
13 template<typename Object>
14 bool updateStationAnimation(const Animation& anim, StationType stationType)
15 {
16 auto tile = TileManager::get(anim.pos);
17 for (auto& el : tile)
18 {
19 auto* elStation = el.as<StationElement>();
20 if (elStation == nullptr)
21 {
22 continue;
23 }
24 if (elStation->baseZ() != anim.baseZ)
25 {
26 continue;
27 }
28 if (elStation->stationType() != stationType)
29 {
30 continue;
31 }
32
33 const auto* obj = ObjectManager::get<Object>(elStation->objectId());
34 auto buildingParts = obj->getBuildingParts(elStation->buildingType());
35 const auto animations = obj->getBuildingPartAnimations();
36 bool hasAnimation = false;
37 uint8_t animSpeed = std::numeric_limits<uint8_t>::max();
38 for (auto& part : buildingParts)
39 {
40 auto& partAnim = animations[part];
41 if (partAnim.numFrames > 1)
42 {
43 hasAnimation = true;
44 animSpeed = std::min<uint8_t>(animSpeed, partAnim.animationSpeed & ~(1 << 7));
45 }
46 }
47 if (!hasAnimation)
48 {
49 return true;
50 }
51 const auto speedMask = ((1 << animSpeed) - 1);
52 if (!(ScenarioManager::getScenarioTicks() & speedMask))
53 {
54 Ui::ViewportManager::invalidate(anim.pos, el.baseHeight(), el.clearHeight(), ZoomLevel::quarter);
55 }
56 return false;
57 }
58 return true;
59 }
60
61 // 0x004944B6
62 bool updateDockStationAnimation(const Animation& anim)

Callers

nothing calls this directly

Calls 11

getScenarioTicksFunction · 0.85
baseZMethod · 0.80
stationTypeMethod · 0.80
baseHeightMethod · 0.80
clearHeightMethod · 0.80
getFunction · 0.70
invalidateFunction · 0.50
objectIdMethod · 0.45
getBuildingPartsMethod · 0.45
buildingTypeMethod · 0.45

Tested by

no test coverage detected