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

Member Function Documentation

◆ operator()() [1/2]

bool Acore::PowerPctOrderPred::operator() ( Unit const *  a,
Unit const *  b 
) const
inline
2619 {
2620 float rA = a->GetMaxPower(_power) ? float(a->GetPower(_power)) / float(a->GetMaxPower(_power)) : 0.0f;
2621 float rB = b->GetMaxPower(_power) ? float(b->GetPower(_power)) / float(b->GetMaxPower(_power)) : 0.0f;
2622 return _ascending ? rA < rB : rA > rB;
2623 }

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

◆ operator()() [2/2]

bool Acore::PowerPctOrderPred::operator() ( WorldObject const *  objA,
WorldObject const *  objB 
) const
inline
2610 {
2611 Unit const* a = objA->ToUnit();
2612 Unit const* b = objB->ToUnit();
2613 float rA = (a && a->GetMaxPower(_power)) ? float(a->GetPower(_power)) / float(a->GetMaxPower(_power)) : 0.0f;
2614 float rB = (b && b->GetMaxPower(_power)) ? float(b->GetPower(_power)) / float(b->GetMaxPower(_power)) : 0.0f;
2615 return _ascending ? rA < rB : rA > rB;
2616 }
Unit * ToUnit()
Definition: Object.h:200
Definition: Unit.h:1290
uint32 GetMaxPower(Powers power) const
Definition: Unit.h:1462
uint32 GetPower(Powers power) const
Definition: Unit.h:1461

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