本文整理汇总了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);
}
示例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)
{
//.........这里部分代码省略.........