/// <summary>
 /// Remove a population from the RPM.
 /// </summary>
 public void RemovePopulation(Population population)
 {
     if (!Populations.Contains(population))
     {
         return;
     }
     Populations.Remove(population);
     TypesOfTerrain.Remove(population);
     openID.Enqueue(PopulationToID[population]);
     PopulationByID.Remove(PopulationToID[population]); // free ID
     PopulationToID.Remove(population);                 // free ID
     CleanupAccessMapForRecycledID();
 }
    /// <summary>
    /// Add a population to the RPM.
    /// </summary>
    public void AddPopulation(Population population)
    {
        if (!Populations.Contains(population))
        {
            // ignore their old id and assign it a new one
            int id = openID.Dequeue();

            // since IDs after maxPopulation-1 are recycled ids, we need to do clean up old values
            if (id == lastRecycledID)
            {
                CleanupAccessMapForRecycledID();
            }
            PopulationToID.Add(population, id);
            PopulationByID.Add(id, population);
            Populations.Add(population);

            TypesOfTerrain.Add(population, new int[(int)TileType.TypesOfTiles]);
            // generate the map with the new id
            GenerateMap(population);
        }
    }