TrinityCore
Trinity::HealthPctOrderPred Class Reference

#include <Unit.h>

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
 

Constructor & Destructor Documentation

◆ HealthPctOrderPred()

Trinity::HealthPctOrderPred::HealthPctOrderPred ( bool  ascending = true)
inline
2056 : _ascending(ascending) { }
bool const _ascending
Definition: Unit.h:2075

Member Function Documentation

◆ operator()() [1/2]

bool Trinity::HealthPctOrderPred::operator() ( WorldObject const *  objA,
WorldObject const *  objB 
) const
inline
2059  {
2060  Unit const* a = objA->ToUnit();
2061  Unit const* b = objB->ToUnit();
2062  float rA = (a && a->GetMaxHealth()) ? float(a->GetHealth()) / float(a->GetMaxHealth()) : 0.0f;
2063  float rB = (b && b->GetMaxHealth()) ? float(b->GetHealth()) / float(b->GetMaxHealth()) : 0.0f;
2064  return _ascending ? rA < rB : rA > rB;
2065  }
bool const _ascending
Definition: Unit.h:2075
uint64 GetHealth() const
Definition: Unit.h:890
static Unit * ToUnit(Object *o)
Definition: Object.h:207
uint64 GetMaxHealth() const
Definition: Unit.h:891
Definition: Unit.h:744
+ Here is the call graph for this function:

◆ operator()() [2/2]

bool Trinity::HealthPctOrderPred::operator() ( Unit const *  a,
Unit const *  b 
) const
inline
2068  {
2069  float rA = a->GetMaxHealth() ? float(a->GetHealth()) / float(a->GetMaxHealth()) : 0.0f;
2070  float rB = b->GetMaxHealth() ? float(b->GetHealth()) / float(b->GetMaxHealth()) : 0.0f;
2071  return _ascending ? rA < rB : rA > rB;
2072  }
bool const _ascending
Definition: Unit.h:2075
+ Here is the call graph for this function:

Member Data Documentation

◆ _ascending

bool const Trinity::HealthPctOrderPred::_ascending
private

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