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

Function updateIndustryAnimation2

src/OpenLoco/src/Map/IndustryElement.cpp:291–363  ·  view source on GitHub ↗

0x00456EEB

Source from the content-addressed store, hash-verified

289
290 // 0x00456EEB
291 bool updateIndustryAnimation2(const Animation& anim)
292 {
293 auto tile = TileManager::get(anim.pos);
294 for (auto& el : tile)
295 {
296 auto* elIndustry = el.as<IndustryElement>();
297 if (elIndustry == nullptr)
298 {
299 continue;
300 }
301 if (elIndustry->baseZ() != anim.baseZ)
302 {
303 continue;
304 }
305 if (!(elIndustry->var_6_003F() & (1 << 5)))
306 {
307 continue;
308 }
309
310 auto* industry = elIndustry->industry();
311 const auto* indObj = industry->getObject();
312 const auto type = elIndustry->buildingType();
313 const auto buildingParts = indObj->getBuildingParts(type);
314 const auto buildingPartAnims = indObj->getBuildingPartAnimations();
315 // Guaranteed power of 2
316 auto animLength = indObj->getAnimationSequence(elIndustry->var_6_003F() & 0x3).size();
317 const auto isMultiTile = indObj->buildingSizeFlags & (1 << type);
318
319 for (auto& part : buildingParts)
320 {
321 auto& partAnim = buildingPartAnims[part];
322 if (partAnim.numFrames == 0)
323 {
324 const auto animSpeed = partAnim.animationSpeed & ~(1 << 7);
325 const auto speedMask = animLength - 1;
326 if (elIndustry->var_6_003F() & (1 << 4))
327 {
328 if ((speedMask & (ScenarioManager::getScenarioTicks() >> animSpeed)) == 0)
329 {
330 applyToMultiTile(*elIndustry, anim.pos, isMultiTile, [](World::IndustryElement& elIndustry, const World::Pos2& pos) {
331 Ui::ViewportManager::invalidate(pos, elIndustry.baseHeight(), elIndustry.clearHeight(), ZoomLevel::quarter);
332 elIndustry.setVar_6_003F(elIndustry.var_6_003F() & ~(1 << 5));
333 });
334 return true;
335 }
336 else
337 {
338 const auto speedMask2 = (1 << animSpeed) - 1;
339 if (!(speedMask2 & ScenarioManager::getScenarioTicks()))
340 {
341 applyToMultiTile(*elIndustry, anim.pos, isMultiTile, [](World::IndustryElement& elIndustry, const World::Pos2& pos) {
342 Ui::ViewportManager::invalidate(pos, elIndustry.baseHeight(), elIndustry.clearHeight(), ZoomLevel::quarter);
343 });
344 }
345 return false;
346 }
347 }
348 else

Callers 1

callUpdateFunctionFunction · 0.85

Calls 15

getScenarioTicksFunction · 0.85
baseZMethod · 0.80
var_6_003FMethod · 0.80
industryMethod · 0.80
getAnimationSequenceMethod · 0.80
baseHeightMethod · 0.80
clearHeightMethod · 0.80
setVar_6_003FMethod · 0.80
getFunction · 0.70
applyToMultiTileFunction · 0.70
invalidateFunction · 0.50
getObjectMethod · 0.45

Tested by

no test coverage detected