当前位置: 首页>>代码示例>>C++>>正文


C++ Sector::Contains方法代码示例

本文整理汇总了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;
	}
}
开发者ID:Mike-Cowley,项目名称:pioneer,代码行数:42,代码来源:Factions.cpp


注:本文中的Sector::Contains方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。