public void IterateFillPattern() { if (DoneFillPatterns) { return; } //Get the current node. PositionalNode n = NeedToApply.Current; //If it is a junction, ignore it for now. //FilledRegions covering junctions/tunnels will be // added after fill patterns are applied to rooms. if (NodeStates[n] == NodeState.TunnelJunction) { DoneFillPatterns = !NeedToApply.MoveNext(); return; } //Get the best fill pattern for it and apply it if one exists. FillPattern p = Settings.MostSuitable(NodeAreas[n]); FilledRegion tempF; if (p != null) { FillData.BeingFilled = NodeAreas[n]; tempF = p.Apply(FillData); //If the area has no team spawns, add one at the top. if (tempF.PotentialSpawns[Spawns.Team].Count == 0 && tempF.Covering.Width + 1 >= 4) { tempF.PotentialSpawns[Spawns.Team].Add(new Region(tempF.Covering.Left, tempF.Covering.Top, tempF.Covering.Width, 0)); } FilledRegions.Add(tempF); } else { FilledRegions.Add(new NoRegion(NodeAreas[n])); } //Continue the iteration. DoneFillPatterns = !NeedToApply.MoveNext(); }
public void IterateFillPattern() { //Already done? if (iterateFillPatternsRegionCount >= Regions.Count) { return; } //Run an iteration. FilledRegion temp; Region r = Regions[iterateFillPatternsRegionCount]; iterateFillPatternsRegionCount++; //Pick a random applicable pattern (assuming one exists) and apply it. FillPattern p = Settings.MostSuitable(r); if (p != null) { //Clear the space, and apply the pattern. FillData.BeingFilled = r; FillData.FillRegion(false, r); temp = p.Apply(FillData); //If the filled region is blank, replace it with a BlankRegion. bool blank = true; for (int i = temp.Covering.Left; i <= temp.Covering.Right; ++i) { for (int j = temp.Covering.Top; j <= temp.Covering.Bottom; ++j) { if (FillData.GetMapAt(new Location(i, j))) { blank = false; break; } } if (!blank) { break; } } if (blank) { temp = new BlankRegion(temp.Covering); } //Now add it. FilledRegions.Add(temp); Region r2; //Make sure the spawn points are all valid. foreach (Spawns s in FilledRegions[FilledRegions.Count - 1].PotentialSpawns.Keys) { for (int i = 0; i < FilledRegions[FilledRegions.Count - 1].PotentialSpawns[s].Count; ++i) { r2 = FilledRegions[FilledRegions.Count - 1].PotentialSpawns[s][i]; if (r2.Width < 0 || r2.Height < 0) { FilledRegions[FilledRegions.Count - 1].PotentialSpawns[s].RemoveAt(i--); } } } } //If no regions fit, add a "NoRegion". else { FilledRegions.Add(new NoRegion(r)); } }