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


C++ CInstance::isKindOf方法代码示例

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


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

示例1: updateAfterRender

// **********************************************
void CToolPick::updateAfterRender()
{
	//H_AUTO(R2_CToolPick_updateAfterRender)
	// See if the mouse is over a valid position
	_ValidPos = false;
	sint32 mouseX,  mouseY;
	getMousePos(mouseX,  mouseY);
	if (!isInScreen(mouseX,  mouseY))
	{
		getEditor().setFocusedInstance(NULL);
		setMouseCursor(_CursCannotPickPos);
		return;
	}
	_CandidateInstance = NULL;
	CInstance *instanceUnder = checkInstanceUnderMouse();
	bool ignoreInstanceUnder = false;
	if(instanceUnder && _IgnoreInstances.size()>0)
	{
		for(uint i=0; i<_IgnoreInstances.size(); i++)
		{
			if(instanceUnder->isKindOf(_IgnoreInstances[i]))
			{
				ignoreInstanceUnder = true;
				break;
			}
		}
	}
	if (!instanceUnder || ignoreInstanceUnder)
	{
		if (isMouseOnUI() && !isMouseOnContainer())
		{
			setMouseCursor(DEFAULT_CURSOR);
		}
		else
		{
			CTool::CWorldViewRay worldViewRay;
			computeWorldViewRay(mouseX,  mouseY,  worldViewRay);
			CVector inter;
			_ValidPos = (ValidPacsPos == computeLandscapeRayIntersection(worldViewRay,  _Intersection));
			setMouseCursor(_ValidPos ? _CursCanPickPos : _CursCannotPickPos);
			getEditor().setFocusedInstance(NULL);
		}
		return;
	}
	getEditor().setFocusedInstance(instanceUnder);
	if (canPick(*instanceUnder))
	{
		_CandidateInstance = instanceUnder;
		setMouseCursor(_CursCanPickInstance);
	}
	else
	{
		setMouseCursor(_CursCannotPickInstance);
	}
}
开发者ID:CCChaos,项目名称:RyzomCore,代码行数:56,代码来源:tool_pick.cpp

示例2: lsr

