Don't allow upgrade anims to be created if building is not upgraded or they require power to be shown and the building isn't powered.
| 237 | |
| 238 | // Don't allow upgrade anims to be created if building is not upgraded or they require power to be shown and the building isn't powered. |
| 239 | static __forceinline bool AllowUpgradeAnim(BuildingClass* pBuilding, BuildingAnimSlot anim) |
| 240 | { |
| 241 | auto const pType = pBuilding->Type; |
| 242 | |
| 243 | if (pType->Upgrades != 0 && anim >= BuildingAnimSlot::Upgrade1 && anim <= BuildingAnimSlot::Upgrade3 && !pBuilding->Anims[int(anim)]) |
| 244 | { |
| 245 | int animIndex = BuildingExt::ExtMap.Find(pBuilding)->PoweredUpToLevel - 1; |
| 246 | |
| 247 | if (animIndex < 0 || (int)anim != animIndex) |
| 248 | return false; |
| 249 | |
| 250 | auto const animData = pType->BuildingAnim[int(anim)]; |
| 251 | |
| 252 | if (((pType->Powered && pType->PowerDrain > 0 && (animData.PoweredLight || animData.PoweredEffect)) || |
| 253 | (pType->PoweredSpecial && animData.PoweredSpecial)) && |
| 254 | !(pBuilding->CurrentMission != Mission::Construction && pBuilding->CurrentMission != Mission::Selling && pBuilding->IsPowerOnline())) |
| 255 | { |
| 256 | return false; |
| 257 | } |
| 258 | } |
| 259 | |
| 260 | return true; |
| 261 | } |
| 262 | |
| 263 | DEFINE_HOOK(0x45189D, BuildingClass_AnimUpdate_Upgrades, 0x6) |
| 264 | { |