@@ -2017,60 +2017,4 @@ class TC_GAME_API Unit : public WorldObject
20172017 /* Player Movement fields END*/
20182018};
20192019
2020- namespace Trinity
2021- {
2022- // Binary predicate for sorting Units based on percent value of a power
2023- class PowerPctOrderPred
2024- {
2025- public:
2026- PowerPctOrderPred (Powers power, bool ascending = true ) : _power(power), _ascending(ascending) { }
2027-
2028- bool operator ()(WorldObject const * objA, WorldObject const * objB) const
2029- {
2030- Unit const * a = objA->ToUnit ();
2031- Unit const * b = objB->ToUnit ();
2032- float rA = a ? a->GetPowerPct (_power) : 0 .0f ;
2033- float rB = b ? b->GetPowerPct (_power) : 0 .0f ;
2034- return _ascending ? rA < rB : rA > rB;
2035- }
2036-
2037- bool operator ()(Unit const * a, Unit const * b) const
2038- {
2039- float rA = a->GetPowerPct (_power);
2040- float rB = b->GetPowerPct (_power);
2041- return _ascending ? rA < rB : rA > rB;
2042- }
2043-
2044- private:
2045- Powers const _power;
2046- bool const _ascending;
2047- };
2048-
2049- // Binary predicate for sorting Units based on percent value of health
2050- class HealthPctOrderPred
2051- {
2052- public:
2053- HealthPctOrderPred (bool ascending = true ) : _ascending(ascending) { }
2054-
2055- bool operator ()(WorldObject const * objA, WorldObject const * objB) const
2056- {
2057- Unit const * a = objA->ToUnit ();
2058- Unit const * b = objB->ToUnit ();
2059- float rA = (a && a->GetMaxHealth ()) ? float (a->GetHealth ()) / float (a->GetMaxHealth ()) : 0 .0f ;
2060- float rB = (b && b->GetMaxHealth ()) ? float (b->GetHealth ()) / float (b->GetMaxHealth ()) : 0 .0f ;
2061- return _ascending ? rA < rB : rA > rB;
2062- }
2063-
2064- bool operator () (Unit const * a, Unit const * b) const
2065- {
2066- float rA = a->GetMaxHealth () ? float (a->GetHealth ()) / float (a->GetMaxHealth ()) : 0 .0f ;
2067- float rB = b->GetMaxHealth () ? float (b->GetHealth ()) / float (b->GetMaxHealth ()) : 0 .0f ;
2068- return _ascending ? rA < rB : rA > rB;
2069- }
2070-
2071- private:
2072- bool const _ascending;
2073- };
2074- }
2075-
20762020#endif
0 commit comments