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

Method UpdateAttachEffects

src/Ext/Techno/Body.Update.cpp:1442–1518  ·  view source on GitHub ↗

Updates state of all AttachEffects on techno.

Source from the content-addressed store, hash-verified

1440
1441// Updates state of all AttachEffects on techno.
1442void TechnoExt::ExtData::UpdateAttachEffects()
1443{
1444 if (!this->AttachedEffects.size())
1445 return;
1446
1447 auto const pThis = this->OwnerObject();
1448 const bool inTunnel = this->IsInTunnel || this->IsBurrowed;
1449 bool markForRedraw = false;
1450 bool altered = false;
1451 std::vector<std::unique_ptr<AttachEffectClass>>::iterator it;
1452 std::vector<WeaponTypeClass*> expireWeapons;
1453
1454 for (it = this->AttachedEffects.begin(); it != this->AttachedEffects.end(); )
1455 {
1456 auto const attachEffect = it->get();
1457
1458 if (!inTunnel)
1459 attachEffect->SetAnimationTunnelState(true);
1460
1461 attachEffect->AI();
1462
1463 if (attachEffect->NeedsRecalculateStat)
1464 {
1465 altered = true;
1466 attachEffect->NeedsRecalculateStat = false;
1467 }
1468
1469 const bool hasExpired = attachEffect->HasExpired();
1470 const bool shouldDiscard = attachEffect->IsActiveIgnorePowered() && attachEffect->ShouldBeDiscardedNow();
1471
1472 if (hasExpired || shouldDiscard)
1473 {
1474 auto const pType = attachEffect->GetType();
1475 attachEffect->ShouldBeDiscarded = false;
1476
1477 if (pType->HasTint())
1478 markForRedraw = true;
1479
1480 if (pType->Cumulative && pType->CumulativeAnimations.size() > 0)
1481 this->UpdateCumulativeAttachEffects(attachEffect->GetType(), attachEffect);
1482
1483 if (pType->ExpireWeapon && ((hasExpired && (pType->ExpireWeapon_TriggerOn & ExpireWeaponCondition::Expire) != ExpireWeaponCondition::None)
1484 || (shouldDiscard && (pType->ExpireWeapon_TriggerOn & ExpireWeaponCondition::Discard) != ExpireWeaponCondition::None)))
1485 {
1486 if (!pType->Cumulative || !pType->ExpireWeapon_CumulativeOnlyOnce || this->GetAttachedEffectCumulativeCount(pType) < 1)
1487 expireWeapons.push_back(pType->ExpireWeapon);
1488 }
1489
1490 if (shouldDiscard && attachEffect->ResetIfRecreatable())
1491 {
1492 ++it;
1493 continue;
1494 }
1495
1496 it = this->AttachedEffects.erase(it);
1497 altered = true;
1498 }
1499 else

Callers 1

OnEarlyUpdateMethod · 0.95

Calls 15

HasExpiredMethod · 0.80
IsActiveIgnorePoweredMethod · 0.80
ShouldBeDiscardedNowMethod · 0.80
ResetIfRecreatableMethod · 0.80
eraseMethod · 0.80
sizeMethod · 0.45
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected