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

Method dieselExhaust1AnimationUpdate

src/OpenLoco/src/Vehicles/VehicleBody.cpp:1089–1156  ·  view source on GitHub ↗

0x004AB9DD & 0x004AAFFA

Source from the content-addressed store, hash-verified

1087
1088 // 0x004AB9DD & 0x004AAFFA
1089 void VehicleBody::dieselExhaust1AnimationUpdate(const Vehicle& train, const CarUpdateState& carState, uint8_t num, int32_t emitterHorizontalPos)
1090 {
1091 VehicleBogie* frontBogie = carState.frontBogie;
1092 VehicleBogie* backBogie = carState.backBogie;
1093 if (frontBogie->hasBreakdownFlags(BreakdownFlags::brokenDown))
1094 {
1095 return;
1096 }
1097
1098 VehicleHead* headVeh = train.head;
1099 Vehicle2* veh_2 = train.veh2;
1100 const auto* vehicleObject = getObject();
1101
1102 if (headVeh->vehicleType == VehicleType::ship)
1103 {
1104 if (veh_2->currentSpeed == 0.0_mph)
1105 {
1106 return;
1107 }
1108
1109 if (has38Flags(Flags38::isReversed))
1110 {
1111 emitterHorizontalPos = -emitterHorizontalPos;
1112 }
1113
1114 if (ScenarioManager::getScenarioTicks() & 3)
1115 {
1116 return;
1117 }
1118
1119 auto positionFactor = vehicleObject->bodySprites[0].halfLength * emitterHorizontalPos / 256;
1120 auto invertedDirection = spriteYaw ^ (1 << 5);
1121 auto xyFactor = Math::Trigonometry::computeXYVector(positionFactor, invertedDirection) / 2;
1122
1123 World::Pos3 loc = position + World::Pos3(xyFactor.x, xyFactor.y, vehicleObject->animation[num].emitterVerticalPos);
1124 Exhaust::create(loc, vehicleObject->animation[num].objectId);
1125 }
1126 else
1127 {
1128 if (veh_2->motorState != MotorState::accelerating)
1129 {
1130 return;
1131 }
1132
1133 if (has38Flags(Flags38::isReversed))
1134 {
1135 emitterHorizontalPos = -emitterHorizontalPos;
1136 }
1137
1138 if (ScenarioManager::getScenarioTicks() & 3)
1139 {
1140 return;
1141 }
1142
1143 if (wheelSlipping != 0)
1144 {
1145 return;
1146 }

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