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
 

Detailed Description

Definition at line 2129 of file Unit.h.

Constructor & Destructor Documentation

◆ HealthPctOrderPred()

Trinity::HealthPctOrderPred::HealthPctOrderPred ( bool  ascending = true)
inline

Definition at line 2132 of file Unit.h.

2132: _ascending(ascending) { }

Member Function Documentation

◆ operator()() [1/2]

bool Trinity::HealthPctOrderPred::operator() ( Unit const *  a,
Unit const *  b 
) const
inline

Definition at line 2143 of file Unit.h.

2144 {
2145 float rA = a->GetMaxHealth() ? float(a->GetHealth()) / float(a->GetMaxHealth()) : 0.0f;
2146 float rB = b->GetMaxHealth() ? float(b->GetHealth()) / float(b->GetMaxHealth()) : 0.0f;
2147 return _ascending ? rA < rB : rA > rB;
2148 }
+ Here is the call graph for this function:

◆ operator()() [2/2]

bool Trinity::HealthPctOrderPred::operator() ( WorldObject const *  objA,
WorldObject const *  objB 
) const
inline

Definition at line 2134 of file Unit.h.

2135 {
2136 Unit const* a = objA->ToUnit();
2137 Unit const* b = objB->ToUnit();
2138 float rA = (a && a->GetMaxHealth()) ? float(a->GetHealth()) / float(a->GetMaxHealth()) : 0.0f;
2139 float rB = (b && b->GetMaxHealth()) ? float(b->GetHealth()) / float(b->GetMaxHealth()) : 0.0f;
2140 return _ascending ? rA < rB : rA > rB;
2141 }
static Unit * ToUnit(Object *o)
Definition: Object.h:212
Definition: Unit.h:747
uint64 GetMaxHealth() const
Definition: Unit.h:897
uint64 GetHealth() const
Definition: Unit.h:896
+ Here is the call graph for this function:

Member Data Documentation

◆ _ascending

bool const Trinity::HealthPctOrderPred::_ascending
private

Definition at line 2151 of file Unit.h.


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