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

Method UpdateTintValues

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

Recalculates tint values.

Source from the content-addressed store, hash-verified

1679
1680// Recalculates tint values.
1681void TechnoExt::ExtData::UpdateTintValues()
1682{
1683 // reset values
1684 this->TintColorOwner = 0;
1685 this->TintColorAllies = 0;
1686 this->TintColorEnemies = 0;
1687 this->TintIntensityOwner = 0;
1688 this->TintIntensityAllies = 0;
1689 this->TintIntensityEnemies = 0;
1690
1691 auto const pTypeExt = this->TypeExtData;
1692 const bool hasTechnoTint = pTypeExt->Tint_Color.isset() || pTypeExt->Tint_Intensity;
1693 const bool hasShieldTint = this->Shield && this->Shield->IsActive() && this->Shield->GetType()->HasTint();
1694
1695 // bail out early if no custom tint is applied.
1696 if (!hasTechnoTint && !this->AE.HasTint && !hasShieldTint)
1697 return;
1698
1699 auto calculateTint = [this](const int color, const int intensity, const AffectedHouse affectedHouse)
1700 {
1701 if ((affectedHouse & AffectedHouse::Owner) != AffectedHouse::None)
1702 {
1703 this->TintColorOwner |= color;
1704 this->TintIntensityOwner += intensity;
1705 }
1706
1707 if ((affectedHouse & AffectedHouse::Allies) != AffectedHouse::None)
1708 {
1709 this->TintColorAllies |= color;
1710 this->TintIntensityAllies += intensity;
1711 }
1712
1713 if ((affectedHouse & AffectedHouse::Enemies) != AffectedHouse::None)
1714 {
1715 this->TintColorEnemies |= color;
1716 this->TintIntensityEnemies += intensity;
1717 }
1718 };
1719
1720 if (hasTechnoTint)
1721 calculateTint(Drawing::RGB_To_Int(pTypeExt->Tint_Color), static_cast<int>(pTypeExt->Tint_Intensity * 1000), pTypeExt->Tint_VisibleToHouses);
1722
1723 if (this->AE.HasTint)
1724 {
1725 for (auto const& attachEffect : this->AttachedEffects)
1726 {
1727 auto const type = attachEffect->GetType();
1728
1729 if (!attachEffect->IsActive() || !type->HasTint())
1730 continue;
1731
1732 calculateTint(Drawing::RGB_To_Int(type->Tint_Color), static_cast<int>(type->Tint_Intensity * 1000), type->Tint_VisibleToHouses);
1733 }
1734 }
1735
1736 if (hasShieldTint)
1737 {
1738 auto const pShieldType = this->Shield->GetType();

Callers 3

UpdateTintMethod · 0.80
Hooks.cppFile · 0.80

Calls 4

issetMethod · 0.80
IsActiveMethod · 0.45
HasTintMethod · 0.45
GetTypeMethod · 0.45

Tested by

no test coverage detected