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

Method update

src/OpenLoco/src/Effects/ExhaustEffect.cpp:19–117  ·  view source on GitHub ↗

0x004408C2

Source from the content-addressed store, hash-verified

17
18 // 0x004408C2
19 void Exhaust::update()
20 {
21 const auto* steamObj = getObject();
22 if (steamObj->hasFlags(SteamObjectFlags::applyWind))
23 {
24 // Wind is applied by applying a slight modification (~1 in 10 ticks a pixel change) to the x component of the exhaust
25 const auto res = windProgress + 7000;
26 windProgress = static_cast<uint16_t>(res);
27 auto newPos = position;
28 newPos.x += res / (std::numeric_limits<uint16_t>::max() + 1);
29 if (newPos.x != position.x)
30 {
31 moveTo(newPos);
32 }
33 }
34 stationaryProgress++;
35 if (stationaryProgress < steamObj->numStationaryTicks)
36 {
37 return;
38 }
39 stationaryProgress = 0;
40 frameNum++;
41
42 auto [totalNumFrames, frameInfo] = steamObj->getFramesInfo(isSubObjType1());
43
44 if (frameNum >= totalNumFrames)
45 {
46 EntityManager::freeEntity(this);
47 return;
48 }
49
50 auto newPos = position;
51 newPos.z += frameInfo[frameNum].height;
52 moveTo(newPos);
53
54 if (!steamObj->hasFlags(SteamObjectFlags::disperseOnCollision))
55 {
56 return;
57 }
58
59 const auto tile = World::TileManager::get(position);
60 const auto lowZ = (position.z / World::kSmallZStep) - 3;
61 const auto highZ = lowZ + 6;
62 for (const auto& el : tile)
63 {
64 if (el.isAiAllocated() || el.isGhost())
65 {
66 continue;
67 }
68 if (lowZ < el.baseZ() && highZ > el.baseZ())
69 {
70 EntityManager::freeEntity(this);
71 return;
72 }
73
74 auto* elTrack = el.as<World::TrackElement>();
75 if (elTrack == nullptr)
76 {

Callers

nothing calls this directly

Calls 11

freeEntityFunction · 0.85
getFramesInfoMethod · 0.80
isAiAllocatedMethod · 0.80
baseZMethod · 0.80
getFunction · 0.50
hasFlagsMethod · 0.45
isGhostMethod · 0.45
hasStationElementMethod · 0.45
nextMethod · 0.45
objectIdMethod · 0.45
sequenceIndexMethod · 0.45

Tested by

no test coverage detected