AzerothCore 3.3.5a
OpenSource WoW Emulator
Loading...
Searching...
No Matches
Acore::HealthPctOrderPred Class Reference

Public Member Functions

 HealthPctOrderPred (bool ascending=true)
 
bool operator() (WorldObject const *objA, WorldObject const *objB) const
 
bool operator() (Unit const *a, Unit const *b) const
 

Private Attributes

bool const _ascending
 

Detailed Description

Constructor & Destructor Documentation

◆ HealthPctOrderPred()

Acore::HealthPctOrderPred::HealthPctOrderPred ( bool  ascending = true)
inline
2212: _ascending(ascending) { }
bool const _ascending
Definition Unit.h:2231

Member Function Documentation

◆ operator()() [1/2]

bool Acore::HealthPctOrderPred::operator() ( Unit const *  a,
Unit const *  b 
) const
inline
2224 {
2225 float rA = a->GetMaxHealth() ? float(a->GetHealth()) / float(a->GetMaxHealth()) : 0.0f;
2226 float rB = b->GetMaxHealth() ? float(b->GetHealth()) / float(b->GetMaxHealth()) : 0.0f;
2227 return _ascending ? rA < rB : rA > rB;
2228 }

References _ascending, Unit::GetHealth(), and Unit::GetMaxHealth().

◆ operator()() [2/2]

bool Acore::HealthPctOrderPred::operator() ( WorldObject const *  objA,
WorldObject const *  objB 
) const
inline
2215 {
2216 Unit const* a = objA->ToUnit();
2217 Unit const* b = objB->ToUnit();
2218 float rA = (a && a->GetMaxHealth()) ? float(a->GetHealth()) / float(a->GetMaxHealth()) : 0.0f;
2219 float rB = (b && b->GetMaxHealth()) ? float(b->GetHealth()) / float(b->GetMaxHealth()) : 0.0f;
2220 return _ascending ? rA < rB : rA > rB;
2221 }
Unit * ToUnit()
Definition Object.h:209
Definition Unit.h:636
uint32 GetMaxHealth() const
Definition Unit.h:1039
uint32 GetHealth() const
Definition Unit.h:1038

References _ascending, Unit::GetHealth(), Unit::GetMaxHealth(), and Object::ToUnit().

Member Data Documentation

◆ _ascending

bool const Acore::HealthPctOrderPred::_ascending
private

Referenced by operator()(), and operator()().


The documentation for this class was generated from the following file: