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

#include "Unit.h"

Public Member Functions

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

Private Attributes

Powers const _power
 
bool const _ascending
 

Detailed Description

Constructor & Destructor Documentation

◆ PowerPctOrderPred()

Acore::PowerPctOrderPred::PowerPctOrderPred ( Powers  power,
bool  ascending = true 
)
inline
2133: _power(power), _ascending(ascending) { }
Powers const _power
Definition: Unit.h:2152
bool const _ascending
Definition: Unit.h:2153

Member Function Documentation

◆ operator()() [1/2]

bool Acore::PowerPctOrderPred::operator() ( Unit const *  a,
Unit const *  b 
) const
inline
2145 {
2146 float rA = a->GetMaxPower(_power) ? float(a->GetPower(_power)) / float(a->GetMaxPower(_power)) : 0.0f;
2147 float rB = b->GetMaxPower(_power) ? float(b->GetPower(_power)) / float(b->GetMaxPower(_power)) : 0.0f;
2148 return _ascending ? rA < rB : rA > rB;
2149 }

References _ascending, _power, Unit::GetMaxPower(), and Unit::GetPower().

◆ operator()() [2/2]

bool Acore::PowerPctOrderPred::operator() ( WorldObject const *  objA,
WorldObject const *  objB 
) const
inline
2136 {
2137 Unit const* a = objA->ToUnit();
2138 Unit const* b = objB->ToUnit();
2139 float rA = (a && a->GetMaxPower(_power)) ? float(a->GetPower(_power)) / float(a->GetMaxPower(_power)) : 0.0f;
2140 float rB = (b && b->GetMaxPower(_power)) ? float(b->GetPower(_power)) / float(b->GetMaxPower(_power)) : 0.0f;
2141 return _ascending ? rA < rB : rA > rB;
2142 }
Unit * ToUnit()
Definition: Object.h:209
Definition: Unit.h:630
uint32 GetMaxPower(Powers power) const
Definition: Unit.h:1057
uint32 GetPower(Powers power) const
Definition: Unit.h:1056

References _ascending, _power, Unit::GetMaxPower(), Unit::GetPower(), and Object::ToUnit().

Member Data Documentation

◆ _ascending

bool const Acore::PowerPctOrderPred::_ascending
private

Referenced by operator()().

◆ _power

Powers const Acore::PowerPctOrderPred::_power
private

Referenced by operator()().