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

Method electricSpark1AnimationUpdate

src/OpenLoco/src/Vehicles/VehicleBody.cpp:1215–1257  ·  view source on GitHub ↗

0x004ABDAD & 0x004AB3CA

Source from the content-addressed store, hash-verified

1213
1214 // 0x004ABDAD & 0x004AB3CA
1215 void VehicleBody::electricSpark1AnimationUpdate(const Vehicle& train, const CarUpdateState& carState, const int32_t unkDistance, uint8_t num, int32_t emitterHorizontalPos)
1216 {
1217 VehicleBogie* frontBogie = carState.frontBogie;
1218 VehicleBogie* backBogie = carState.backBogie;
1219 if (frontBogie->hasBreakdownFlags(BreakdownFlags::brokenDown))
1220 {
1221 return;
1222 }
1223
1224 Vehicle2* veh_2 = train.veh2;
1225 const auto* vehicleObject = getObject();
1226
1227 if (veh_2->motorState != MotorState::coasting && veh_2->motorState != MotorState::accelerating)
1228 {
1229 return;
1230 }
1231
1232 auto _var_44 = var_44;
1233 if (has38Flags(Flags38::isReversed))
1234 {
1235 emitterHorizontalPos = -emitterHorizontalPos;
1236 _var_44 = -var_44;
1237 }
1238
1239 if (((uint16_t)unkDistance) + ((uint16_t)_var_44 * 8) < std::numeric_limits<uint16_t>::max())
1240 {
1241 return;
1242 }
1243
1244 emitterHorizontalPos += 64;
1245
1246 if (gPrng1().randNext(std::numeric_limits<uint16_t>::max()) > 819)
1247 {
1248 return;
1249 }
1250
1251 auto bogieDifference = backBogie->position - frontBogie->position;
1252 auto xyFactor = Math::Trigonometry::computeXYVector(vehicleObject->animation[num].emitterVerticalPos, spritePitch, spriteYaw);
1253
1254 auto loc = bogieDifference * emitterHorizontalPos / 128 + frontBogie->position + World::Pos3(xyFactor.x, xyFactor.y, vehicleObject->animation[num].emitterVerticalPos);
1255
1256 Exhaust::create(loc, vehicleObject->animation[num].objectId);
1257 }
1258
1259 // 0x004ABEC3 & 0x004AB4E0
1260 void VehicleBody::electricSpark2AnimationUpdate(const Vehicle& train, const CarUpdateState& carState, const int32_t unkDistance, uint8_t num, int32_t emitterHorizontalPos)

Callers

nothing calls this directly

Calls 4

computeXYVectorFunction · 0.85
createFunction · 0.50
hasBreakdownFlagsMethod · 0.45
randNextMethod · 0.45

Tested by

no test coverage detected