void Village::import(EntityReference entity) { Faction faction = entity->getFaction(); EntityGroup group = entity->getGroup(); EntityType type = entity->getEntityType(); if(faction == this->faction) { switch(group) { case EG_VILLAGER: villagerList.push_back((MobileEntityReference)entity); availableHousing --; break; case EG_DOMESTIC: domesticList.push_back((MobileEntityReference)entity); break; case EG_BUILDING: buildingList.push_back(entity); switch(type) { case ET_TOWN_CENTER: if(townCenter) std::cerr << "A second town center? How fancy!" << std::endl; townCenter = entity; break; case ET_HOUSE: availableHousing += POP_PER_HOUSE; break; case ET_TEMPLE: break; default: break; } break; default: break; } } }
void GameManager::setup() { WorldGeneration world; worldSize = world.getWorldSize(); initializeCallbackMap(); buttonContainer = new SdlWidgetContainer(callbackMap, "res/sidebar-files.cfg"); mapView = new SdlMapView(); mapView->hide(); SdlEntity::mapView = mapView; SdlEntity::worldSize = worldSize; // Village Manager villageManager.show(); villageManager.addVillage(F_PLAYER_1); villageManager.addVillage(F_PLAYER_2); hide(); obstructionMap = new ObstructionMap(worldSize); EntityReference tempEntity = world.getNextEntity(); EntityReference storedEntity; int count = 0; while (tempEntity && tempEntity->getType() != ET_NONE) { storedEntity = entityManager.createRecord(tempEntity); villageManager.import(storedEntity); creatureManager.import(storedEntity); if (tempEntity->getGroup() >= EG_MOBILE) obstructionMap->set(tempEntity->getPosition(), OT_CONSIDERED); else obstructionMap->set(tempEntity->getPosition(), OT_OBSTRUCTED); // Get next entity for next loop iteration. delete tempEntity; tempEntity = world.getNextEntity(); count++; } std::cout << count << std::endl; }