9 public bool CrawlUntil(
Map map, Func<Point> onStart,
int tries, Func<Crawler.Result, bool> canComplete, Action onFail =
null)
15 for (
int i = 0; i < tries; i++)
18 for (
int j = 0; j < 100; j++)
20 Point point = onStart();
21 Crawler.StartType startType = this.startType;
22 if (startType !=
Crawler.StartType.Surface)
24 if (startType ==
Crawler.StartType.Block)
26 if (point.sourceBlock.tileType.IsFullBlock && point.Installed ==
null)
32 else if (!point.HasBlock)
44 Debug.Log(
"CrawlUntil Complete:" + i.ToString());
52 Debug.Log(
"CrawlUntil Fail" + tries.ToString());
62 public void Crawl(
Map map)
65 while ((
float)num < map.sizeModifier * (
float)
this.repeat + 1f)
67 this.Crawl(map, map.GetRandomSurface(
false,
true,
false), delegate(
Point p)
69 p.cell.biome.Populate(p,
false);
78 if (this.members.Count == 0)
80 for (
int i = 0; i < this.member; i++)
85 Point point = _start.Copy();
91 int num = this.skipBorder ? 2 : 0;
92 int num2 = this.skipBorder ? (this.Size - 2) : this.Size;
93 if (
Crawler.mapping.Length !=
this.Size)
95 Crawler.mapping =
new int[map.Size, map.Size];
99 member.pos.Set(point);
100 member.life = this.life;
102 for (
int j = 0; j < this.life; j++)
104 for (
int k = 0; k < this.members.Count; k++)
109 int num5 = member2.pos.x + num3;
110 int num6 = member2.pos.z + num4;
111 if (point.Distance(num5, num6) <=
this.radius && num5 >= num && num6 >= num && num5 < num2 && num6 < num2)
113 Cell cell = map.cells[num5, num6];
114 if (!this.stickToStartBiome || !(cell.biome != biome))
116 Crawler.MoveType moveType = this.moveType;
117 if (moveType !=
Crawler.MoveType.Surface)
119 if (moveType ==
Crawler.MoveType.Block)
121 if (cell._block == 0 || !cell.sourceBlock.tileType.IsFullBlock || cell.Installed !=
null)
129 if (cell._block != 0)
138 member2.pos.Set(num5, num6);
142 Point point2 = member2.pos.Copy();
143 result.points.Add(point2);
144 if (onNewVisit !=
null)
158 public static Crawler Create(
string id)
160 return ResourceCache.Load<
Crawler>(
"World/Map/Crawler/crawler " + id);
164 public static int[,] mapping =
new int[0, 0];
167 public static int sync;
182 public bool stickToStartBiome;
185 public bool skipBorder;
188 public Crawler.StartType startType;
191 public Crawler.MoveType moveType;
215 public List<Point> points =
new List<Point>();
228 public enum StartType