MCPcopy Create free account
hub / github.com/Phobos-developers/Phobos / AllowUpgradeAnim

Function AllowUpgradeAnim

src/Ext/BuildingType/Hooks.Upgrade.cpp:239–261  ·  view source on GitHub ↗

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.

Source from the content-addressed store, hash-verified

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.
239static __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
263DEFINE_HOOK(0x45189D, BuildingClass_AnimUpdate_Upgrades, 0x6)
264{

Callers 1

Hooks.Upgrade.cppFile · 0.85

Calls 1

FindMethod · 0.45

Tested by

no test coverage detected