本文整理汇总了C++中Sector::Contains方法的典型用法代码示例。如果您正苦于以下问题:C++ Sector::Contains方法的具体用法?C++ Sector::Contains怎么用?C++ Sector::Contains使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Sector
的用法示例。
在下文中一共展示了Sector::Contains方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: IsCloserAndContains
/* Answer whether the faction both contains the sysPath, and has a homeworld
closer than the passed distance.
if it is, then the passed distance will also be updated to be the distance
from the factions homeworld to the sysPath.
*/
const bool Faction::IsCloserAndContains(double& closestFactionDist, const Sector sec, Uint32 sysIndex)
{
/* Treat factions without homeworlds as if they are of effectively infinite radius,
so every world is potentially within their borders, but also treat them as if
they had a homeworld that was infinitely far away, so every other faction has
a better claim.
*/
float distance = HUGE_VAL;
bool inside = true;
/* Factions that have a homeworld... */
if (hasHomeworld)
{
/* ...automatically gain the allegiance of worlds within the same sector... */
if (sec.Contains(homeworld)) { distance = 0; }
/* ...otherwise we need to calculate whether the world is inside the
the faction border, and how far away it is. */
else {
if (!m_homesector) m_homesector = new Sector(homeworld.sectorX, homeworld.sectorY, homeworld.sectorZ);
distance = Sector::DistanceBetween(m_homesector, homeworld.systemIndex, &sec, sysIndex);
inside = distance < Radius();
}
}
/* if the faction contains the world, and its homeworld is closer, then this faction
wins, and we update the closestFactionDist */
if (inside && (distance <= closestFactionDist)) {
closestFactionDist = distance;
return true;
/* otherwise this isn't the faction we were looking for */
} else {
return false;
}
}