private int ComputeGlobalNumberOfSites(PointOfInterestTemplate poiTemplate)
        {
            int num;

            if (!int.TryParse(poiTemplate.GetPropertyValue("NormalQuantity"), out num))
            {
                num = 1;
            }
            else if (num == 0)
            {
                return(0);
            }
            num *= this.AbundanceFactor * this.MapSizeFactor * this.CompetitionFactor;
            num /= 1000000;
            base.Trace(string.Format("{1} : normal number of sites : {0}", num, poiTemplate.GetPropertyValue("ResourceName")));
            if (base.Context.OceanicResourceCounts.ContainsKey(poiTemplate.GetPropertyValue("ResourceName")))
            {
                int num2 = base.Context.OceanicResourceCounts[poiTemplate.GetPropertyValue("ResourceName")];
                if (!base.Context.Settings.XephiStrategic)
                {
                    base.Trace(string.Format("removing {0} sites already moved to oceans", num2));
                    num -= num2;
                }
            }
            if (num < 1)
            {
                num = 1;
            }
            return(num);
        }
        private void PickResourceSite(PointOfInterestTemplate poiTemplate, List <PointOfInterestDefinition> createdPOIs, List <HexPos> availableSpots)
        {
            bool   flag          = false;
            int    num           = 20;
            string propertyValue = poiTemplate.GetPropertyValue("ResourceName");

            do
            {
                num--;
                HexPos hexPos = availableSpots.First <HexPos>();
                availableSpots.RemoveAt(0);
                Region region = base.Context.Regions[base.Context.RegionData[hexPos.Row, hexPos.Column]];
                PointOfInterestDefinition pointOfInterestDefinition = this.MakeNewPOI(hexPos, poiTemplate, 1);
                this.Influence.AddSpot(hexPos);
                if (pointOfInterestDefinition != null)
                {
                    createdPOIs.Add(pointOfInterestDefinition);
                    Dictionary <int, int> dictionary = this.CreatedSites[propertyValue];
                    int landMassIndex = region.LandMassIndex;
                    int num2          = dictionary[landMassIndex];
                    dictionary[landMassIndex] = num2 + 1;
                    region.Resources.Add(pointOfInterestDefinition);
                    flag = true;
                }
            }while (!flag && num > 0 && availableSpots.Count > 0);
        }
        public static int EstimatedGlobalNumberOfSites(WorldGeneratorContext context, WorldGeneratorSettings.AlgorithmParameters parameters, PointOfInterestTemplate poiTemplate)
        {
            int value  = parameters.GetValue("MapSizeSensitivity");
            int value2 = parameters.GetValue("EmpireCountSensitivity");
            int strategicResourcesAbundancePercent = context.Settings.StrategicResourcesAbundancePercent;

            if (strategicResourcesAbundancePercent <= 0)
            {
                return(0);
            }
            int num = (from d in context.Districts.Values
                       where d.Content == District.Contents.Land
                       select d).Sum((District d) => d.Count) / 20;
            int num2 = (num - 100) * value / 100;

            num = 100 + num2;
            int num3 = context.EmpiresCount * 25;

            num2 = (num3 - 100) * value2 / 100;
            num3 = 100 + num2;
            int num4;

            if (!int.TryParse(poiTemplate.GetPropertyValue("NormalQuantity"), out num4))
            {
                num4 = 1;
            }
            else if (num4 == 0)
            {
                return(0);
            }
            num4 *= strategicResourcesAbundancePercent * num * num3;
            num4 /= 1000000;
            if (context.OceanicResourceCounts != null && context.OceanicResourceCounts.ContainsKey(poiTemplate.GetPropertyValue("ResourceName")))
            {
                int num5 = context.OceanicResourceCounts[poiTemplate.GetPropertyValue("ResourceName")];
                num4 -= num5;
            }
            return(num4);
        }