public override void Rebuild()
        {
            this.weatherCommonalityRecords.Clear();
            base.Def.baseWeatherCommonalities.ForEach((WeatherCommonalityRecord r) => this.weatherCommonalityRecords.Add(this.CreateWeatherWidget(r)));

            this.terrainsByFertility.Clear();
            base.Def.terrainsByFertility.ForEach((TerrainThreshold tt) => this.terrainsByFertility.Add(this.CreateThresholdWidget(tt)));

            this.terrainPatchMakers.Clear();
            base.Def.terrainPatchMakers.ForEach((TerrainPatchMaker m) => this.terrainPatchMakers.Add(new TerrainPatchMakerWidget(m)));

            this.soundsAmbient.Clear();
            base.Def.soundsAmbient.ForEach((SoundDef d) => this.soundsAmbient.Add(d));

            this.diseases.Clear();
            BiomeDefStats.GetDiseases(base.Def).ForEach((BiomeDiseaseRecord r) => this.diseases.Add(this.CreateDiseaseWidget(r)));

            this.wildPlants.Clear();
            BiomeDefStats.GetWildPlants(base.Def).ForEach((BiomePlantRecord r) => this.wildPlants.Add(this.CreateWildPlantWidget(r)));

            this.wildAnimals.Clear();
            BiomeDefStats.GetWildAnimals(base.Def).ForEach((BiomeAnimalRecord r) => this.wildAnimals.Add(this.CreateWildAnimalWidget(r)));

            this.allowedPackAnimals.Clear();
            BiomeDefStats.GetAllowedPackAnimals(base.Def).ForEach((ThingDef d) => this.allowedPackAnimals.Add(d));

            this.ResetBuffers();
        }
        public BiomeWidget(BiomeDef d, DefType type) : base(d, type)
        {
            if (base.Def.baseWeatherCommonalities == null)
            {
                base.Def.baseWeatherCommonalities = new List <WeatherCommonalityRecord>();
            }
            if (base.Def.terrainsByFertility == null)
            {
                base.Def.terrainsByFertility = new List <TerrainThreshold>();
            }
            if (base.Def.soundsAmbient == null)
            {
                base.Def.soundsAmbient = new List <SoundDef>();
            }
            if (base.Def.terrainPatchMakers == null)
            {
                base.Def.terrainPatchMakers = new List <TerrainPatchMaker>();
            }
            if (BiomeDefStats.GetWildAnimals(base.Def) == null)
            {
                BiomeDefStats.SetWildAnimals(base.Def, new List <BiomeAnimalRecord>());
            }
            if (BiomeDefStats.GetWildPlants(base.Def) == null)
            {
                BiomeDefStats.SetWildPlants(base.Def, new List <BiomePlantRecord>());
            }
            if (BiomeDefStats.GetDiseases(base.Def) == null)
            {
                BiomeDefStats.SetDiseases(base.Def, new List <BiomeDiseaseRecord>());
            }
            if (BiomeDefStats.GetAllowedPackAnimals(base.Def) == null)
            {
                BiomeDefStats.SetAllowedPackAnimals(base.Def, new List <ThingDef>());
            }

            this.inputWidgets = new List <IInputWidget>()
            {
                new BoolInputWidget <BiomeDef>(base.Def, "Can Build Base", (BiomeDef def) => def.canBuildBase, (BiomeDef def, bool b) => def.canBuildBase         = b),
                new BoolInputWidget <BiomeDef>(base.Def, "Can Auto Choose", (BiomeDef def) => def.canAutoChoose, (BiomeDef def, bool b) => def.canAutoChoose      = b),
                new BoolInputWidget <BiomeDef>(base.Def, "Allow Roads", (BiomeDef def) => def.allowRoads, (BiomeDef def, bool b) => def.allowRoads                = b),
                new BoolInputWidget <BiomeDef>(base.Def, "Allow Rivers", (BiomeDef def) => def.allowRivers, (BiomeDef def, bool b) => def.allowRivers             = b),
                new FloatInputWidget <BiomeDef>(base.Def, "Animal Density", (BiomeDef def) => def.animalDensity, (BiomeDef def, float f) => def.animalDensity     = f),
                new FloatInputWidget <BiomeDef>(base.Def, "Plant Density", (BiomeDef def) => def.plantDensity, (BiomeDef def, float f) => def.plantDensity        = f),
                new FloatInputWidget <BiomeDef>(base.Def, "Disease Mtb Days", (BiomeDef def) => def.diseaseMtbDays, (BiomeDef def, float f) => def.diseaseMtbDays = f),
                new FloatInputWidget <BiomeDef>(base.Def, "Settlement Selection Weight", (BiomeDef def) => def.settlementSelectionWeight, (BiomeDef def, float f) => def.settlementSelectionWeight = f),
                new BoolInputWidget <BiomeDef>(base.Def, "Impassable", (BiomeDef def) => def.impassable, (BiomeDef def, bool b) => def.impassable = b),
                new BoolInputWidget <BiomeDef>(base.Def, "Has Virtual Plants", (BiomeDef def) => def.hasVirtualPlants, (BiomeDef def, bool b) => def.hasVirtualPlants = b),
                new FloatInputWidget <BiomeDef>(base.Def, "Forageability", (BiomeDef def) => def.forageability, (BiomeDef def, float f) => def.forageability          = f),
                new BoolInputWidget <BiomeDef>(base.Def, "Local Plants Care Fertability", (BiomeDef def) => def.wildPlantsCareAboutLocalFertility, (BiomeDef def, bool b) => def.wildPlantsCareAboutLocalFertility = b),
                new FloatInputWidget <BiomeDef>(base.Def, "Wild Plant Regrow Days", (BiomeDef def) => def.wildPlantRegrowDays, (BiomeDef def, float f) => def.wildPlantRegrowDays = f),
                new FloatInputWidget <BiomeDef>(base.Def, "Movement Difficulty", (BiomeDef def) => def.movementDifficulty, (BiomeDef def, float f) => def.movementDifficulty      = f),
                new BoolInputWidget <BiomeDef>(base.Def, "Has Bedrock", (BiomeDef def) => def.hasBedrock, (BiomeDef def, bool b) => def.hasBedrock = b)
            };

            this.weatherPlusMinusArgs = new PlusMinusArgs <WeatherDef>()
            {
                allItems  = DefDatabase <WeatherDef> .AllDefs,
                beingUsed = () => Util.ConvertItems(this.weatherCommonalityRecords, (FloatInputWidget <WeatherCommonalityRecord> w) => w.Parent.weather),
                onAdd     = delegate(WeatherDef wd)
                {
                    WeatherCommonalityRecord rec = new WeatherCommonalityRecord()
                    {
                        weather = wd
                    };
                    this.weatherCommonalityRecords.Add(this.CreateWeatherWidget(rec));
                    base.Def.baseWeatherCommonalities.Add(rec);
                },
                onRemove = delegate(WeatherDef wd)
                {
                    this.weatherCommonalityRecords.RemoveAll((FloatInputWidget <WeatherCommonalityRecord> w) => w.Parent.weather == wd);
                    base.Def.baseWeatherCommonalities.RemoveAll((WeatherCommonalityRecord rec) => rec.weather == wd);
                },
                getDisplayName = (WeatherDef def) => def.label,
            };

            this.terrainFertilityPlusMinusArgs = new PlusMinusArgs <TerrainDef>()
            {
                allItems  = DefDatabase <TerrainDef> .AllDefs,
                beingUsed = () => Util.ConvertItems(this.terrainsByFertility, (MinMaxInputWidget <TerrainThreshold, float> w) => w.Parent.terrain),
                onAdd     = delegate(TerrainDef td)
                {
                    TerrainThreshold tt = new TerrainThreshold()
                    {
                        terrain = td
                    };
                    this.terrainsByFertility.Add(this.CreateThresholdWidget(tt));
                    this.Def.terrainsByFertility.Add(tt);
                },
                onRemove = delegate(TerrainDef td)
                {
                    this.terrainsByFertility.RemoveAll((MinMaxInputWidget <TerrainThreshold, float> w) => w.Parent.terrain == td);
                    base.Def.terrainsByFertility.RemoveAll((TerrainThreshold tt) => tt.terrain == td);
                },
                getDisplayName = (TerrainDef def) => def.label,
            };

            this.ambientSoundPlusMinusArgs = new PlusMinusArgs <SoundDef>()
            {
                allItems  = DefDatabase <SoundDef> .AllDefs,
                beingUsed = () => this.soundsAmbient,
                onAdd     = delegate(SoundDef sd)
                {
                    this.soundsAmbient.Add(sd);
                    this.Def.soundsAmbient.Add(sd);
                },
                onRemove = delegate(SoundDef sd)
                {
                    this.soundsAmbient.Remove(sd);
                    this.Def.soundsAmbient.Remove(sd);
                },
                getDisplayName = (SoundDef sd) => sd.defName
            };

            this.diseasesPlusMinusArgs = new PlusMinusArgs <IncidentDef>()
            {
                allItems  = Util.FindAll(DefDatabase <IncidentDef> .AllDefs, id => id.defName.StartsWith("Disease_")),
                beingUsed = () => Util.ConvertItems(this.diseases, (FloatInputWidget <BiomeDiseaseRecord> w) => w.Parent.diseaseInc),
                onAdd     = delegate(IncidentDef id)
                {
                    BiomeDiseaseRecord r = new BiomeDiseaseRecord()
                    {
                        diseaseInc = id, commonality = 0
                    };
                    this.diseases.Add(this.CreateDiseaseWidget(r));
                    BiomeDefStats.GetDiseases(this.Def).Add(r);
                },
                onRemove = delegate(IncidentDef id)
                {
                    this.diseases.RemoveAll((FloatInputWidget <BiomeDiseaseRecord> w) => w.Parent.diseaseInc == id);
                    BiomeDefStats.GetDiseases(this.Def).RemoveAll((BiomeDiseaseRecord rec) => rec.diseaseInc == id);
                },
                getDisplayName = (IncidentDef def) => def.label,
            };

            this.wildPlantPlusMinusArgs = new PlusMinusArgs <ThingDef>()
            {
                allItems  = Util.FindAll(DefDatabase <ThingDef> .AllDefs, td => td.plant != null),
                beingUsed = () => Util.ConvertItems(this.wildPlants, (FloatInputWidget <BiomePlantRecord> w) => w.Parent.plant),
                onAdd     = delegate(ThingDef td)
                {
                    BiomePlantRecord r = new BiomePlantRecord()
                    {
                        plant = td, commonality = 0
                    };
                    this.wildPlants.Add(this.CreateWildPlantWidget(r));
                    BiomeDefStats.GetWildPlants(this.Def).Add(r);
                },
                onRemove = delegate(ThingDef td)
                {
                    this.wildPlants.RemoveAll((FloatInputWidget <BiomePlantRecord> w) => w.Parent.plant == td);
                    BiomeDefStats.GetWildPlants(this.Def).RemoveAll((BiomePlantRecord rec) => rec.plant == td);
                },
                getDisplayName = (ThingDef def) => def.label,
            };

            this.wildAnimalPlusMinusArgs = new PlusMinusArgs <PawnKindDef>()
            {
                allItems  = Util.FindAll(DefDatabase <PawnKindDef> .AllDefs, pdk => pdk.race.race.thinkTreeMain.defName.Equals("Animal")),
                beingUsed = () => Util.ConvertItems(this.wildAnimals, (FloatInputWidget <BiomeAnimalRecord> w) => w.Parent.animal),
                onAdd     = delegate(PawnKindDef td)
                {
                    BiomeAnimalRecord r = new BiomeAnimalRecord()
                    {
                        animal = td, commonality = 0
                    };
                    this.wildAnimals.Add(this.CreateWildAnimalWidget(r));
                    BiomeDefStats.GetWildAnimals(this.Def).Add(r);
                },
                onRemove = delegate(PawnKindDef td)
                {
                    this.wildAnimals.RemoveAll((FloatInputWidget <BiomeAnimalRecord> w) => w.Parent.animal == td);
                    BiomeDefStats.GetWildAnimals(this.Def).RemoveAll((BiomeAnimalRecord rec) => rec.animal == td);
                },
                getDisplayName = (PawnKindDef def) => def.label,
            };

            this.allowedPackAnimalsPlusMinusArgs = new PlusMinusArgs <ThingDef>()
            {
                allItems  = Util.FindAll(DefDatabase <ThingDef> .AllDefs, td => td.race != null && td.race.herdAnimal),
                beingUsed = () => this.allowedPackAnimals,
                onAdd     = delegate(ThingDef td)
                {
                    this.allowedPackAnimals.Add(td);
                    BiomeDefStats.GetAllowedPackAnimals(base.Def).Add(td);
                },
                onRemove = delegate(ThingDef td)
                {
                    this.allowedPackAnimals.Remove(td);
                    BiomeDefStats.GetAllowedPackAnimals(base.Def).Remove(td);
                },
                getDisplayName = (ThingDef def) => def.label,
            };

            this.Rebuild();
        }