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

Method dieselExhaust2AnimationUpdate

src/OpenLoco/src/Vehicles/VehicleBody.cpp:1159–1212  ·  view source on GitHub ↗

0x004ABB5A & 0x004AB177

Source from the content-addressed store, hash-verified

1157
1158 // 0x004ABB5A & 0x004AB177
1159 void VehicleBody::dieselExhaust2AnimationUpdate(const Vehicle& train, const CarUpdateState& carState, uint8_t num, int32_t emitterHorizontalPos)
1160 {
1161 VehicleBogie* frontBogie = carState.frontBogie;
1162 VehicleBogie* backBogie = carState.backBogie;
1163 if (frontBogie->hasBreakdownFlags(BreakdownFlags::brokenDown))
1164 {
1165 return;
1166 }
1167
1168 Vehicle2* veh_2 = train.veh2;
1169 const auto* vehicleObject = getObject();
1170
1171 if (veh_2->motorState != MotorState::accelerating)
1172 {
1173 return;
1174 }
1175
1176 if (veh_2->currentSpeed > 14.0_mph)
1177 {
1178 return;
1179 }
1180
1181 if (has38Flags(Flags38::isReversed))
1182 {
1183 emitterHorizontalPos = -emitterHorizontalPos;
1184 }
1185
1186 if (ScenarioManager::getScenarioTicks() & 7)
1187 {
1188 return;
1189 }
1190
1191 emitterHorizontalPos += 64;
1192
1193 auto bogieDifference = backBogie->position - frontBogie->position;
1194 auto xyFactor = Math::Trigonometry::computeXYVector(vehicleObject->animation[num].emitterVerticalPos, spritePitch, spriteYaw);
1195
1196 auto loc = bogieDifference * emitterHorizontalPos / 128 + frontBogie->position + World::Pos3(xyFactor.x, xyFactor.y, vehicleObject->animation[num].emitterVerticalPos);
1197
1198 // 90 degrees C.W.
1199 auto yaw = (spriteYaw + 16) & 0x3F;
1200
1201 auto unkFactor = 5;
1202 if (getGameState().trafficHandedness != 0)
1203 {
1204 unkFactor = -5;
1205 }
1206
1207 xyFactor = Math::Trigonometry::computeXYVector(unkFactor, yaw);
1208 loc.x += xyFactor.x;
1209 loc.y += xyFactor.y;
1210
1211 Exhaust::create(loc, vehicleObject->animation[num].objectId);
1212 }
1213
1214 // 0x004ABDAD & 0x004AB3CA
1215 void VehicleBody::electricSpark1AnimationUpdate(const Vehicle& train, const CarUpdateState& carState, const int32_t unkDistance, uint8_t num, int32_t emitterHorizontalPos)

Callers

nothing calls this directly

Calls 4

getScenarioTicksFunction · 0.85
computeXYVectorFunction · 0.85
createFunction · 0.50
hasBreakdownFlagsMethod · 0.45

Tested by

no test coverage detected