//***************************************************************
CInstance *CAutoGroup::getGroupingCandidate()
{
	//H_AUTO(R2_CAutoGroup_getGroupingCandidate)
	if (!_AutoGroupEnabled) return NULL;
	// if I'm a bot object, don't auto-group
	CObject *palEntry = getEditor().getDMC().getPaletteElement(_PaletteEntry);
	if (!palEntry || !palEntry->isTable()) return NULL;
	if (getNumber(palEntry, "IsBotObject") == 1) return NULL;
	// auto-group feature
	// look in default feature and sort objects by distance
	CInstance *defaultFeatInst = getEditor().getDefaultFeature(getEditor().getCurrentAct());
	CInstance *baseDefaultFeatInst = getEditor().getDefaultFeature(getEditor().getBaseAct());
	if (!defaultFeatInst || !baseDefaultFeatInst)
	{
		nlwarning("Can't access to Default Features"); // syntax error in lua was making the client crash
		return NULL; //In this case there is no default features
	}
	CObjectTable *defaultFeat = defaultFeatInst->getObjectTable();
	CObjectTable *baseDefaultFeat = baseDefaultFeatInst->getObjectTable();
	CObject *components = defaultFeat->getAttr("Components");
	CObject *baseComponents = baseDefaultFeat->getAttr("Components");
	if (!components || !baseComponents || !palEntry->isTable()) return NULL;
	_SortedComponents.clear();
	for (uint k = 0; k < (components->getSize()+baseComponents->getSize()); ++k)
	{
		CObject *obj = NULL;
		if(k<components->getSize())
			obj = components->getValue(k);
		else
			obj = baseComponents->getValue(k - components->getSize());
		CInstance *inst = getEditor().getInstanceFromObject(obj);
		if (!inst)
		{
			nlwarning("Error: can not find create Instance of an object.");
			continue;
		}
		CDisplayerVisual *dv = inst->getDisplayerVisual();
		if (!dv) continue;
		CComponentSort cs;
		cs.Dist = (_TestPos - dv->getWorldPos()).norm();
		if (cs.Dist > CV_AutoGroupMaxDist.get()) continue;
		cs.Instance = inst;
		_SortedComponents.push_back(cs);
	}
	// iterate through other features
	CObjectTable *act = getEditor().getCurrentAct()->getObjectTable();
	CObjectTable *baseAct = getEditor().getBaseAct()->getObjectTable();
	if (!act || !baseAct) return NULL;
	CObject *features = act->getAttr("Features");
	CObject *baseFeatures = baseAct->getAttr("Features");
	if (!features || !baseFeatures) return NULL;
	for (uint k = 0; k < (features->getSize()+baseFeatures->getSize()); ++k)
	{
		CObject *obj = NULL;
		if(k<features->getSize())
			obj = features->getValue(k);
		else
			obj = baseFeatures->getValue(k - features->getSize());
		CInstance *inst = getEditor().getInstanceFromObject(obj);
		CDisplayerVisual *dv = inst->getDisplayerVisual();
		if (!dv) continue;
		if (inst->isKindOf("NpcGrpFeature"))
		{
			if (dv->getNumSons() == 0) continue;
			CComponentSort cs;
			cs.Dist = (_TestPos - dv->getSon(0)->getWorldPos()).norm();
			if (cs.Dist > CV_AutoGroupMaxDist.get()) continue;
			cs.Instance = inst;
			_SortedComponents.push_back(cs);
		}
	}


	std::sort(_SortedComponents.begin(), _SortedComponents.end());
	CLuaState &ls = getEditor().getLua();
	const CObject *categoryObj = getObject(palEntry, "Category");
	if (!categoryObj)
	{
		nlwarning("No 'Category' field in palEntry '%s'", _PaletteEntry.c_str());
		return NULL;
	}
	if (!categoryObj->isString()) return NULL;
	std::string category = categoryObj->toString();
	//
	const CObject *subCategoryObj = getObject(palEntry, "SubCategory");
	std::string subCategory;
	if (subCategoryObj && subCategoryObj->isString())
	{
		subCategory = subCategoryObj->toString();
	}
	else
	{
		//nlwarning("No 'SubCategory' field in palEntry '%s'", paletteEntry.c_str());
	}

	//
	if (category.empty()) return NULL;
	for(uint k = 0; k < _SortedComponents.size(); ++k)
	{
//.........这里部分代码省略.........
开发者ID:mixxit,项目名称:solinia,代码行数:101,代码来源:auto_group.cpp

示例3: group

//***************************************************************
void CAutoGroup::group(CObject *newEntityDesc, const NLMISC::CVectorD &createPosition)
{
	//H_AUTO(R2_CAutoGroup_group)
	CInstance *destGroup = getGroupingCandidate();
	if (!destGroup || !_AutoGroupEnabled) return;
	_AutoGroupEnabled = false; // force user to call 'update' again
	clear();
	// remove any activity, dialog, or event in the copy
	CObject *behav = newEntityDesc->findAttr("Behavior");
	if (behav)
	{
		behav->setObject("Actions", new CObjectTable());
		behav->setObject("Activities", new CObjectTable());
		behav->setObject("ChatSequences", new CObjectTable());
		newEntityDesc->setObject("ActivitiesId", new CObjectTable());
	}
	nlassert(newEntityDesc);
	nlassert(destGroup);
	std::string targetGroupId;
	if (destGroup->isKindOf("NpcGrpFeature"))
	{
		// make relative to newgroup and insert
		CVectorD relPos = createPosition;
		CDisplayerVisual *vd = destGroup->getDisplayerVisual();
		if (vd)
		{
			relPos = relPos - vd->getWorldPos();
		}
		newEntityDesc->setObject("Position", buildVector(relPos));
		targetGroupId = destGroup->getId();
	}
	else
	{
		// other is a standalone entity -> create a new group
		std::auto_ptr<CObject> newGroup(getEditor().getDMC().newComponent("NpcGrpFeature"));
		if (!newGroup.get())
		{
			nlwarning("Syntax error in r2_features_npc_group.lua.");
			getEditor().getDMC().getActionHistoric().endAction();
			getEditor().getDMC().flushActions();
			return;
		}
		ucstring readableName;
		CLuaState &ls = getEditor().getLua();
		R2::getEditor().getEnv()["PaletteIdToGroupTranslation"][newEntityDesc->getAttr("Base")->toString()].push();
		if (ls.isString(-1))
			readableName.fromUtf8(ls.toString(-1));
		ucstring ucGroupName = ucstring(readableName + " " + CI18N::get("uiR2EDNameGroup").toUtf8());

		newGroup->set("Name", getEditor().genInstanceName(ucGroupName).toUtf8());
		getEditor().getDMC().requestInsertNode(destGroup->getParentAct()->getId(),
							   "Features",
							   -1,
							   "",
							   newGroup.get());
		targetGroupId = getString(newGroup.get(), "InstanceId");
		// move target instance in that group (becomes the leader)
		getEditor().getDMC().requestMoveNode(destGroup->getId(), "", -1, targetGroupId, "Components", -1);
	}
	// move newly created entity into target group
	getEditor().getDMC().requestInsertNode(targetGroupId,
							   "Components",
							   -1,
							   "",
							   newEntityDesc);
	getEditor().getDMC().getActionHistoric().endAction();
	getEditor().getDMC().flushActions();
}
开发者ID:mixxit,项目名称:solinia,代码行数:69,代码来源:auto_group.cpp

示例4: update

//*********************************************************************************************************
void CDisplayerVisualActivitySequence::update()
{
	//H_AUTO(R2_CDisplayerVisualActivitySequence_update)
	if (!_Active) return;
	if (!_Touched) return;
	_Touched = false;
	CObjectTable *activities = getProps().toTable("Components");
	if (!activities)
	{
		clear();
		return;
	}
	// get first world object parent to get start position
	nlassert(getDisplayedInstance());
	CInstance *prevZone = NULL;
	CDisplayerVisual *prevDV = getParentDV();
	if (!prevDV)
	{
		clear();
		return;
	}
	//
	clear(false);
	//
	for(uint k = 0; k < activities->getSize(); ++k)
	{
		// search next zone of activity
		CObjectTable *activity = activities->getValue(k)->toTable();
		if (!activity) continue;
		std::string activityStr = getString(activity, "Activity");
		if (activityStr == "Stand Still" || activityStr == "Inactive") continue;
		//
		CInstance *nextZone = NULL;
		std::string zoneId = getString(activity, "ActivityZoneId");
		//
		if (!zoneId.empty())
		{
			_ObserverHandles.push_back(getEditor().addInstanceObserver(zoneId, this));
			nextZone = getEditor().getInstanceFromId(zoneId);
		}

		if (!nextZone) break;
		CDisplayerVisual *nextDV = nextZone->getDisplayerVisual();
		if (!nextDV) break;

		_TraversedPrimInfos.push_back(CTraversedPrimInfo());
		_TraversedPrimInfos.back().PrimDisplay = nextDV;
		_TraversedPrimInfos.back().Visible = nextDV->getActualDisplayMode() != DisplayModeHidden;


		CWorldPosCache wpc;
		wpc.DV = nextDV;
		wpc.WorldPos2f = nextDV->getWorldPos2f();
		_WPCache.push_back(wpc);

		if (nextDV->getActualDisplayMode() != DisplayModeHidden
			&& prevDV->getActualDisplayMode() != DisplayModeHidden)
		{
			// special case for regions
			if (nextZone->isKindOf("Region"))
			{
				// first case : previous zone is not a region
				if (!prevZone || !prevZone->isKindOf("Region"))
				{
					// search shortest distance bewteen last pos and the region
					CVector entryPos;
					if (nextDV->evalEnterPoint(prevDV->evalExitPoint(), entryPos))
					{
						addFootSteps(CLine(prevDV->evalExitPoint(), entryPos));
					}
					else
					{
						addWanderSteps(prevDV->evalExitPoint());
					}
				}
				else
				{
					// region-region footsteps
					// just use the couple of vertices for which the distance is the smallest
					static std::vector<CVector2f> r0;
					static std::vector<CVector2f> r1;
					prevDV->getSonsWorldPos2f(r0);
					nextDV->getSonsWorldPos2f(r1);
					if (!r0.empty() && !r1.empty())
					{
						CVector2f p0, p1;
						float bestDist = FLT_MAX;
						for(uint k = 0; k < r0.size(); ++k)
						{
							for(uint l = 0; l < r0.size(); ++l)
							{
								float dist = (r0[k] - r1[l]).norm();
								if (dist <bestDist)
								{
									bestDist = dist;
									p0 = r0[k];
									p1 = r1[l];
								}
							}
//.........这里部分代码省略.........
开发者ID:mixxit,项目名称:solinia,代码行数:101,代码来源:displayer_visual_activity_sequence.cpp


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