Elin Modding Docs Doc
Loading...
Searching...
No Matches
MapGen.cs
1using System;
2using System.Collections.Generic;
3using System.Runtime.CompilerServices;
4using UnityEngine;
5
6// Token: 0x0200066C RID: 1644
7public class MapGen : BaseMapGen
8{
9 // Token: 0x17000D14 RID: 3348
10 // (get) Token: 0x06002E12 RID: 11794 RVA: 0x00101BA0 File Offset: 0x000FFDA0
11 public static MapGen Instance
12 {
13 get
14 {
15 MapGen result;
16 if ((result = MapGen._Instance) == null)
17 {
18 result = (MapGen._Instance = new MapGen());
19 }
20 return result;
21 }
22 }
23
24 // Token: 0x06002E13 RID: 11795 RVA: 0x00101BB8 File Offset: 0x000FFDB8
25 protected override void GenerateTerrain()
26 {
27 base.SetSize(this.zp.useRootSize ? this.zone.GetTopZone().bounds.Size : this.zp.size, 10);
28 if (this.biomes == null || this.Size != this.biomes.GetLength(0))
29 {
30 this.biomes = new BiomeProfile[this.Size, this.Size];
31 this.subBiomes = new bool[this.Size, this.Size];
32 this.heights1 = new float[this.Size, this.Size];
33 this.heights2 = new float[this.Size, this.Size];
34 this.heights3 = new float[this.Size, this.Size];
35 this.waters = new float[this.Size, this.Size];
36 this.heights3d = new float[this.Size, this.Size];
37 this.lastSize = this.Size;
38 }
39 this.map.biomes = this.biomes;
40 this.layerHeight.SaveSettings();
41 this.layerStratum.SaveSettings();
42 this.layerBiome.SaveSettings();
43 this.layerRiver.SaveSettings();
44 this.layerBiome.SaveSettings();
45 this.skipWater = (this.zp.noWater || (this.bp.tileCenter != null && (this.bp.tileCenter.IsNeighborRoad || this.bp.tileCenter.isRoad)));
46 for (int i = 0; i < 100; i++)
47 {
48 this.seed = (this.map.seed = this.bp.genSetting.seed + i);
49 Rand.SetSeed(this.seed);
50 if (this.OnGenerateTerrain())
51 {
52 break;
53 }
54 Debug.Log("Failed map generation:" + i.ToString() + " / " + BaseMapGen.err);
55 this.skipWater = true;
56 }
57 this.map.SetZone(EClass._zone);
58 for (int j = 0; j < this.Size; j++)
59 {
60 for (int k = 0; k < this.Size; k++)
61 {
62 this.map.QuickRefreshTile(j, k);
63 }
64 }
65 Rand.SetSeed(-1);
66 }
67
68 // Token: 0x06002E14 RID: 11796 RVA: 0x00101E10 File Offset: 0x00100010
69 protected override bool OnGenerateTerrain()
70 {
71 int idMat = 66;
72 if (this.map.isGenerated)
73 {
74 if (this.map.Size != this.Size)
75 {
76 this.map.Resize(this.Size);
77 }
78 this.map.Reset();
79 }
80 else
81 {
82 this.map.CreateNew(this.Size, true);
83 }
84 this.map.poiMap.Reset();
85 if (this.bp.zoneProfile.useRootSize)
86 {
87 this.map.SetBounds(this.zone.GetTopZone().bounds);
88 }
89 else
90 {
91 this.map.SetBounds((this.bp.zoneProfile.sizeBounds == 0) ? EClass.setting.defaultMapSize : this.bp.zoneProfile.sizeBounds);
92 }
93 ZoneProfile.GenType genType = this.zp.genType;
94 if (genType != ZoneProfile.GenType.Sky)
95 {
96 if (genType == ZoneProfile.GenType.Underground)
97 {
98 this.map.config.idBiome = "Underground";
99 this.zone._biome = null;
100 }
101 this.waterCount = 0f;
102 if (!this.skipWater)
103 {
104 float num = (float)(this.Size * this.Size) * this.variation.maxWaterRatio;
105 this.layerRiver.FillHeightMap(this.waters, this.OX, 0, this.OZ, this.Size, this.Size, this.seed, 1f);
106 for (int i = 0; i < this.Size; i++)
107 {
108 for (int j = 0; j < this.Size; j++)
109 {
110 this.waters[i, j] += (float)this.zp.water;
111 if (this.waters[i, j] > 0f)
112 {
113 this.waterCount += 1f;
114 }
115 }
116 if (this.waterCount > num)
117 {
118 BaseMapGen.err = "Too many water";
119 return false;
120 }
121 }
122 }
123 this.layerBiome.FillHeightMap(this.heights1, this.OX, 0, this.OZ, this.Size, this.Size, this.zp.seeds.biome, 1f);
124 this.layerBiome.FillHeightMap(this.heights2, this.OX, 0, this.OZ, this.Size, this.Size, this.zp.seeds.biome + 1, 1f);
125 if (base.extraBiome)
126 {
127 this.layerBiome.FillHeightMap(this.heights3, this.OX, 0, this.OZ, this.Size, this.Size, this.zp.seeds.biome + 2, 1f);
128 }
129 for (int k = 0; k < this.Size; k++)
130 {
131 for (int l = 0; l < this.Size; l++)
132 {
133 if (this.heights1[k, l] != 0f)
134 {
135 this.biomes[k, l] = this.biomeProfiles[1];
136 }
137 else if (this.heights2[k, l] != 0f)
138 {
139 this.biomes[k, l] = this.biomeProfiles[2];
140 }
141 else if (base.extraBiome && this.heights3[k, l] != 0f)
142 {
143 this.biomes[k, l] = this.biomeProfiles[3];
144 }
145 else
146 {
147 this.biomes[k, l] = this.biomeProfiles[0];
148 }
149 }
150 }
151 this.layerBiome.FillHeightMap(this.heights1, this.OX, 0, this.OZ, this.Size, this.Size, this.zp.seeds.biomeSub, this.zp.biomeSubScale);
152 for (int m = 0; m < this.Size; m++)
153 {
154 for (int n = 0; n < this.Size; n++)
155 {
156 this.subBiomes[m, n] = (this.heights1[m, n] != 0f);
157 }
158 }
159 this.layerBiome.FillHeightMap(this.heights1, this.OX, 0, this.OZ, this.Size, this.Size, this.zp.seeds.biome, 1f);
160 for (int num2 = 0; num2 < this.biomeProfiles.Length; num2++)
161 {
162 if (num2 == 0 || !(this.biomeProfiles[num2 - 1] == this.biomeProfiles[num2]))
163 {
164 this.biomeProfiles[num2].layerBlock.FillHeightMap(this.heights1, this.OX, 0, this.OZ, this.Size, this.Size, this.zp.seeds.biome, 1f);
165 bool flag = EClass.sources.floors.rows[this.biomeProfiles[num2].exterior.floor.id].tag.Contains("soil");
166 for (int num3 = 0; num3 < this.Size; num3++)
167 {
168 if (!this.zp.clearEdge || ((num3 <= this.map.bounds.x - 4 || num3 > this.map.bounds.x + 4) && (num3 <= this.map.bounds.maxX - 4 || num3 > this.map.bounds.maxX + 4)))
169 {
170 for (int num4 = 0; num4 < this.Size; num4++)
171 {
172 if ((!this.zp.clearEdge || ((num4 <= this.map.bounds.z - 4 || num4 > this.map.bounds.z + 4) && (num4 <= this.map.bounds.maxZ - 4 || num4 > this.map.bounds.maxZ + 4))) && !(this.biomes[num3, num4] != this.biomeProfiles[num2]) && this.heights1[num3, num4] > (float)this.blockHeight)
173 {
174 SourceBlock.Row row = EClass.sources.blocks.rows[this.biomeProfiles[num2].exterior.block.id];
175 if (!flag || row.alias == "block_ice")
176 {
177 SourceFloor.Row row2 = EClass.sources.floors.alias[row.autoFloor];
178 base.SetFloor(num3, num4, row2.DefaultMaterial.id, row2.id, 0);
179 }
180 base.SetBlock(num3, num4, this.biomeProfiles[num2].exterior.block.mat, this.biomeProfiles[num2].exterior.block.id, 0);
181 }
182 }
183 }
184 }
185 }
186 }
187 bool flag2 = false;
188 for (int num5 = this.Size / 2 - 4; num5 < this.Size / 2 + 4; num5++)
189 {
190 for (int num6 = this.Size / 2 - 4; num6 < this.Size / 2 + 4; num6++)
191 {
192 if (num5 >= 0 && num6 >= 0 && num5 < this.Size && num6 < this.Size && this.map.cells[num5, num6]._block != 0)
193 {
194 flag2 = true;
195 break;
196 }
197 }
198 }
199 if (flag2)
200 {
201 for (int num7 = 0; num7 < this.Size; num7++)
202 {
203 for (int num8 = 0; num8 < this.Size; num8++)
204 {
205 base.SetBlock(num7, num8, 0, 0, 0);
206 }
207 }
208 }
209 this.layerHeight.FillHeightMap(this.heights1, this.OX, 0, this.OZ, this.Size, this.Size, this.seed, 1f);
210 this.layerHeight.FillHeightMap(this.heights2, this.OX, 0, this.OZ, this.Size, this.Size, this.zp.seeds.bush, 1f);
211 this.layerHeight.FillHeightMap(this.heights3, this.OX, 0, this.OZ, this.Size, this.Size, this.seed + 1, 1f);
212 BiomeProfile biomeWater = this.biomeWater;
213 byte b = (byte)EClass.setting.maxGenHeight;
214 for (int num9 = 0; num9 < this.Size; num9++)
215 {
216 for (int num10 = 0; num10 < this.Size; num10++)
217 {
218 int num11 = (int)this.heights1[num9, num10];
219 Cell cell = this.map.cells[num9, num10];
220 if (cell._block == 0 || cell._floor == 0)
221 {
222 BiomeProfile biomeProfile = this.biomes[num9, num10];
223 SourceMaterial.Row row3 = this.subBiomes[num9, num10] ? biomeProfile.MatSub : biomeProfile.MatFloor;
224 int dir = biomeProfile.exterior.floor.GetDir();
225 byte b2 = (byte)(this.heights1[num9, num10] * (float)this.hSetting.heightMod + (float)this.hSetting.baseHeight);
226 if (this.hSetting.step > 0)
227 {
228 b2 = (byte)((int)b2 / this.hSetting.step * this.hSetting.step);
229 }
230 if (b2 > b)
231 {
232 b2 = b;
233 }
234 cell.height = b2;
235 if (!this.skipWater && this.waters[num9, num10] > 0f && cell._block == 0)
236 {
237 cell.height = 0;
238 if (biomeWater)
239 {
240 bool flag3 = false;
241 for (int num12 = num10 - 2; num12 < num10 + 3; num12++)
242 {
243 for (int num13 = num9 - 2; num13 < num9 + 3; num13++)
244 {
245 if (num12 >= 0 && num13 >= 0 && num13 < this.Size && num12 < this.Size && this.waters[num13, num12] <= 0f)
246 {
247 flag3 = true;
248 break;
249 }
250 }
251 }
252 base.SetFloor(num9, num10, this.biomeWater.MatFloor.id, flag3 ? 44 : 43, 0);
253 }
254 else
255 {
256 base.SetFloor(num9, num10, idMat, (this.waters[num9, num10] < 5f) ? 44 : 43, 0);
257 }
258 }
259 else if (this.zp.shoreHeight > 0f && (float)num11 < this.zp.shoreHeight)
260 {
261 base.SetFloor(num9, num10, this.biomeShore.MatFloor.id, this.biomeShore.MatFloor.defFloor, 0);
262 this.biomes[num9, num10] = this.biomeShore;
263 }
264 else if (biomeProfile.floor_height != 0 && (int)this.heights2[num9, num10] + this.zp.bushMod >= 4)
265 {
266 base.SetFloor(num9, num10, (int)((byte)row3.id), biomeProfile.floor_height, dir);
267 }
268 else
269 {
270 base.SetFloor(num9, num10, (int)((byte)row3.id), (biomeProfile.exterior.floor.id != 0) ? biomeProfile.exterior.floor.id : row3.defFloor, dir);
271 }
272 }
273 }
274 }
275 if (this.hSetting.heightMod > 0)
276 {
277 this.ModifyHeight(this.map);
278 }
279 this.MakeNeighbor();
280 for (int num14 = 0; num14 < this.Size; num14++)
281 {
282 for (int num15 = 0; num15 < this.Size; num15++)
283 {
284 Cell cell2 = this.map.cells[num14, num15];
285 if (this.zp.setShore && !cell2.HasBlock && !cell2.IsTopWater && cell2.height <= 20)
286 {
287 bool flag4 = false;
288 for (int num16 = num14 - 1; num16 < num14 + 2; num16++)
289 {
290 if (num16 >= 0 && num16 < this.Size)
291 {
292 for (int num17 = num15 - 1; num17 < num15 + 2; num17++)
293 {
294 if (num17 >= 0 && num17 < this.Size && (num16 != num14 || num17 != num15) && this.map.cells[num16, num17].IsTopWater)
295 {
296 flag4 = true;
297 break;
298 }
299 }
300 if (flag4)
301 {
302 break;
303 }
304 }
305 }
306 if (flag4)
307 {
308 base.SetFloor(num14, num15, this.biomeShore.MatFloor.id, this.biomeShore.MatFloor.defFloor, 0);
309 this.biomes[num14, num15] = this.biomeShore;
310 if (this.zp.extraShores > 0)
311 {
312 int extraShores = this.zp.extraShores;
313 for (int num18 = num14 - extraShores; num18 < num14 + extraShores + 1; num18++)
314 {
315 if (num18 >= 0 && num18 < this.Size)
316 {
317 for (int num19 = num15 - extraShores; num19 < num15 + extraShores + 1; num19++)
318 {
319 if (num19 >= 0 && num19 < this.Size && !(this.biomes[num18, num19] == this.biomeShore) && !this.map.cells[num18, num19].IsTopWater && !this.map.cells[num18, num19].HasBlock)
320 {
321 base.SetFloor(num18, num19, this.biomeShore.MatFloor.id, this.biomeShore.MatFloor.defFloor, 0);
322 this.biomes[num18, num19] = this.biomeShore;
323 }
324 }
325 }
326 }
327 }
328 }
329 }
330 }
331 }
332 return true;
333 }
334 this.map.config.idBiome = "Sky";
335 this.zone._biome = null;
336 for (int num20 = 0; num20 < this.Size; num20++)
337 {
338 for (int num21 = 0; num21 < this.Size; num21++)
339 {
340 base.SetFloor(num20, num21, 0, 90, 0);
341 }
342 }
343 return true;
344 }
345
346 // Token: 0x06002E15 RID: 11797 RVA: 0x00102CD0 File Offset: 0x00100ED0
347 public void MakeNeighbor()
348 {
349 MapGen.<>c__DisplayClass5_0 CS$<>8__locals1;
350 CS$<>8__locals1.<>4__this = this;
351 if (this.bp.surrounding == null)
352 {
353 return;
354 }
355 CS$<>8__locals1.thisInfo = this.bp.surrounding[1, 1];
356 CS$<>8__locals1.seaDir = (CS$<>8__locals1.thisInfo.sea ? (1 + EClass.rnd(4)) : 0);
357 this.<MakeNeighbor>g___MakeNeighbor|5_0(this.bp.surrounding[1, 2], this.Size / 3 + 7, new Point(0, this.Size - 1), 0, -1, 3, 1, ref CS$<>8__locals1);
358 this.<MakeNeighbor>g___MakeNeighbor|5_0(this.bp.surrounding[1, 0], this.Size / 3 + 7, new Point(0, 0), 0, 1, 1, 3, ref CS$<>8__locals1);
359 this.<MakeNeighbor>g___MakeNeighbor|5_0(this.bp.surrounding[2, 1], this.Size / 3 + 7, new Point(this.Size - 1, 0), -1, 0, 2, 4, ref CS$<>8__locals1);
360 this.<MakeNeighbor>g___MakeNeighbor|5_0(this.bp.surrounding[0, 1], this.Size / 3 + 7, new Point(0, 0), 1, 0, 4, 2, ref CS$<>8__locals1);
361 EClass._map.config.seaDir = CS$<>8__locals1.seaDir;
362 }
363
364 // Token: 0x06002E16 RID: 11798 RVA: 0x00102E0C File Offset: 0x0010100C
365 public void MakeNeighbor_old()
366 {
367 if (this.bp.surrounding == null)
368 {
369 return;
370 }
371 this.<MakeNeighbor_old>g___MakeNeighbor|6_0(this.bp.surrounding[1, 2], new Point(this.Size / 2, this.Size / 3 * 2 - 5), 0, 1);
372 this.<MakeNeighbor_old>g___MakeNeighbor|6_0(this.bp.surrounding[1, 0], new Point(this.Size / 2, this.Size / 3 + 6), 0, -1);
373 this.<MakeNeighbor_old>g___MakeNeighbor|6_0(this.bp.surrounding[2, 1], new Point(this.Size / 3 * 2 - 5, this.Size / 2), 1, 0);
374 this.<MakeNeighbor_old>g___MakeNeighbor|6_0(this.bp.surrounding[0, 1], new Point(this.Size / 3 + 6, this.Size / 2), -1, 0);
375 }
376
377 // Token: 0x06002E17 RID: 11799 RVA: 0x00102EF0 File Offset: 0x001010F0
378 public void MakeRoad()
379 {
380 if (this.bp.tileCenter == null || this.bp.ignoreRoad)
381 {
382 return;
383 }
384 EloMap.TileInfo tileCenter = this.bp.tileCenter;
385 if (tileCenter.roadLeft)
386 {
387 this.<MakeRoad>g___MakeRoad|7_0(-1, 0);
388 }
389 if (tileCenter.roadRight)
390 {
391 this.<MakeRoad>g___MakeRoad|7_0(1, 0);
392 }
393 if (tileCenter.roadUp)
394 {
395 this.<MakeRoad>g___MakeRoad|7_0(0, 1);
396 }
397 if (tileCenter.roadDown)
398 {
399 this.<MakeRoad>g___MakeRoad|7_0(0, -1);
400 }
401 }
402
403 // Token: 0x06002E18 RID: 11800 RVA: 0x00102F64 File Offset: 0x00101164
404 public void ModifyHeight(Map _map)
405 {
406 this.map = _map;
407 Cell[,] cells = this.map.cells;
408 bool flag = false;
409 for (int i = this.Size - 1; i > 0; i--)
410 {
411 for (int j = 0; j < this.Size - 1; j++)
412 {
413 Cell cell = cells[i, j];
414 byte height = cell.height;
415 Cell cell2 = cells[i - 1, j];
416 Cell cell3 = cells[i, j + 1];
417 if (!cell2.IsTopWater && !cell3.IsTopWater)
418 {
419 if (EClass.rnd(500) == 0)
420 {
421 flag = !flag;
422 }
423 if (EClass.rnd(3) == 0)
424 {
425 if (flag)
426 {
427 cell2.height = height;
428 }
429 else
430 {
431 cell3.height = height;
432 }
433 }
434 if (this.hSetting.smoothDownhill && EClass.rnd(3) == 0)
435 {
436 if (cell2.height < height - 2)
437 {
438 cell2.height = height - 2;
439 }
440 if (cell3.height < height - 2)
441 {
442 cell3.height = height - 2;
443 }
444 }
445 else
446 {
447 if (this.hSetting.mod1 && (cell2.height >= height - 1 || cell3.height >= height - 1))
448 {
449 if (EClass.rnd(4) == 0 && height != 0)
450 {
451 cell2.height = (cell3.height = height);
452 }
453 else
454 {
455 cell.height = (cell2.height = cell3.height);
456 }
457 }
458 if (this.hSetting.mod2 && (cell2.height < height - 1 || cell3.height < height - 1))
459 {
460 if (EClass.rnd(2) == 0)
461 {
462 cell2.height = (cell3.height = height);
463 }
464 else
465 {
466 cells[i, j].height = (cell2.height = cell3.height);
467 }
468 }
469 if (this.hSetting.mod3 && (cell2.height >= height - 1 || cell3.height >= height - 1))
470 {
471 if (EClass.rnd(2) == 0)
472 {
473 cell2.height = (cell3.height = height);
474 }
475 else
476 {
477 cells[i, j].height = (cell2.height = cell3.height);
478 }
479 }
480 }
481 }
482 }
483 }
484 if (this.hSetting.smoothDownhill)
485 {
486 for (int k = this.Size - 1; k > 0; k--)
487 {
488 for (int l = 0; l < this.Size - 1; l++)
489 {
490 byte height2 = cells[k, l].height;
491 Cell cell4 = cells[k - 1, l];
492 Cell cell5 = cells[k, l + 1];
493 if (height2 != 0)
494 {
495 if (cell4.height < height2 - 2 && !cell4.IsTopWater)
496 {
497 cell4.height = height2 - 2;
498 }
499 if (cell5.height < height2 - 2 && !cell5.IsTopWater)
500 {
501 cell5.height = height2 - 2;
502 }
503 }
504 }
505 }
506 }
507 }
508
509 // Token: 0x06002E19 RID: 11801 RVA: 0x00103268 File Offset: 0x00101468
510 public void MakeRiver(Map _map)
511 {
512 int num = 0;
513 for (int i = 0; i < 100; i++)
514 {
515 Point point = null;
516 Point point2 = null;
517 for (int j = 0; j < 1000; j++)
518 {
519 point = _map.GetRandomEdge(1);
520 if (!point.cell.blocked)
521 {
522 break;
523 }
524 }
525 for (int k = 0; k < 1000; k++)
526 {
527 point2 = _map.GetRandomEdge(1);
528 if (point.x != point2.x && point.z != point2.z && !point2.cell.blocked && point.Distance(point2) >= _map.Size / 2)
529 {
530 break;
531 }
532 }
533 if (this.TryMakeRiver(point, point2))
534 {
535 num += 1 + EClass.rnd(2);
536 if (num > 10)
537 {
538 break;
539 }
540 }
541 }
542 }
543
544 // Token: 0x06002E1A RID: 11802 RVA: 0x00103328 File Offset: 0x00101528
545 public bool TryMakeRiver(Point p1, Point p2)
546 {
547 List<Point> list = new List<Point>();
548 int num = 30;
549 for (int i = 0; i < num; i++)
550 {
551 list.Add(new Point
552 {
553 x = p1.x + (p2.x - p1.x) * i / num,
554 z = p1.z + (p2.z - p1.z) * i / num
555 });
556 }
557 for (int j = 0; j < num; j++)
558 {
559 Point point = list[j];
560 if (!p1.Equals(point))
561 {
562 while (!p1.IsWater)
563 {
564 base.SetBlock(p1.x, p1.z, 0, 0, 0);
565 base.SetFloor(p1.x, p1.z, 67, 44, 0);
566 if (EClass.rnd(2) == 0)
567 {
568 if (p1.x != point.x)
569 {
570 p1.x += ((p1.x > point.x) ? -1 : 1);
571 }
572 else if (p1.z != point.z)
573 {
574 p1.z += ((p1.z > point.z) ? -1 : 1);
575 }
576 }
577 else if (p1.z != point.z)
578 {
579 p1.z += ((p1.z > point.z) ? -1 : 1);
580 }
581 else if (p1.x != point.x)
582 {
583 p1.x += ((p1.x > point.x) ? -1 : 1);
584 }
585 if (p1.Equals(point))
586 {
587 break;
588 }
589 }
590 if (p1.IsWater || p1.Equals(p2))
591 {
592 return true;
593 }
594 }
595 }
596 return true;
597 }
598
599 // Token: 0x06002E1B RID: 11803 RVA: 0x001034E8 File Offset: 0x001016E8
600 public void Populate(Map _map)
601 {
602 this.map = _map;
603 EClass._zone.isShore = this.bp.zoneProfile.isShore;
604 Rand.SetSeed(this.zp.seeds.poi);
605 if (this.zp.river)
606 {
607 this.MakeRiver(_map);
608 }
609 this.map.RefreshAllTiles();
610 this.layerStratum.FillHeightMap(this.heights1, this.OX, 0, this.OZ, this.Size, this.Size, this.seed, 1f);
611 this.layerStratum.FillHeightMap(this.heights2, this.OX, 0, this.OZ, this.Size, this.Size, this.seed + 1, 1f);
612 this.layerStratum.FillHeightMap(this.heights3, this.OX, 0, this.OZ, this.Size, this.Size, this.seed + 2, 1f);
613 this.layerStratum.FillHeightMap(this.heights3d, this.OX, 0, this.OZ, this.Size, this.Size, this.seed, 1f);
614 Point point = new Point();
615 for (int i = 0; i < this.Size; i++)
616 {
617 for (int j = 0; j < this.Size; j++)
618 {
619 point.Set(i, j);
620 Cell cell = point.cell;
621 if (cell.IsTopWater && this.biomeWater)
622 {
623 if (cell.Left.IsTopWater && cell.Right.IsTopWater && cell.Front.IsTopWater && cell.Back.IsTopWater)
624 {
625 this.biomeWater.Populate(point, false);
626 }
627 }
628 else
629 {
630 BiomeProfile biome = cell.biome;
631 if (!cell.HasBlock)
632 {
633 biome.Populate(point, false);
634 }
635 }
636 }
637 }
638 if (this.zp.name == "R_Plain")
639 {
640 Crawler crawler = Crawler.Create("pasture");
641 int tries = 10;
642 crawler.CrawlUntil(_map, () => _map.GetRandomPoint(), tries, delegate(Crawler.Result r)
643 {
644 int id = (EClass.rnd(3) == 0) ? 108 : 105;
645 foreach (Point point2 in r.points)
646 {
647 this.map.SetObj(point2.x, point2.z, id, 1, 0);
648 int num = 3;
649 if (EClass.rnd(6) == 0)
650 {
651 num++;
652 }
653 point2.growth.SetStage(num, false);
654 }
655 return false;
656 }, null);
657 }
658 if (this.crawlers != null)
659 {
660 Crawler[] crawlers = this.crawlers;
661 for (int k = 0; k < crawlers.Length; k++)
662 {
663 crawlers[k].Crawl(this.map);
664 }
665 }
666 this.MakeRoad();
667 Rand.SetSeed(-1);
668 }
669
670 // Token: 0x06002E1C RID: 11804 RVA: 0x0010378C File Offset: 0x0010198C
671 public void Output()
672 {
673 Debug.Log(this.zp.name + "/" + this.variation.name);
674 Debug.Log(string.Concat(new string[]
675 {
676 "seed:",
677 EClass._map.seed.ToString(),
678 " offset: ",
679 this.OX.ToString(),
680 "/",
681 this.OZ.ToString()
682 }));
683 }
684
685 // Token: 0x06002E1E RID: 11806 RVA: 0x0010381C File Offset: 0x00101A1C
686 [CompilerGenerated]
687 private void <MakeNeighbor>g___MakeNeighbor|5_0(EloMap.TileInfo info, int _s, Point p, int vx, int vz, int _seaDir1, int _seaDir2, ref MapGen.<>c__DisplayClass5_0 A_8)
688 {
689 int num = _s;
690 int num2 = 4;
691 Point point = new Point();
692 while (p.IsValid)
693 {
694 point.Set(p);
695 num2--;
696 if (num2 < 0)
697 {
698 num += ((EClass.rnd(2) == 0) ? 1 : -1);
699 num = Mathf.Clamp(num, _s - 3, _s + 3);
700 num2 = 2 + EClass.rnd(4);
701 }
702 for (int i = 0; i < num; i++)
703 {
704 if (vx != 0)
705 {
706 point.x = p.x + i * vx;
707 }
708 else
709 {
710 point.z = p.z + i * vz;
711 }
712 if (point.IsValid)
713 {
714 if (info.sea)
715 {
716 if (!A_8.thisInfo.sea)
717 {
718 A_8.seaDir = _seaDir1;
719 }
720 base.SetFloor(point.x, point.z, 66, (i >= num - 3) ? 44 : 43, 0);
721 }
722 else if (info.rock)
723 {
724 base.SetBlock(point.x, point.z, 45, 1, 0);
725 }
726 else if (info.shore)
727 {
728 if (!A_8.thisInfo.shore)
729 {
730 A_8.seaDir = _seaDir2;
731 }
732 base.SetFloor(point.x, point.z, 97, 33, 0);
733 }
734 }
735 }
736 if (vx == 0)
737 {
738 p.x++;
739 }
740 else
741 {
742 p.z++;
743 }
744 }
745 }
746
747 // Token: 0x06002E1F RID: 11807 RVA: 0x00103978 File Offset: 0x00101B78
748 [CompilerGenerated]
749 private void <MakeNeighbor_old>g___MakeNeighbor|6_0(EloMap.TileInfo info, Point p, int vx, int vz)
750 {
751 Point point = new Point();
752 while (p.IsValid)
753 {
754 point.Set(p);
755 int num = EClass.rnd(2) - EClass.rnd(2);
756 if (vx != 0)
757 {
758 p.x += num;
759 }
760 else
761 {
762 p.z += num;
763 }
764 for (int i = -this.Size / 2; i < this.Size / 2; i++)
765 {
766 if (vx != 0)
767 {
768 point.z = p.z + i;
769 }
770 else
771 {
772 point.x = p.x + i;
773 }
774 if (point.IsValid)
775 {
776 if (info.sea)
777 {
778 base.SetFloor(point.x, point.z, 66, 43, 0);
779 }
780 else if (info.rock)
781 {
782 base.SetBlock(point.x, point.z, 45, 1, 0);
783 }
784 else if (info.shore)
785 {
786 base.SetFloor(point.x, point.z, 97, 33, 0);
787 }
788 }
789 }
790 p.x += vx;
791 p.z += vz;
792 }
793 }
794
795 // Token: 0x06002E20 RID: 11808 RVA: 0x00103A9C File Offset: 0x00101C9C
796 [CompilerGenerated]
797 private void <MakeRoad>g___MakeRoad|7_0(int vx, int vz)
798 {
799 Point point = new Point(this.Size / 2, this.Size / 2);
800 Point point2 = new Point();
801 while (point.IsValid)
802 {
803 point2.Set(point);
804 for (int i = -1; i < 2; i++)
805 {
806 if (vx != 0)
807 {
808 point2.z = point.z + i;
809 }
810 else
811 {
812 point2.x = point.x + i;
813 }
814 if (point2.IsValid)
815 {
816 base.SetFloor(point2.x, point2.z, 45, 40, 0);
817 base.SetBlock(point2.x, point2.z, 0, 0, 0);
818 point2.cell.obj = 0;
819 }
820 }
821 point.x += vx;
822 point.z += vz;
823 if (EClass.rnd(30) == 0)
824 {
825 point.x += ((vx == 0) ? (EClass.rnd(3) - 1) : 0);
826 point.z += ((vz == 0) ? (EClass.rnd(3) - 1) : 0);
827 }
828 }
829 }
830
831 // Token: 0x04001A39 RID: 6713
832 private static MapGen _Instance;
833}
Definition Cell.cs:10
Definition Map.cs:15
Definition Point.cs:11