//----------------------------------------------- // build : // Build the entity from a sheet. //----------------------------------------------- bool CItemCL::build(const CEntitySheet *sheet ) // virtual { // Cast the sheet in the right type. const CItemSheet *sh = dynamic_cast<const CItemSheet *>(sheet); if(sh==0) { nlwarning("Item:build: the sheet is not an item sheet -> entity not initialized."); return false; } // Get the DB Entry if(IngameDbMngr.getNodePtr()) { CCDBNodeBranch *nodeRoot = dynamic_cast<CCDBNodeBranch *>(IngameDbMngr.getNodePtr()->getNode(0)); if(nodeRoot) { _DBEntry = dynamic_cast<CCDBNodeBranch *>(nodeRoot->getNode(_Slot)); if(_DBEntry == 0) pushDebugStr("Cannot get a pointer on the DB entry."); } } // initialize(); initShape( sh->getShape() ); // Entity Created. return true; }// build //
//----------------------------------------------- // build : // Build the entity from a sheet. //----------------------------------------------- bool CPlayerR2CL::build(const CEntitySheet *sheet) // virtual { // Cast the sheet in the right type. _Sheet = dynamic_cast<const CCharacterSheet *>(sheet); if(_Sheet==0) { pushDebugStr(NLMISC::toString("R2 Player '%d' sheet is not a '.creature' -> BIG PROBLEM.", _Slot)); return false; } else pushInfoStr(NLMISC::toString("R2 Player '%d' sheet is valid.", _Slot)); // Get the DB Entry if(IngameDbMngr.getNodePtr()) { CCDBNodeBranch *nodeRoot = dynamic_cast<CCDBNodeBranch *>(IngameDbMngr.getNodePtr()->getNode(0)); if(nodeRoot) { _DBEntry = dynamic_cast<CCDBNodeBranch *>(nodeRoot->getNode(_Slot)); if(_DBEntry == 0) pushDebugStr("Cannot get a pointer on the DB entry."); } } // Compute the first automaton. _CurrentAutomaton = automatonType() + "_normal.automaton"; // Initialize the player look. init3d(); // Compute the primitive initPrimitive(0.5f, 2.0f, 0.0f, 0.0f, UMovePrimitive::DoNothing, UMovePrimitive::NotATrigger, MaskColPlayer, MaskColNone); // Create the collision entity (used to snap the entity to the ground). computeCollisionEntity(); // Initialize properties of the client. initProperties(); // Entity Created. return true; }// build //
virtual void execute (CCtrlBase * /* pCaller */, const string &Params) { CInterfaceManager *pIM = CInterfaceManager::getInstance(); string dbdst = getParam (Params, "dbdst"); string dbsrc = getParam (Params, "dbsrc"); CCDBNodeBranch *pNBdst = pIM->getDbBranch(dbdst); CCDBNodeBranch *pNBsrc = pIM->getDbBranch(dbsrc); // Branch copy if ((pNBdst != NULL) && (pNBsrc != NULL)) { //nlinfo("copying from %s to %s",pNBsrc->getName()->c_str(), pNBdst->getName()->c_str()); // Parse all children of the src branch uint nbLeaves = pNBsrc->countLeaves(); for (uint i = 0; i < nbLeaves; ++i) { uint count = i; CCDBNodeLeaf *pNLsrc = pNBsrc->findLeafAtCount(count); // Find its access name string sTmp = *pNLsrc->getName(); CCDBNodeBranch *pParent = pNLsrc->getParent(); while (pParent != pNBsrc) { sTmp = *pParent->getName() + ":" + sTmp; pParent = pParent->getParent(); } // Find the correspondant node in the dst branch CCDBNodeLeaf *pNLdst = dynamic_cast<CCDBNodeLeaf*>(pNBdst->getNode(ICDBNode::CTextId(sTmp))); if (pNLdst == NULL) { nlwarning ("cannot find destination leaf %s",sTmp.c_str()); } else { pNLdst->setValue64(pNLsrc->getValue64()); //sint32 nVal = pNLsrc->getValue64(); //nlinfo("set value %d for node %s", nVal, sTmp.c_str()); } } return; } // Not branch copy so leaf copy CInterfaceProperty ipsrc; CInterfaceProperty ipdst; if (!ipsrc.link (dbsrc.c_str())) { nlwarning("cannot find leaf %s",dbsrc.c_str()); return; } if (!ipdst.link (dbdst.c_str())) { nlwarning("cannot find leaf %s",dbdst.c_str()); return; } // copy ipdst.setSInt64 (ipsrc.getSInt64()); }