refactor UnitAI::SelectTarget to allow having a predicate function (1st step).

--HG--
branch : trunk
This commit is contained in:
Trazom62
2010-02-27 16:29:58 +01:00
parent e010310c6d
commit d9056adc8a
7 changed files with 113 additions and 96 deletions
+15
View File
@@ -2085,4 +2085,19 @@ namespace Trinity
}
}
// binary function to sort unit based on the distance to a reference unit
struct TargetDistanceOrder : public std::binary_function<const Unit *, const Unit *, bool>
{
const Unit *me;
// pUnit: the reference unit from which the distance is computed.
TargetDistanceOrder(const Unit* pUnit) : me(pUnit) {};
// functor for operator "<"
bool operator()(const Unit* left, const Unit* right) const
{
return (me->GetExactDistSq(left) < me->GetExactDistSq(right));
}
};
#endif