protected void InitializeContinents() { this.Continents = new List <CreateContinents.Continent>(); this.CoreHexes = this.CoreBlobs.Sum((CreateContinents.Blob b) => b.Districts.Sum((District d) => d.Count)); int num = Math.Max(1, base.Context.Settings.LandPrevalence); int num2 = Math.Max(0, base.Context.Settings.OceanPrevalence); this.ExpectedLandHexes = this.CoreHexes * num / (num + num2); base.Trace(string.Format("Expected land hexes : {0}", this.ExpectedLandHexes)); this.ExpectedLandHexes = Math.Max(this.ExpectedLandHexes, this.MinRegionCount * base.Context.Settings.ExpectedRegionArea); base.Trace(string.Format("Expected land hexes : {0}", this.ExpectedLandHexes)); this.ExpectedLandHexes = Math.Min(this.ExpectedLandHexes, this.CoreHexes); base.Trace(string.Format("Expected land hexes : {0}", this.ExpectedLandHexes)); base.Context.Settings.ExpectedRegionArea = Math.Min(base.Context.Settings.ExpectedRegionArea, this.ExpectedLandHexes / this.MinRegionCount); if (num2 <= 0) { base.Context.IsOnlyLand = true; this.Continents.Add(new CreateContinents.Continent(this.BlobGraph)); foreach (CreateContinents.Blob blob in this.CoreBlobs) { blob.Content = District.Contents.Land; blob.Districts.ForEach(delegate(District d) { d.Content = District.Contents.Land; }); this.Continents.First <CreateContinents.Continent>().Blobs.Add(blob); } return; } int num3 = Math.Max(1, base.Context.CurrentRequestedLandMasses); num3 = Math.Min(num3, this.CoreBlobs.Count); for (int i = 1; i <= num3; i++) { CreateContinents.Continent item = new CreateContinents.Continent(this.BlobGraph); this.Continents.Add(item); } int num4 = 0; for (int j = Math.Max(base.Context.EmpiresCount, base.Context.CurrentRequestedLandMasses); j > 0; j--) { this.Continents[num4].MinArea += base.Context.Settings.ExpectedRegionArea; num4 = (num4 + 1) % this.Continents.Count; } this.Continents.ForEach(delegate(CreateContinents.Continent c) { c.MinArea = 9 * c.MinArea / 10; }); }
protected void MakeIslands(int islandSize, int keepPercent) { CreateContinents.< > c__DisplayClass14_0 CS$ < > 8__locals1 = new CreateContinents.< > c__DisplayClass14_0(); CS$ < > 8__locals1.< > 4__this = this; CreateContinents.< > c__DisplayClass14_0 CS$ < > 8__locals2 = CS$ < > 8__locals1; ProximityComputer <CreateContinents.Blob> proximityComputer = new ProximityComputer <CreateContinents.Blob>(this.BlobGraph); proximityComputer.StartingNodes = new List <CreateContinents.Blob>(from c in this.Continents from b in c.Blobs select b); CS$ < > 8__locals2.proxer = proximityComputer; CS$ < > 8__locals1.proxer.Execute(); CS$ < > 8__locals1.potentialIslands = new List <CreateContinents.Blob>(from b in this.CoreBlobs where CS$ < > 8__locals1.proxer.Proximity(b) > 1 select b); List <CreateContinents.Blob> list = new List <CreateContinents.Blob>(); while (CS$ < > 8__locals1.potentialIslands.Count > 0 && this.Continents.Count < 254) { List <CreateContinents.Blob> island = new List <CreateContinents.Blob>(); CreateContinents.Blob blob = CS$ < > 8__locals1.potentialIslands.ElementAt(base.Context.Randomizer.Next(CS$ < > 8__locals1.potentialIslands.Count)); CS$ < > 8__locals1.potentialIslands.Remove(blob); island.Add(blob); list.Clear(); List <CreateContinents.Blob> list2 = list; IEnumerable <CreateContinents.Blob> source = this.BlobGraph.Adjacents(blob); Func <CreateContinents.Blob, bool> predicate; if ((predicate = CS$ < > 8__locals1.< > 9__3) == null) { predicate = (CS$ < > 8__locals1.< > 9__3 = ((CreateContinents.Blob n) => CS$ < > 8__locals1.potentialIslands.Contains(n))); } list2.AddRange(source.Where(predicate)); while (list.Count > 0) { if (island.Sum((CreateContinents.Blob b) => b.Districts.Sum((District d) => d.Count)) >= islandSize) { break; } CreateContinents.Blob item = list.ElementAt(base.Context.Randomizer.Next(list.Count)); island.Add(item); CS$ < > 8__locals1.potentialIslands.Remove(item); list.Clear(); List <CreateContinents.Blob> list3 = list; var source2 = from b in island from n in this.BlobGraph.Adjacents(b) select new { b, n }; var predicate2; if ((predicate2 = CS$ < > 8__locals1.< > 9__6) == null) { predicate2 = (CS$ < > 8__locals1.< > 9__6 = (< > h__TransparentIdentifier0 => CS$ < > 8__locals1.potentialIslands.Contains(< > h__TransparentIdentifier0.n))); } list3.AddRange(from <> h__TransparentIdentifier0 in source2.Where(predicate2) select <> h__TransparentIdentifier0.n); } if (island.Count > 0) { if (island.Sum((CreateContinents.Blob b) => b.Districts.Sum((District d) => d.Count)) < 3 * islandSize) { if (island.Sum((CreateContinents.Blob b) => b.Districts.Sum((District d) => d.Count)) > islandSize && base.Context.Randomizer.Next(100) < keepPercent) { CreateContinents.Continent continent = new CreateContinents.Continent(this.BlobGraph); this.Continents.Add(continent); island.ForEach(delegate(CreateContinents.Blob b) { b.Content = District.Contents.Land; }); island.ForEach(delegate(CreateContinents.Blob b) { b.Districts.ForEach(delegate(District d) { d.Content = District.Contents.Land; }); }); continent.Blobs.UnionWith(island); Func <CreateContinents.Blob, bool> < > 9__18; CS$ < > 8__locals1.potentialIslands.RemoveAll(delegate(CreateContinents.Blob b) { IEnumerable <CreateContinents.Blob> source3 = CS$ < > 8__locals1.< > 4__this.BlobGraph.Adjacents(b); Func <CreateContinents.Blob, bool> predicate3; if ((predicate3 = < > 9__18) == null) { predicate3 = (< > 9__18 = ((CreateContinents.Blob n) => island.Contains(n))); } return(source3.Any(predicate3)); }); } } } } }
protected void GrowSmoothLandMasses(WorldGeneratorSettings.ContinentStyles shaping, WorldGeneratorSettings.ContinentStyles spreading) { this.AvailableBlobs = new HashSet <CreateContinents.Blob>(this.CoreBlobs); this.Influencer = new IncrementalInfluencer <CreateContinents.Blob>(this.BlobGraph); List <CreateContinents.Blob> list = new List <CreateContinents.Blob>(this.AvailableBlobs); Dictionary <CreateContinents.Continent, Dictionary <CreateContinents.Blob, int> > valuations = new Dictionary <CreateContinents.Continent, Dictionary <CreateContinents.Blob, int> >(); foreach (CreateContinents.Continent continent in this.Continents) { CreateContinents.Blob blob3 = null; if (spreading == WorldGeneratorSettings.ContinentStyles.Regular) { List <CreateContinents.Blob> list2 = this.Influencer.FarthestNodes(); blob3 = list2.ElementAt(base.Context.Randomizer.Next(list2.Count)); this.Influencer.Add(blob3); } else if (list.Count > 0) { blob3 = list.ElementAt(base.Context.Randomizer.Next(list.Count)); } if (!base.Context.Settings.WorldWrap && this.Continents.Count == 1) { HexPos mapCenter = new HexPos(base.Context.Grid.Columns / 2, base.Context.Grid.Rows / 2); Func <District, bool> < > 9__1; blob3 = this.CoreBlobs.Find(delegate(CreateContinents.Blob b) { IEnumerable <District> districts = b.Districts; Func <District, bool> predicate; if ((predicate = < > 9__1) == null) { predicate = (< > 9__1 = ((District d) => d.Contains(mapCenter))); } return(districts.Any(predicate)); }); } if (blob3 != null) { this.AvailableBlobs.Remove(blob3); continent.Blobs.Add(blob3); list.Remove(blob3); foreach (CreateContinents.Blob item in this.BlobGraph.Adjacents(blob3)) { list.Remove(item); } valuations.Add(continent, new Dictionary <CreateContinents.Blob, int>()); continent.ProxBlober.StartingNodes.Add(blob3); continent.ProxBlober.Execute(); continent.ComputeInfluence(); } } foreach (CreateContinents.Continent continent2 in this.Continents) { Dictionary <CreateContinents.Blob, int> dictionary = valuations[continent2]; List <CreateContinents.Continent> list3 = new List <CreateContinents.Continent>(this.Continents); list3.Remove(continent2); using (HashSet <CreateContinents.Blob> .Enumerator enumerator3 = this.AvailableBlobs.GetEnumerator()) { while (enumerator3.MoveNext()) { CreateContinents.Blob blob = enumerator3.Current; if (list3.Count > 0) { dictionary.Add(blob, list3.Min((CreateContinents.Continent k) => k.ProxBlober.Proximity(blob))); } else { dictionary.Add(blob, 0); } Dictionary <CreateContinents.Blob, int> dictionary2 = dictionary; CreateContinents.Blob blob2 = blob; dictionary2[blob2] -= continent2.ProxBlober.Proximity(blob); if (shaping == WorldGeneratorSettings.ContinentStyles.Chaotic) { dictionary2 = dictionary; blob2 = blob; dictionary2[blob2] += base.Context.Randomizer.Next(8) - base.Context.Randomizer.Next(8); } } } } bool flag = true; for (;;) { if (this.Continents.Sum((CreateContinents.Continent k) => k.HexCount) >= this.ExpectedLandHexes || !flag) { break; } flag = false; List <CreateContinents.Continent> source = new List <CreateContinents.Continent>(from k in this.Continents orderby k.WeightedHexCount select k); CreateContinents.Continent smallest = source.First <CreateContinents.Continent>(); List <CreateContinents.Continent> others = new List <CreateContinents.Continent>(this.Continents); others.Remove(smallest); List <CreateContinents.Blob> list4 = new List <CreateContinents.Blob>(from b in this.AvailableBlobs where b.Neighbours.Any((CreateContinents.Blob n) => smallest.Blobs.Contains(n)) where !others.Any((CreateContinents.Continent k) => k.Influence.Contains(b)) orderby valuations[smallest][b] descending select b); if (list4.Count > 0) { flag = true; CreateContinents.Blob item2 = list4.First <CreateContinents.Blob>(); smallest.Blobs.Add(item2); this.AvailableBlobs.Remove(item2); smallest.ComputeInfluence(); } } }