1 #include "PopulationPool.h" 2 3 #include "../universe/Enums.h" 4 #include "../universe/PopCenter.h" 5 #include "../util/AppInterface.h" 6 PopulationPool()7PopulationPool::PopulationPool() 8 {} 9 Population() const10float PopulationPool::Population() const 11 { return m_population; } 12 SetPopCenters(const std::vector<int> & pop_center_ids)13void PopulationPool::SetPopCenters(const std::vector<int>& pop_center_ids) { 14 if (m_pop_center_ids == pop_center_ids) 15 return; 16 m_pop_center_ids = pop_center_ids; 17 } 18 Update()19void PopulationPool::Update() { 20 m_population = 0.0f; 21 // sum population from all PopCenters in this pool 22 for (const auto& center : Objects().find<PopCenter>(m_pop_center_ids)) { 23 if (!center) 24 continue; 25 m_population += center->GetMeter(METER_POPULATION)->Current(); 26 } 27 ChangedSignal(); 28 } 29