Exemplo n.º 1
0
        internal static float _CommonalityOfAnimal(this BiomeDef _this, PawnKindDef animalDef)
        {
            var cachedAnimalCommonalities = _this.cachedAnimalCommonalities();

            if (cachedAnimalCommonalities == null)
            {
                cachedAnimalCommonalities = new Dictionary <PawnKindDef, float>();
                for (int index = 0; index < _this.wildAnimals().Count; ++index)
                {
                    cachedAnimalCommonalities.Add(_this.wildAnimals()[index].animal, _this.wildAnimals()[index].commonality);
                }
                foreach (PawnKindDef current in DefDatabase <PawnKindDef> .AllDefs)
                {
                    if (current.RaceProps.wildBiomes != null)
                    {
                        for (int index = 0; index < current.RaceProps.wildBiomes.Count; ++index)
                        {
                            if (current.RaceProps.wildBiomes[index].biome.defName == _this.defName)
                            {
                                cachedAnimalCommonalities.Add(current.RaceProps.wildBiomes[index].animal, current.RaceProps.wildBiomes[index].commonality);
                            }
                        }
                    }
                }
                _this.cachedAnimalCommonalitiesSet(cachedAnimalCommonalities);
            }
            float num;

            if (cachedAnimalCommonalities.TryGetValue(animalDef, out num))
            {
                return(num);
            }
            return(0.0f);
        }