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
2621: _power(power), _ascending(ascending) { }
Powers const _power
Definition: Unit.h:2640
bool const _ascending
Definition: Unit.h:2641

Member Function Documentation

◆ operator()() [1/2]

bool Acore::PowerPctOrderPred::operator() ( Unit const *  a,
Unit const *  b 
) const
inline
2633 {
2634 float rA = a->GetMaxPower(_power) ? float(a->GetPower(_power)) / float(a->GetMaxPower(_power)) : 0.0f;
2635 float rB = b->GetMaxPower(_power) ? float(b->GetPower(_power)) / float(b->GetMaxPower(_power)) : 0.0f;
2636 return _ascending ? rA < rB : rA > rB;
2637 }

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

◆ operator()() [2/2]

bool Acore::PowerPctOrderPred::operator() ( WorldObject const *  objA,
WorldObject const *  objB 
) const
inline
2624 {
2625 Unit const* a = objA->ToUnit();
2626 Unit const* b = objB->ToUnit();
2627 float rA = (a && a->GetMaxPower(_power)) ? float(a->GetPower(_power)) / float(a->GetMaxPower(_power)) : 0.0f;
2628 float rB = (b && b->GetMaxPower(_power)) ? float(b->GetPower(_power)) / float(b->GetMaxPower(_power)) : 0.0f;
2629 return _ascending ? rA < rB : rA > rB;
2630 }
Unit * ToUnit()
Definition: Object.h:200
Definition: Unit.h:1302
uint32 GetMaxPower(Powers power) const
Definition: Unit.h:1476
uint32 GetPower(Powers power) const
Definition: Unit.h:1475

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()().