CEntity* CEntityFactory::CreateTmpEntity(CStrID GUID, CStrID Category, PValueTable Table, int Row) const { CEntity* pEntity = CreateEntityByClassName("Entity"); pEntity->SetCategory(Category); //???add to dummy table all attrs if category exists? pEntity->SetAttrTable(Table); pEntity->SetAttrTableRowIndex(Row); pEntity->SetUniqueID(GUID); pEntity->SetLive(true); return pEntity; }
CEntity* CEntityFactory::CreateEntityByTemplate(CStrID GUID, CStrID Category, CStrID TplName, EntityPool EntPool) { n_assert(Category.IsValid()); n_assert(TplName.IsValid()); const CEntityCat& Cat = Categories[Category]; int TplIdx = FindTemplate(TplName, Cat); if (TplIdx == INVALID_INDEX) return NULL; CEntity* pEntity = CreateEntityByClassName(Cat.CppClass); pEntity->SetLive(EntPool == LivePool); pEntity->SetAttrTable(Cat.InstDataset->GetValueTable()); pEntity->SetAttrTableRowIndex(Cat.InstDataset->GetValueTable()->CopyExtRow(Cat.TplDataset->GetValueTable(), TplIdx, true)); pEntity->SetCategory(Category); pEntity->SetUniqueID(GUID); for (int i = 0; i < Cat.Properties.Size(); i++) AttachProperty(*pEntity, Cat.Properties[i]); return pEntity; }