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


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

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


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

示例1: checkAdditionnalRoomLeftFor

//***************************************************************
bool CToolSelectMove::checkAdditionnalRoomLeftFor(CInstance &instance)
{
	//H_AUTO(R2_CToolSelectMove_checkAdditionnalRoomLeftFor)
	CLuaObject &luaProj = instance.getLuaProjection();
	CLuaState &ls = getEditor().getLua();
	CLuaStackRestorer lsr(&ls, 0);
	// check ai & static cost : if they are too big, can't create the duplicate
	if (!luaProj.callMethodByNameNoThrow("getAiCost", 0, 1)
		|| !ls.isNumber(-1))
	{
		return false;
	}
	uint aiCost = (uint) ls.toNumber(-1);
	ls.pop();
	if (!luaProj.callMethodByNameNoThrow("getStaticObjectCost", 0, 1))
	{
		return false;
	}
	uint staticCost = (uint) ls.toNumber(-1);
	ls.pop();
	if (!getEditor().verifyRoomLeft(aiCost, staticCost))
	{
		return false;
	}
	return true;
}
开发者ID:mixxit,项目名称:solinia,代码行数:27,代码来源:tool_select_move.cpp

示例2: lsr

//***************************************************************
CInstance *CToolSelectMove::createGhost(CInstance &instance)
{
	//H_AUTO(R2_CToolSelectMove_createGhost)
	CLuaState &ls = getEditor().getLua();
	// copy then do a local paste
	CLuaStackRestorer lsr(&ls, 0);
	//
	CLuaObject &luaProj = instance.getLuaProjection();
	CLuaObject &classDef = instance.getClass();
	if (luaProj.callMethodByNameNoThrow("copy", 0, 1))
	{
		// now we got a table that is an exact (canonical) copy of the original object, with the
		// same instance ids..
		// prepare for new insertion by renaming these instance id's (which 'newCopy' does)
		if (classDef["newCopy"].callNoThrow(1, 1))
		{
			// now, insert the new copy as a ghost in the new scene
			if (classDef["pasteGhost"].callNoThrow(1, 1))
			{

				CLuaObject ghost(ls); // pop the ghost from stack
				CInstance *newInst = getEditor().getInstanceFromId(ghost["InstanceId"].toString());
				if (newInst)
				{
					if (!newInst->getGhost())
					{
						nlwarning("When duplicating an object using the 'select/move' tool, temporary duplicate should be inserted \
								   as a ghost in the scene, removing object...");
						getEditor().getDMC().requestEraseNode(newInst->getId(), "", -1);
					}
					// set the flag so that the cost of this object isn't taken in account in the displayed quotas
					newInst->getLuaProjection()["User"].setValue("GhostDuplicate", true);
					getEditor().setSelectedInstance(newInst);
					newInst->getDisplayerVisual()->setDisplayFlag(CDisplayerVisual::FlagHideActivities, true);
					nlwarning("CToolSelectMove: beginning duplicate with instance with id %s", newInst->getId().c_str());
					// show in "frozen" state
					{
						/*CObjectNumber *numberValue = new CObjectNumber(2); // 2 = frozen state
						getEditor().getDMC().requestSetNode(newInst->getId(), "DisplayMode", numberValue);
						delete numberValue;
						*/
						newInst->getDisplayerVisual()->setDisplayMode(CDisplayerVisual::DisplayModeFrozen);
						getEditor().getEntitySorter()->clipEntitiesByDist();
						return newInst;
					}
				}
			}
		}
开发者ID:mixxit,项目名称:solinia,代码行数:49,代码来源:tool_select_move.cpp

示例3: getNameInParent

// ************************************************************************
void CObjectRefIdClient::getNameInParent(std::string &name, sint32 &indexInArray) const
{
	//H_AUTO(R2_CObjectRefIdClient_getNameInParent)
	if (_IndexInParent != -1 && _ParentInstance)
	{
		CObjectTable *parentInstanceTable = _ParentInstance->getObjectTable();
		// check that index is still valid (true most of the case unless instance has been moved)
		if (_IndexInParent <= (sint32) parentInstanceTable->getSize())
		{
			if (_IndexInParentArray == -1)
			{
				if (parentInstanceTable->getValue(_IndexInParent) == static_cast<const CObject *>(this))
				{
					name =  parentInstanceTable->getKey(_IndexInParent);
					indexInArray = -1;
					return;
				}
			}
			else
			{
				CObject *subObject = parentInstanceTable->getValue(_IndexInParent);
				if (subObject->isTable())
				{
					CObjectTable *subTable = (CObjectTable *) subObject;
					if (_IndexInParentArray < (sint32) subTable->getSize())
					{
						if (subTable->getValue(_IndexInParentArray) == static_cast<const CObject *>(this))
						{
							name =  parentInstanceTable->getKey(_IndexInParent);
							indexInArray = _IndexInParentArray;
						}
					}
				}
			}
		}
	}
	// must search name in parent (on init or when object is moved)
	updateParentInstancePtr();
	if (!_ParentInstance)
	{
		_IndexInParent = -1;
		_IndexInParentArray = -1;
		name.clear();
		indexInArray = -1;
		return;
	}
	CObjectTable *parentInstanceTable = _ParentInstance->getObjectTable();
	const CObject *ptrInParent = (parentInstanceTable == this->getParent()) ? static_cast<const CObject *>(this) : this->getParent();
	// if instance is the direct parent (e.g object is not in an array of the parent)
	for (uint k = 0; k < parentInstanceTable->getSize(); ++k)
	{
		if (parentInstanceTable->getValue(k) == ptrInParent)
		{
			_IndexInParent = k;
			if (ptrInParent == this)
			{
				_IndexInParentArray = -1;
				indexInArray = -1;
				name = parentInstanceTable->getKey(_IndexInParent);
				return;
			}
			else
			{
				// I'm in an array in my parent, retrieve the index
				for (uint l = 0; l < getParent()->getSize(); ++l)
				{
					if (getParent()->getValue(l) == static_cast<const CObject *>(this))
					{
						name = parentInstanceTable->getKey(_IndexInParent);
						_IndexInParentArray = l;
						return;
					}
				}
			}
		}
	}
	// TMP TMP
	nlwarning("=========================================");
	CLuaIHMRyzom::dumpCallStack();
	nlwarning("=========================================");
	nlwarning("ObservedObject = %s", getValue().c_str());
	CInstance *obsInstance = getEditor().getInstanceFromId(getValue().c_str());
	nlwarning("ObservedObject instance ptr = %p", obsInstance);
	nlwarning("=========================================");
	if (obsInstance)
	{
		obsInstance->getLuaProjection().dump();
		CInstance *parent = obsInstance->getParent();
		nlwarning("ObservedObject parent instance ptr = %p", parent);
		parent->getLuaProjection().dump();
	}
	nlassert(0); // not found in parent
}
开发者ID:CCChaos,项目名称:RyzomCore,代码行数:94,代码来源:object_factory_client.cpp


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