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


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

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


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

示例1: beginAction

// ***************************************************************
void CToolSelectRotate::beginAction(CInstance &instance)
{
	//H_AUTO(R2_CToolSelectRotate_beginAction)
	_MouseStartX = getMouseX();
	_StartAngle = (float) instance.getObjectTable()->toNumber("Angle");
	setRotateInProgress(true, instance);
}
开发者ID:CCChaos,项目名称:RyzomCore,代码行数:8,代码来源:tool_select_rotate.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


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