// create whatever entity the client desires Eris::Entity* EmberEntityFactory::instantiate(const Atlas::Objects::Entity::RootEntity &ge, Eris::TypeInfo* type, Eris::View* w) { EmberEntity* entity = new EmberEntity(ge->getId(), type, w); //the creator binds the model mapping and this instance together by creating instance of EmberEntityModelAction and EmberEntityPartAction which in turn calls the setModel(..) and show/hideModelPart(...) methods. EmberEntityActionCreator creator(*entity, mScene); EntityMapping::EntityMapping* mapping = Mapping::EmberEntityMappingManager::getSingleton().getManager().createMapping(*entity, creator, &mView); entity->BeingDeleted.connect(sigc::bind(sigc::mem_fun(*this, &EmberEntityFactory::deleteMapping), mapping)); mapping->initialize(); S_LOG_VERBOSE("Entity " << entity->getId() << " (" << type->getName() << ") added to game view."); return entity; }
EmberEntity* EmberEntity::getAttachedEntity(const std::string& namedPoint) { //HACK: this is just a temporary solution if (hasAttr(namedPoint)) { const Atlas::Message::Element& idElement = valueOfAttr(namedPoint); std::string id; if (Eris::Entity::extractEntityId(idElement, id)) { for (unsigned int i = 0; i < numContained(); ++i) { EmberEntity* entity = getEmberContained(i); if (entity && entity->getId() == id) { return entity; } } } } return 0; }
void TerrainEntityManager::entityAreaAttrChanged(EmberEntity& entity, const Atlas::Message::Element& value) { Terrain::TerrainArea* terrainArea; auto I = mAreas.find(&entity); if (I == mAreas.end()) { terrainArea = new Terrain::TerrainArea(entity); mAreas.insert(std::make_pair(&entity, terrainArea)); terrainArea->EventEntityBeingDeleted.connect(sigc::bind(sigc::mem_fun(*this, &TerrainEntityManager::entityBeingDeletedArea), &entity)); terrainArea->EventEntityMoved.connect(sigc::bind(sigc::mem_fun(*this, &TerrainEntityManager::entityMovedArea), &entity)); } else { terrainArea = I->second; } Mercator::Area* area = nullptr; terrainArea->parse(value, &area); mTerrainHandler.updateArea(entity.getId(), area); delete area; }
void TerrainEntityManager::topLevelEntityChanged() { EmberEntity* entity = static_cast<EmberEntity*>(mView.getTopLevel()); entity->setAttachment(nullptr); entity->setAttachment(new WorldAttachment(*entity, mSceneManager.getRootSceneNode()->createChildSceneNode("entity_" + entity->getId()))); }