本文整理汇总了C++中CInstance::getId方法的典型用法代码示例。如果您正苦于以下问题:C++ CInstance::getId方法的具体用法?C++ CInstance::getId怎么用?C++ CInstance::getId使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CInstance
的用法示例。
在下文中一共展示了CInstance::getId方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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;
}
}
}
}
示例2: setEntityAngle
// ***************************************************************
void CToolSelectRotate::setEntityAngle(CEntityCL &/* entity */, CInstance &instance, float angle)
{
//H_AUTO(R2_CToolSelectRotate_setEntityAngle)
CObjectNumber *angleObject = new CObjectNumber(angle);
getEditor().requestSetLocalNode(instance.getId(), "Angle", angleObject);
delete angleObject;
}
示例3: commitAction
// ***************************************************************
void CToolSelectRotate::commitAction(CInstance &instance)
{
//H_AUTO(R2_CToolSelectRotate_commitAction)
getDMC().newAction(CI18N::get("uiR2EDRotateAction") + instance.getDisplayName());
// nothing to do, entity already has good angle
getEditor().requestCommitLocalNode(instance.getId(), "Angle");
setRotateInProgress(false, instance);
}
示例4: cancelAction
// ***************************************************************
void CToolSelectRotate::cancelAction(CInstance &instance)
{
//H_AUTO(R2_CToolSelectRotate_cancelAction)
CEntityCL *entity = instance.getEntity();
nlassert(entity);
getEditor().requestRollbackLocalNode(instance.getId(), "Angle");
setRotateInProgress(false, instance);
}
示例5: visit
virtual void visit(CInstance &inst)
{
CNotifySonDeletion notifySonDeletion(inst);
getEditor().triggerInstanceObserver(inst.getId(), notifySonDeletion);
}
示例6: 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();
}