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

Method steamPuffsAnimationUpdate

src/OpenLoco/src/Vehicles/VehicleBody.cpp:927–1086  ·  view source on GitHub ↗

0x004AB688, 0x004AACA5

Source from the content-addressed store, hash-verified

925
926 // 0x004AB688, 0x004AACA5
927 void VehicleBody::steamPuffsAnimationUpdate(const Vehicle& train, const CarUpdateState& carState, const int32_t unkDistance, uint8_t num, int32_t emitterHorizontalPos)
928 {
929 const auto* vehicleObject = getObject();
930 VehicleBogie* frontBogie = carState.frontBogie;
931 VehicleBogie* backBogie = carState.backBogie;
932 if (frontBogie->hasBreakdownFlags(BreakdownFlags::brokenDown))
933 {
934 return;
935 }
936
937 Vehicle2* veh_2 = train.veh2;
938 bool soundCode = false;
939 if (veh_2->motorState == MotorState::accelerating || veh_2->motorState == MotorState::stoppedOnIncline)
940 {
941 soundCode = true;
942 }
943 bool tickCalc = true;
944 if (veh_2->motorState != MotorState::stopped && veh_2->currentSpeed >= 1.0_mph)
945 {
946 tickCalc = false;
947 }
948
949 auto _var_44 = var_44;
950 // Reversing
951 if (has38Flags(Flags38::isReversed))
952 {
953 emitterHorizontalPos = -emitterHorizontalPos;
954 _var_44 = -_var_44;
955 }
956
957 if (tickCalc && (soundCode == false))
958 {
959 if (ScenarioManager::getScenarioTicks() & 7)
960 {
961 return;
962 }
963 }
964 else
965 {
966 if (unkDistance + (uint16_t)(_var_44 * 8) < std::numeric_limits<uint16_t>::max())
967 {
968 return;
969 }
970 }
971
972 emitterHorizontalPos += 64;
973
974 auto xyFactor = Math::Trigonometry::computeXYVector(vehicleObject->animation[num].emitterVerticalPos, spritePitch, spriteYaw);
975
976 auto bogieDifference = backBogie->position - frontBogie->position;
977
978 auto smokeLoc = bogieDifference * emitterHorizontalPos / 128 + frontBogie->position + World::Pos3(xyFactor.x, xyFactor.y, vehicleObject->animation[num].emitterVerticalPos);
979
980 Exhaust::create(smokeLoc, vehicleObject->animation[num].objectId | (soundCode ? 0 : 0x80));
981 if (soundCode == false)
982 {
983 return;
984 }

Callers

nothing calls this directly

Calls 15

getScenarioTicksFunction · 0.85
computeXYVectorFunction · 0.85
getHeightFunction · 0.85
playSoundFunction · 0.85
makeObjectSoundIdFunction · 0.85
isAiAllocatedMethod · 0.80
baseZMethod · 0.80
trackIdMethod · 0.80
createFunction · 0.50
getFunction · 0.50
hasBreakdownFlagsMethod · 0.45
hasFlagsMethod · 0.45

Tested by

no test coverage detected