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

Member Function Documentation

◆ operator()() [1/2]

bool Acore::PowerPctOrderPred::operator() ( Unit const *  a,
Unit const *  b 
) const
inline
1984 {
1985 float rA = a->GetMaxPower(_power) ? float(a->GetPower(_power)) / float(a->GetMaxPower(_power)) : 0.0f;
1986 float rB = b->GetMaxPower(_power) ? float(b->GetPower(_power)) / float(b->GetMaxPower(_power)) : 0.0f;
1987 return _ascending ? rA < rB : rA > rB;
1988 }

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

◆ operator()() [2/2]

bool Acore::PowerPctOrderPred::operator() ( WorldObject const *  objA,
WorldObject const *  objB 
) const
inline
1975 {
1976 Unit const* a = objA->ToUnit();
1977 Unit const* b = objB->ToUnit();
1978 float rA = (a && a->GetMaxPower(_power)) ? float(a->GetPower(_power)) / float(a->GetMaxPower(_power)) : 0.0f;
1979 float rB = (b && b->GetMaxPower(_power)) ? float(b->GetPower(_power)) / float(b->GetMaxPower(_power)) : 0.0f;
1980 return _ascending ? rA < rB : rA > rB;
1981 }
Unit * ToUnit()
Definition: Object.h:206
Definition: Unit.h:630
uint32 GetMaxPower(Powers power) const
Definition: Unit.h:892
uint32 GetPower(Powers power) const
Definition: Unit.h:891

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