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


C++ MoverPtr::getCurCV方法代码示例

本文整理汇总了C++中MoverPtr::getCurCV方法的典型用法代码示例。如果您正苦于以下问题:C++ MoverPtr::getCurCV方法的具体用法?C++ MoverPtr::getCurCV怎么用?C++ MoverPtr::getCurCV使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在MoverPtr的用法示例。


在下文中一共展示了MoverPtr::getCurCV方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: getContacts

long TeamSensorSystem::getContacts (GameObjectPtr looker, long* contactList, long contactCriteria, long sortType) {

	if ((sortType != CONTACT_SORT_NONE) && !looker)
		return(0);

	static float sortValues[MAX_CONTACTS_PER_SENSOR];

	float CV = 0;
	long numValidContacts = 0;
	long handleList[MAX_CONTACTS_PER_SENSOR];
	for (long i = 0; i < numContacts; i++) {
		MoverPtr mover = (MoverPtr)ObjectManager->get(contacts[i]);
		if (!meetsCriteria(looker, mover, contactCriteria))
			continue;
		handleList[numValidContacts] = mover->getHandle();
		switch (sortType) {
			case CONTACT_SORT_NONE:
				sortValues[numValidContacts] = 0.0;
				break;
			case CONTACT_SORT_CV:
				CV = (float)mover->getCurCV();
				sortValues[numValidContacts] = CV;
				break;
			case CONTACT_SORT_DISTANCE:
				sortValues[numValidContacts] = looker->distanceFrom(mover->getPosition());
				break;
		}
		numValidContacts++;
	}

	if ((numValidContacts > 0) && (sortType != CONTACT_SORT_NONE)) {
		//---------------------------------------------------------
		// BIG ASSUMPTION HERE: That a mech will not have more than
		// MAX_CONTACTS_PER_SENSOR contacts.
		if (!SensorSystem::sortList) {
			SensorSystem::sortList = new SortList;
			if (!SensorSystem::sortList)
				Fatal(0, " Unable to create Contact sortList ");
			SensorSystem::sortList->init(MAX_CONTACTS_PER_SENSOR);
		}
		bool descendSort = true;
		if (sortType == CONTACT_SORT_DISTANCE)
			descendSort = false;
		SensorSystem::sortList->clear(descendSort);
		for (long contact = 0; contact < numValidContacts; contact++) {
			SensorSystem::sortList->setId(contact, handleList[contact]);
			SensorSystem::sortList->setValue(contact, sortValues[contact]);
		}
		SensorSystem::sortList->sort(descendSort);
		for (contact = 0; contact < numValidContacts; contact++)
			contactList[contact] = SensorSystem::sortList->getId(contact);
		}
	else if (contactList)
		for (long contact = 0; contact < numValidContacts; contact++)
			contactList[contact] = handleList[contact];


	return(numValidContacts);
}
开发者ID:Ariemeth,项目名称:MechCommander2HD,代码行数:59,代码来源:Contact.cpp


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