Elin Decompiled Documentation EA 23.102 Nightly
Loading...
Searching...
No Matches
MapGen Class Reference
Inheritance diagram for MapGen:
BaseMapGen GenBounds EClass

Public Member Functions

void MakeNeighbor ()
 
void MakeNeighbor_old ()
 
void MakeRoad ()
 
void ModifyHeight (Map _map)
 
void MakeRiver (Map _map)
 
bool TryMakeRiver (Point p1, Point p2)
 
void Populate (Map _map)
 
void Output ()
 
- Public Member Functions inherited from BaseMapGen
void SetSize (int size, int _poiSize)
 
void Generate (ZoneBlueprint _bp)
 
- Public Member Functions inherited from GenBounds
void SetFloor (BiomeProfile.Tile t, int x, int z)
 
void SetBlock (BiomeProfile.Tile t, int x, int z, int idMat=-1)
 
void SetFloor (int x, int z, int idMat, int idFloor, int direction=0)
 
void SetBlock (int x, int z, int idMat, int idBlock, int direction=0)
 
bool IsEmpty ()
 
List< PointListEmptyPoint ()
 
GenBounds GetBounds (int w, int h, bool ignoreBlock)
 
GenBounds GetBounds (Map map, Zone zone, int x, int y, int width, int height, int dw, int dh, bool ignoreBlock)
 
PartialMap TryAddMapPiece (MapPiece.Type type=MapPiece.Type.Any, float ruin=-1f, string tags=null, Action< PartialMap, GenBounds > onCreate=null)
 

Protected Member Functions

override void GenerateTerrain ()
 
override bool OnGenerateTerrain ()
 
virtual void GenerateTerrain ()
 
virtual bool OnGenerateTerrain ()
 

Properties

static MapGen Instance [get]
 
- Properties inherited from BaseMapGen
bool extraBiome [get]
 
- Properties inherited from EClass
static Game game [get]
 
static bool AdvMode [get]
 
static Player player [get]
 
static Chara pc [get]
 
static UI ui [get]
 
static Map _map [get]
 
static Zone _zone [get]
 
static FactionBranch Branch [get]
 
static FactionBranch BranchOrHomeBranch [get]
 
static Faction Home [get]
 
static Faction Wilds [get]
 
static Scene scene [get]
 
static BaseGameScreen screen [get]
 
static GameSetting setting [get]
 
static GameData gamedata [get]
 
static ColorProfile Colors [get]
 
static World world [get]
 
static SourceManager sources [get]
 
static SourceManager editorSources [get]
 
static SoundManager Sound [get]
 
static CoreDebug debug [get]
 

Static Private Attributes

static MapGen _Instance
 

Additional Inherited Members

- Static Public Member Functions inherited from GenBounds
static GenBounds Create (Zone z)
 
- Static Public Member Functions inherited from EClass
static int rnd (int a)
 
static int curve (int a, int start, int step, int rate=75)
 
static int rndHalf (int a)
 
static float rndf (float a)
 
static int rndSqrt (int a)
 
static void Wait (float a, Card c)
 
static void Wait (float a, Point p)
 
static int Bigger (int a, int b)
 
static int Smaller (int a, int b)
 
- Public Attributes inherited from BaseMapGen
NoiseLayer layerHeight
 
NoiseLayer layerRiver
 
NoiseLayer layerStratum
 
NoiseLayer layerBiome
 
BiomeProfile[] biomeProfiles
 
BiomeProfile biomeShore
 
BiomeProfile biomeSand
 
BiomeProfile biomeWater
 
Crawler[] crawlers
 
ZoneBlueprint bp
 
ZoneProfile zp
 
int blockHeight
 
int seed
 
int lastSize
 
int OX
 
int OZ
 
BiomeProfile[,] biomes
 
bool[,] subBiomes
 
MapGenVariation variation
 
MapHeight hSetting
 
- Public Attributes inherited from GenBounds
Map map
 
Zone zone
 
int Size
 
int x
 
int y
 
int width
 
int height
 
int marginPartial
 
Func< Cell, bool > FuncCheckEmpty
 
- Static Public Attributes inherited from BaseMapGen
static string err
 
- Static Public Attributes inherited from EClass
static Core core
 
- Protected Attributes inherited from BaseMapGen
bool skipWater
 
float[,] heights1
 
float[,] heights2
 
float[,] heights3
 
float[,] waters
 
float[,] heights3d
 
float waterCount
 

Detailed Description

Definition at line 4 of file MapGen.cs.

Member Function Documentation

◆ GenerateTerrain()

override void MapGen.GenerateTerrain ( )
inlineprotectedvirtual

Reimplemented from BaseMapGen.

Definition at line 10 of file MapGen.cs.

11 {
12 SetSize((zone is Zone_Gathering) ? 60 : ((!zp.useRootSize) ? zp.size : (zone.GetTopZone().bounds?.Size ?? zp.size)), 10);
13 if (biomes == null || Size != biomes.GetLength(0))
14 {
16 subBiomes = new bool[Size, Size];
17 heights1 = new float[Size, Size];
18 heights2 = new float[Size, Size];
19 heights3 = new float[Size, Size];
20 waters = new float[Size, Size];
21 heights3d = new float[Size, Size];
22 lastSize = Size;
23 }
24 map.biomes = biomes;
25 layerHeight.SaveSettings();
26 layerStratum.SaveSettings();
27 layerBiome.SaveSettings();
28 layerRiver.SaveSettings();
29 layerBiome.SaveSettings();
30 skipWater = zp.noWater || (bp.tileCenter != null && (bp.tileCenter.IsNeighborRoad || bp.tileCenter.isRoad));
31 for (int i = 0; i < 100; i++)
32 {
33 seed = (map.seed = bp.genSetting.seed + i);
36 {
37 break;
38 }
39 Debug.Log("Failed map generation:" + i + " / " + BaseMapGen.err);
40 skipWater = true;
41 }
43 for (int j = 0; j < Size; j++)
44 {
45 for (int k = 0; k < Size; k++)
46 {
48 }
49 }
50 Rand.SetSeed();
51 }
float[,] heights3
Definition: BaseMapGen.cs:51
float[,] waters
Definition: BaseMapGen.cs:54
int lastSize
Definition: BaseMapGen.cs:66
float[,] heights2
Definition: BaseMapGen.cs:48
NoiseLayer layerStratum
Definition: BaseMapGen.cs:15
static string err
Definition: BaseMapGen.cs:6
NoiseLayer layerBiome
Definition: BaseMapGen.cs:18
float[,] heights3d
Definition: BaseMapGen.cs:57
BiomeProfile[,] biomes
Definition: BaseMapGen.cs:78
NoiseLayer layerHeight
Definition: BaseMapGen.cs:9
void SetSize(int size, int _poiSize)
Definition: BaseMapGen.cs:91
ZoneProfile zp
Definition: BaseMapGen.cs:42
ZoneBlueprint bp
Definition: BaseMapGen.cs:39
float[,] heights1
Definition: BaseMapGen.cs:45
NoiseLayer layerRiver
Definition: BaseMapGen.cs:12
bool skipWater
Definition: BaseMapGen.cs:36
bool[,] subBiomes
Definition: BaseMapGen.cs:81
Definition: EClass.cs:5
static Zone _zone
Definition: EClass.cs:20
Zone zone
Definition: GenBounds.cs:9
int Size
Definition: GenBounds.cs:11
Map map
Definition: GenBounds.cs:7
int Size
Definition: MapBounds.cs:20
override bool OnGenerateTerrain()
Definition: MapGen.cs:53
void SetZone(Zone _zone)
Definition: Map.cs:181
void QuickRefreshTile(int x, int z)
Definition: Map.cs:2116
Definition: Rand.cs:4
static void SetSeed(int a=-1)
Definition: Rand.cs:37
EloMap.TileInfo tileCenter
bool useRootSize
Definition: ZoneProfile.cs:61
Zone GetTopZone()
Definition: Zone.cs:1854
MapBounds bounds
Definition: Zone.cs:46

References EClass._zone, BaseMapGen.biomes, Zone.bounds, BaseMapGen.bp, Debug, BaseMapGen.err, Zone.GetTopZone(), BaseMapGen.heights1, BaseMapGen.heights2, BaseMapGen.heights3, BaseMapGen.heights3d, BaseMapGen.lastSize, BaseMapGen.layerBiome, BaseMapGen.layerHeight, BaseMapGen.layerRiver, BaseMapGen.layerStratum, GenBounds.map, OnGenerateTerrain(), Map.QuickRefreshTile(), BaseMapGen.seed, Rand.SetSeed(), BaseMapGen.SetSize(), Map.SetZone(), GenBounds.Size, MapBounds.Size, ZoneProfile.size, BaseMapGen.skipWater, BaseMapGen.subBiomes, ZoneBlueprint.tileCenter, ZoneProfile.useRootSize, BaseMapGen.waters, GenBounds.zone, and BaseMapGen.zp.

◆ MakeNeighbor()

void MapGen.MakeNeighbor ( )
inline

Definition at line 343 of file MapGen.cs.

344 {
345 EloMap.TileInfo thisInfo;
346 int seaDir;
347 if (bp.surrounding != null)
348 {
349 thisInfo = bp.surrounding[1, 1];
350 seaDir = (thisInfo.sea ? (1 + EClass.rnd(4)) : 0);
351 _MakeNeighbor(bp.surrounding[1, 2], Size / 3 + 7, new Point(0, Size - 1), 0, -1, 3, 1);
352 _MakeNeighbor(bp.surrounding[1, 0], Size / 3 + 7, new Point(0, 0), 0, 1, 1, 3);
353 _MakeNeighbor(bp.surrounding[2, 1], Size / 3 + 7, new Point(Size - 1, 0), -1, 0, 2, 4);
354 _MakeNeighbor(bp.surrounding[0, 1], Size / 3 + 7, new Point(0, 0), 1, 0, 4, 2);
355 EClass._map.config.seaDir = seaDir;
356 }
357 void _MakeNeighbor(EloMap.TileInfo info, int _s, Point p, int vx, int vz, int _seaDir1, int _seaDir2)
358 {
359 int num = _s;
360 int num2 = 4;
361 Point point = new Point();
362 while (p.IsValid)
363 {
364 point.Set(p);
365 num2--;
366 if (num2 < 0)
367 {
368 num += ((EClass.rnd(2) == 0) ? 1 : (-1));
369 num = Mathf.Clamp(num, _s - 3, _s + 3);
370 num2 = 2 + EClass.rnd(4);
371 }
372 for (int i = 0; i < num; i++)
373 {
374 if (vx != 0)
375 {
376 point.x = p.x + i * vx;
377 }
378 else
379 {
380 point.z = p.z + i * vz;
381 }
382 if (point.IsValid)
383 {
384 if (info.sea)
385 {
386 if (!thisInfo.sea)
387 {
388 seaDir = _seaDir1;
389 }
390 SetFloor(point.x, point.z, 66, (i >= num - 3) ? 44 : 43);
391 }
392 else if (info.rock)
393 {
394 SetBlock(point.x, point.z, 45, 1);
395 }
396 else if (info.shore)
397 {
398 if (!thisInfo.shore)
399 {
400 seaDir = _seaDir2;
401 }
402 SetFloor(point.x, point.z, 97, 33);
403 }
404 }
405 }
406 if (vx == 0)
407 {
408 p.x++;
409 }
410 else
411 {
412 p.z++;
413 }
414 }
415 }
416 }
static int rnd(int a)
Definition: EClass.cs:50
bool shore
Definition: EloMap.cs:50
Definition: EloMap.cs:8
void SetBlock(BiomeProfile.Tile t, int x, int z, int idMat=-1)
Definition: GenBounds.cs:43
void SetFloor(BiomeProfile.Tile t, int x, int z)
Definition: GenBounds.cs:37
Definition: Point.cs:9
Point Set(int _x, int _z)
Definition: Point.cs:479
int x
Definition: Point.cs:36
int z
Definition: Point.cs:39
bool IsValid
Definition: Point.cs:88
Point Clamp(bool useBounds=false)
Definition: Point.cs:972
EloMap.TileInfo[,] surrounding

References BaseMapGen.bp, Point.Clamp(), Point.IsValid, EClass.rnd(), EloMap.TileInfo.sea, Point.Set(), GenBounds.SetBlock(), GenBounds.SetFloor(), EloMap.TileInfo.shore, GenBounds.Size, ZoneBlueprint.surrounding, Point.x, and Point.z.

Referenced by OnGenerateTerrain().

◆ MakeNeighbor_old()

void MapGen.MakeNeighbor_old ( )
inline

Definition at line 418 of file MapGen.cs.

419 {
420 if (bp.surrounding != null)
421 {
422 _MakeNeighbor(bp.surrounding[1, 2], new Point(Size / 2, Size / 3 * 2 - 5), 0, 1);
423 _MakeNeighbor(bp.surrounding[1, 0], new Point(Size / 2, Size / 3 + 6), 0, -1);
424 _MakeNeighbor(bp.surrounding[2, 1], new Point(Size / 3 * 2 - 5, Size / 2), 1, 0);
425 _MakeNeighbor(bp.surrounding[0, 1], new Point(Size / 3 + 6, Size / 2), -1, 0);
426 }
427 void _MakeNeighbor(EloMap.TileInfo info, Point p, int vx, int vz)
428 {
429 Point point = new Point();
430 while (p.IsValid)
431 {
432 point.Set(p);
433 int num = 0;
434 num = EClass.rnd(2) - EClass.rnd(2);
435 if (vx != 0)
436 {
437 p.x += num;
438 }
439 else
440 {
441 p.z += num;
442 }
443 for (int i = -Size / 2; i < Size / 2; i++)
444 {
445 if (vx != 0)
446 {
447 point.z = p.z + i;
448 }
449 else
450 {
451 point.x = p.x + i;
452 }
453 if (point.IsValid)
454 {
455 if (info.sea)
456 {
457 SetFloor(point.x, point.z, 66, 43);
458 }
459 else if (info.rock)
460 {
461 SetBlock(point.x, point.z, 45, 1);
462 }
463 else if (info.shore)
464 {
465 SetFloor(point.x, point.z, 97, 33);
466 }
467 }
468 }
469 p.x += vx;
470 p.z += vz;
471 }
472 }
473 }

References BaseMapGen.bp, Point.IsValid, EClass.rnd(), Point.Set(), GenBounds.SetBlock(), GenBounds.SetFloor(), GenBounds.Size, ZoneBlueprint.surrounding, Point.x, and Point.z.

◆ MakeRiver()

void MapGen.MakeRiver ( Map  _map)
inline

Definition at line 637 of file MapGen.cs.

638 {
639 int num = 0;
640 for (int i = 0; i < 100; i++)
641 {
642 Point point = null;
643 Point point2 = null;
644 for (int j = 0; j < 1000; j++)
645 {
646 point = _map.GetRandomEdge(1);
647 if (!point.cell.blocked)
648 {
649 break;
650 }
651 }
652 for (int k = 0; k < 1000; k++)
653 {
654 point2 = _map.GetRandomEdge(1);
655 if (point.x != point2.x && point.z != point2.z && !point2.cell.blocked && point.Distance(point2) >= _map.Size / 2)
656 {
657 break;
658 }
659 }
660 if (TryMakeRiver(point, point2))
661 {
662 num += 1 + EClass.rnd(2);
663 if (num > 10)
664 {
665 break;
666 }
667 }
668 }
669 }
static Map _map
Definition: EClass.cs:18
bool TryMakeRiver(Point p1, Point p2)
Definition: MapGen.cs:671
new Point GetRandomEdge(int r=3)
Definition: Map.cs:2211
int Distance(Point p)
Definition: Point.cs:953
Cell cell
Definition: Point.cs:51

References EClass._map, Algorithms.WeightCell.blocked, Point.cell, Point.Distance(), Map.GetRandomEdge(), EClass.rnd(), MapBounds.Size, TryMakeRiver(), Point.x, and Point.z.

Referenced by Populate().

◆ MakeRoad()

void MapGen.MakeRoad ( )
inline

Definition at line 475 of file MapGen.cs.

476 {
477 if (bp.tileCenter != null && !bp.ignoreRoad)
478 {
479 EloMap.TileInfo tileCenter = bp.tileCenter;
480 if (tileCenter.roadLeft)
481 {
482 _MakeRoad(-1, 0);
483 }
484 if (tileCenter.roadRight)
485 {
486 _MakeRoad(1, 0);
487 }
488 if (tileCenter.roadUp)
489 {
490 _MakeRoad(0, 1);
491 }
492 if (tileCenter.roadDown)
493 {
494 _MakeRoad(0, -1);
495 }
496 }
497 void _MakeRoad(int vx, int vz)
498 {
499 Point point = new Point(Size / 2, Size / 2);
500 Point point2 = new Point();
501 while (point.IsValid)
502 {
503 point2.Set(point);
504 for (int i = -1; i < 2; i++)
505 {
506 if (vx != 0)
507 {
508 point2.z = point.z + i;
509 }
510 else
511 {
512 point2.x = point.x + i;
513 }
514 if (point2.IsValid)
515 {
516 SetFloor(point2.x, point2.z, 45, 40);
517 SetBlock(point2.x, point2.z, 0, 0);
518 point2.cell.obj = 0;
519 }
520 }
521 point.x += vx;
522 point.z += vz;
523 if (EClass.rnd(30) == 0)
524 {
525 point.x += ((vx == 0) ? (EClass.rnd(3) - 1) : 0);
526 point.z += ((vz == 0) ? (EClass.rnd(3) - 1) : 0);
527 }
528 }
529 }
530 }
bool roadLeft
Definition: EloMap.cs:38
bool roadUp
Definition: EloMap.cs:42
bool roadDown
Definition: EloMap.cs:44
bool roadRight
Definition: EloMap.cs:40

References BaseMapGen.bp, ZoneBlueprint.ignoreRoad, Point.IsValid, EClass.rnd(), EloMap.TileInfo.roadDown, EloMap.TileInfo.roadLeft, EloMap.TileInfo.roadRight, EloMap.TileInfo.roadUp, Point.Set(), GenBounds.SetBlock(), GenBounds.SetFloor(), GenBounds.Size, ZoneBlueprint.tileCenter, Point.x, and Point.z.

◆ ModifyHeight()

void MapGen.ModifyHeight ( Map  _map)
inline

Definition at line 532 of file MapGen.cs.

533 {
534 map = _map;
535 Cell[,] cells = map.cells;
536 bool flag = false;
537 for (int num = Size - 1; num > 0; num--)
538 {
539 for (int i = 0; i < Size - 1; i++)
540 {
541 Cell cell = cells[num, i];
542 byte b = cell.height;
543 Cell cell2 = cells[num - 1, i];
544 Cell cell3 = cells[num, i + 1];
545 if (cell2.IsTopWater || cell3.IsTopWater)
546 {
547 continue;
548 }
549 if (EClass.rnd(500) == 0)
550 {
551 flag = !flag;
552 }
553 if (EClass.rnd(3) == 0)
554 {
555 if (flag)
556 {
557 cell2.height = b;
558 }
559 else
560 {
561 cell3.height = b;
562 }
563 }
564 if (hSetting.smoothDownhill && EClass.rnd(3) == 0)
565 {
566 if (cell2.height < b - 2)
567 {
568 cell2.height = (byte)(b - 2);
569 }
570 if (cell3.height < b - 2)
571 {
572 cell3.height = (byte)(b - 2);
573 }
574 continue;
575 }
576 if (hSetting.mod1 && (cell2.height >= b - 1 || cell3.height >= b - 1))
577 {
578 if (EClass.rnd(4) == 0 && b != 0)
579 {
580 cell2.height = (cell3.height = b);
581 }
582 else
583 {
584 cell.height = (cell2.height = cell3.height);
585 }
586 }
587 if (hSetting.mod2 && (cell2.height < b - 1 || cell3.height < b - 1))
588 {
589 if (EClass.rnd(2) == 0)
590 {
591 cell2.height = (cell3.height = b);
592 }
593 else
594 {
595 cells[num, i].height = (cell2.height = cell3.height);
596 }
597 }
598 if (hSetting.mod3 && (cell2.height >= b - 1 || cell3.height >= b - 1))
599 {
600 if (EClass.rnd(2) == 0)
601 {
602 cell2.height = (cell3.height = b);
603 }
604 else
605 {
606 cells[num, i].height = (cell2.height = cell3.height);
607 }
608 }
609 }
610 }
612 {
613 return;
614 }
615 for (int num2 = Size - 1; num2 > 0; num2--)
616 {
617 for (int j = 0; j < Size - 1; j++)
618 {
619 byte b2 = cells[num2, j].height;
620 Cell cell4 = cells[num2 - 1, j];
621 Cell cell5 = cells[num2, j + 1];
622 if (b2 != 0)
623 {
624 if (cell4.height < b2 - 2 && !cell4.IsTopWater)
625 {
626 cell4.height = (byte)(b2 - 2);
627 }
628 if (cell5.height < b2 - 2 && !cell5.IsTopWater)
629 {
630 cell5.height = (byte)(b2 - 2);
631 }
632 }
633 }
634 }
635 }
MapHeight hSetting
Definition: BaseMapGen.cs:87
Definition: Cell.cs:7
bool IsTopWater
Definition: Cell.cs:700
byte height
Definition: Cell.cs:72
bool mod2
Definition: MapHeight.cs:15
bool mod3
Definition: MapHeight.cs:17
bool smoothDownhill
Definition: MapHeight.cs:11
bool mod1
Definition: MapHeight.cs:13
Cell[,] cells
Definition: Map.cs:85

References EClass._map, Map.cells, Cell.height, BaseMapGen.hSetting, Cell.IsTopWater, GenBounds.map, MapHeight.mod1, MapHeight.mod2, MapHeight.mod3, EClass.rnd(), GenBounds.Size, and MapHeight.smoothDownhill.

Referenced by OnGenerateTerrain().

◆ OnGenerateTerrain()

override bool MapGen.OnGenerateTerrain ( )
inlineprotectedvirtual

Reimplemented from BaseMapGen.

Definition at line 53 of file MapGen.cs.

54 {
55 int idMat = 66;
56 if (map.isGenerated)
57 {
58 if (map.Size != Size)
59 {
61 }
62 map.Reset();
63 }
64 else
65 {
67 }
69 if (zone is Zone_Gathering)
70 {
71 map.SetBounds(Size - 20);
72 }
73 else if (bp.zoneProfile.useRootSize && zone.GetTopZone().bounds != null)
74 {
76 }
77 else
78 {
80 }
81 switch (zp.genType)
82 {
83 case ZoneProfile.GenType.Underground:
84 map.config.idBiome = "Underground";
85 zone._biome = null;
86 break;
87 case ZoneProfile.GenType.Sky:
88 {
89 map.config.idBiome = "Sky";
90 zone._biome = null;
91 for (int i = 0; i < Size; i++)
92 {
93 for (int j = 0; j < Size; j++)
94 {
95 SetFloor(i, j, 0, 90);
96 }
97 }
98 return true;
99 }
100 }
101 waterCount = 0f;
102 if (!skipWater)
103 {
104 float num = (float)(Size * Size) * variation.maxWaterRatio;
105 layerRiver.FillHeightMap(waters, OX, 0, OZ, Size, Size, seed);
106 for (int k = 0; k < Size; k++)
107 {
108 for (int l = 0; l < Size; l++)
109 {
110 waters[k, l] += zp.water;
111 if (waters[k, l] > 0f)
112 {
113 waterCount += 1f;
114 }
115 }
116 if (waterCount > num)
117 {
118 BaseMapGen.err = "Too many water";
119 return false;
120 }
121 }
122 }
123 layerBiome.FillHeightMap(heights1, OX, 0, OZ, Size, Size, zp.seeds.biome);
124 layerBiome.FillHeightMap(heights2, OX, 0, OZ, Size, Size, zp.seeds.biome + 1);
125 if (base.extraBiome)
126 {
127 layerBiome.FillHeightMap(heights3, OX, 0, OZ, Size, Size, zp.seeds.biome + 2);
128 }
129 for (int m = 0; m < Size; m++)
130 {
131 for (int n = 0; n < Size; n++)
132 {
133 if (heights1[m, n] != 0f)
134 {
135 biomes[m, n] = biomeProfiles[1];
136 }
137 else if (heights2[m, n] != 0f)
138 {
139 biomes[m, n] = biomeProfiles[2];
140 }
141 else if (base.extraBiome && heights3[m, n] != 0f)
142 {
143 biomes[m, n] = biomeProfiles[3];
144 }
145 else
146 {
147 biomes[m, n] = biomeProfiles[0];
148 }
149 }
150 }
151 layerBiome.FillHeightMap(heights1, OX, 0, OZ, Size, Size, zp.seeds.biomeSub, zp.biomeSubScale);
152 for (int num2 = 0; num2 < Size; num2++)
153 {
154 for (int num3 = 0; num3 < Size; num3++)
155 {
156 subBiomes[num2, num3] = heights1[num2, num3] != 0f;
157 }
158 }
159 layerBiome.FillHeightMap(heights1, OX, 0, OZ, Size, Size, zp.seeds.biome);
160 for (int num4 = 0; num4 < biomeProfiles.Length; num4++)
161 {
162 if (num4 != 0 && biomeProfiles[num4 - 1] == biomeProfiles[num4])
163 {
164 continue;
165 }
166 biomeProfiles[num4].layerBlock.FillHeightMap(heights1, OX, 0, OZ, Size, Size, zp.seeds.biome);
167 bool flag = EClass.sources.floors.rows[biomeProfiles[num4].exterior.floor.id].tag.Contains("soil");
168 for (int num5 = 0; num5 < Size; num5++)
169 {
170 if (zp.clearEdge && ((num5 > map.bounds.x - 4 && num5 <= map.bounds.x + 4) || (num5 > map.bounds.maxX - 4 && num5 <= map.bounds.maxX + 4)))
171 {
172 continue;
173 }
174 for (int num6 = 0; num6 < Size; num6++)
175 {
176 if ((!zp.clearEdge || ((num6 <= map.bounds.z - 4 || num6 > map.bounds.z + 4) && (num6 <= map.bounds.maxZ - 4 || num6 > map.bounds.maxZ + 4))) && !(biomes[num5, num6] != biomeProfiles[num4]) && heights1[num5, num6] > (float)blockHeight)
177 {
179 if (!flag || row.alias == "block_ice")
180 {
182 SetFloor(num5, num6, row2.DefaultMaterial.id, row2.id);
183 }
184 SetBlock(num5, num6, biomeProfiles[num4].exterior.block.mat, biomeProfiles[num4].exterior.block.id);
185 }
186 }
187 }
188 }
189 bool flag2 = false;
190 for (int num7 = Size / 2 - 4; num7 < Size / 2 + 4; num7++)
191 {
192 for (int num8 = Size / 2 - 4; num8 < Size / 2 + 4; num8++)
193 {
194 if (num7 >= 0 && num8 >= 0 && num7 < Size && num8 < Size && map.cells[num7, num8]._block != 0)
195 {
196 flag2 = true;
197 break;
198 }
199 }
200 }
201 if (flag2)
202 {
203 for (int num9 = 0; num9 < Size; num9++)
204 {
205 for (int num10 = 0; num10 < Size; num10++)
206 {
207 SetBlock(num9, num10, 0, 0);
208 }
209 }
210 }
211 layerHeight.FillHeightMap(heights1, OX, 0, OZ, Size, Size, seed);
212 layerHeight.FillHeightMap(heights2, OX, 0, OZ, Size, Size, zp.seeds.bush);
213 layerHeight.FillHeightMap(heights3, OX, 0, OZ, Size, Size, seed + 1);
214 BiomeProfile biomeProfile = biomeWater;
215 byte b = (byte)EClass.setting.maxGenHeight;
216 for (int num11 = 0; num11 < Size; num11++)
217 {
218 for (int num12 = 0; num12 < Size; num12++)
219 {
220 int num13 = (int)heights1[num11, num12];
221 Cell cell = map.cells[num11, num12];
222 if (cell._block != 0 && cell._floor != 0)
223 {
224 continue;
225 }
226 BiomeProfile biomeProfile2 = biomes[num11, num12];
227 SourceMaterial.Row row3 = (subBiomes[num11, num12] ? biomeProfile2.MatSub : biomeProfile2.MatFloor);
228 int dir = biomeProfile2.exterior.floor.GetDir();
229 byte b2 = (byte)(heights1[num11, num12] * (float)hSetting.heightMod + (float)hSetting.baseHeight);
230 if (hSetting.step > 0)
231 {
232 b2 = (byte)(b2 / hSetting.step * hSetting.step);
233 }
234 if (b2 > b)
235 {
236 b2 = b;
237 }
238 cell.height = b2;
239 if (!skipWater && waters[num11, num12] > 0f && cell._block == 0)
240 {
241 cell.height = 0;
242 if ((bool)biomeProfile)
243 {
244 bool flag3 = false;
245 for (int num14 = num12 - 2; num14 < num12 + 3; num14++)
246 {
247 for (int num15 = num11 - 2; num15 < num11 + 3; num15++)
248 {
249 if (num14 >= 0 && num15 >= 0 && num15 < Size && num14 < Size && waters[num15, num14] <= 0f)
250 {
251 flag3 = true;
252 break;
253 }
254 }
255 }
256 SetFloor(num11, num12, biomeWater.MatFloor.id, flag3 ? 44 : 43);
257 }
258 else
259 {
260 SetFloor(num11, num12, idMat, (waters[num11, num12] < 5f) ? 44 : 43);
261 }
262 }
263 else if (zp.shoreHeight > 0f && (float)num13 < zp.shoreHeight)
264 {
265 SetFloor(num11, num12, biomeShore.MatFloor.id, biomeShore.MatFloor.defFloor);
266 biomes[num11, num12] = biomeShore;
267 }
268 else if (biomeProfile2.floor_height != 0 && (int)heights2[num11, num12] + zp.bushMod >= 4)
269 {
270 SetFloor(num11, num12, (byte)row3.id, biomeProfile2.floor_height, dir);
271 }
272 else
273 {
274 SetFloor(num11, num12, (byte)row3.id, (biomeProfile2.exterior.floor.id != 0) ? biomeProfile2.exterior.floor.id : row3.defFloor, dir);
275 }
276 }
277 }
278 if (hSetting.heightMod > 0)
279 {
281 }
282 MakeNeighbor();
283 for (int num16 = 0; num16 < Size; num16++)
284 {
285 for (int num17 = 0; num17 < Size; num17++)
286 {
287 Cell cell2 = map.cells[num16, num17];
288 if (!zp.setShore || cell2.HasBlock || cell2.IsTopWater || cell2.height > 20)
289 {
290 continue;
291 }
292 bool flag4 = false;
293 for (int num18 = num16 - 1; num18 < num16 + 2; num18++)
294 {
295 if (num18 < 0 || num18 >= Size)
296 {
297 continue;
298 }
299 for (int num19 = num17 - 1; num19 < num17 + 2; num19++)
300 {
301 if (num19 >= 0 && num19 < Size && (num18 != num16 || num19 != num17) && map.cells[num18, num19].IsTopWater)
302 {
303 flag4 = true;
304 break;
305 }
306 }
307 if (flag4)
308 {
309 break;
310 }
311 }
312 if (!flag4)
313 {
314 continue;
315 }
316 SetFloor(num16, num17, biomeShore.MatFloor.id, biomeShore.MatFloor.defFloor);
317 biomes[num16, num17] = biomeShore;
318 if (zp.extraShores <= 0)
319 {
320 continue;
321 }
322 int extraShores = zp.extraShores;
323 for (int num20 = num16 - extraShores; num20 < num16 + extraShores + 1; num20++)
324 {
325 if (num20 < 0 || num20 >= Size)
326 {
327 continue;
328 }
329 for (int num21 = num17 - extraShores; num21 < num17 + extraShores + 1; num21++)
330 {
331 if (num21 >= 0 && num21 < Size && !(biomes[num20, num21] == biomeShore) && !map.cells[num20, num21].IsTopWater && !map.cells[num20, num21].HasBlock)
332 {
333 SetFloor(num20, num21, biomeShore.MatFloor.id, biomeShore.MatFloor.defFloor);
334 biomes[num20, num21] = biomeShore;
335 }
336 }
337 }
338 }
339 }
340 return true;
341 }
float waterCount
Definition: BaseMapGen.cs:75
BiomeProfile[] biomeProfiles
Definition: BaseMapGen.cs:21
BiomeProfile biomeShore
Definition: BaseMapGen.cs:24
int blockHeight
Definition: BaseMapGen.cs:60
MapGenVariation variation
Definition: BaseMapGen.cs:84
BiomeProfile biomeWater
Definition: BaseMapGen.cs:30
TileGroup exterior
NoiseLayer layerBlock
SourceMaterial.Row MatFloor
byte _block
Definition: Cell.cs:30
bool HasBlock
Definition: Cell.cs:643
byte _floor
Definition: Cell.cs:34
static SourceManager sources
Definition: EClass.cs:42
static GameSetting setting
Definition: EClass.cs:34
int maxGenHeight
Definition: GameSetting.cs:331
int defaultMapSize
Definition: GameSetting.cs:335
int maxZ
Definition: MapBounds.cs:17
int maxX
Definition: MapBounds.cs:14
int x
Definition: MapBounds.cs:8
void ModifyHeight(Map _map)
Definition: MapGen.cs:532
void MakeNeighbor()
Definition: MapGen.cs:343
int heightMod
Definition: MapHeight.cs:5
int baseHeight
Definition: MapHeight.cs:7
int step
Definition: MapHeight.cs:9
bool isGenerated
Definition: Map.cs:129
void Reset()
Definition: Map.cs:345
void SetBounds(int size)
Definition: Map.cs:2309
POIMap poiMap
Definition: Map.cs:97
void CreateNew(int size, bool setReference=true)
Definition: Map.cs:153
void Resize(int newSize)
Definition: Map.cs:226
MapBounds bounds
Definition: Map.cs:52
void Reset()
Definition: POIMap.cs:35
SourceMaterial.Row DefaultMaterial
Definition: RenderRow.cs:86
string autoFloor
Definition: SourceBlock.cs:15
SourceBlock blocks
SourceFloor floors
string alias
Definition: TileRow.cs:12
int id
Definition: TileRow.cs:8
ZoneProfile zoneProfile
float shoreHeight
Definition: ZoneProfile.cs:49
int sizeBounds
Definition: ZoneProfile.cs:35
Seeds seeds
Definition: ZoneProfile.cs:31
bool setShore
Definition: ZoneProfile.cs:55
float biomeSubScale
Definition: ZoneProfile.cs:51
GenType genType
Definition: ZoneProfile.cs:69
bool clearEdge
Definition: ZoneProfile.cs:65
int extraShores
Definition: ZoneProfile.cs:47

References Cell._block, Cell._floor, TileRow.alias, SourceBlock.Row.autoFloor, MapHeight.baseHeight, ZoneProfile.Seeds.biome, BaseMapGen.biomeProfiles, BaseMapGen.biomes, BaseMapGen.biomeShore, ZoneProfile.Seeds.biomeSub, ZoneProfile.biomeSubScale, BaseMapGen.biomeWater, BiomeProfile.TileGroup.block, BaseMapGen.blockHeight, SourceManager.blocks, Map.bounds, Zone.bounds, BaseMapGen.bp, ZoneProfile.Seeds.bush, ZoneProfile.bushMod, Map.cells, ZoneProfile.clearEdge, Map.CreateNew(), GameSetting.defaultMapSize, RenderRow.DefaultMaterial, SourceMaterial.Row.defFloor, BiomeProfile.exterior, ZoneProfile.extraShores, BiomeProfile.TileGroup.floor, BiomeProfile.floor_height, SourceManager.floors, ZoneProfile.genType, BiomeProfile.Tile.GetDir(), Zone.GetTopZone(), Cell.HasBlock, Cell.height, MapHeight.heightMod, BaseMapGen.heights1, BaseMapGen.heights2, BaseMapGen.heights3, BaseMapGen.hSetting, BiomeProfile.Tile.id, SourceMaterial.Row.id, TileRow.id, Map.isGenerated, Cell.IsTopWater, BaseMapGen.layerBiome, BiomeProfile.layerBlock, BaseMapGen.layerHeight, BaseMapGen.layerRiver, MakeNeighbor(), GenBounds.map, BiomeProfile.MatFloor, GameSetting.maxGenHeight, MapGenVariation.maxWaterRatio, MapBounds.maxX, MapBounds.maxZ, ModifyHeight(), BaseMapGen.OX, BaseMapGen.OZ, Map.poiMap, Map.Reset(), POIMap.Reset(), Map.Resize(), BaseMapGen.seed, ZoneProfile.seeds, GenBounds.SetBlock(), Map.SetBounds(), GenBounds.SetFloor(), ZoneProfile.setShore, EClass.setting, ZoneProfile.shoreHeight, GenBounds.Size, MapBounds.Size, ZoneProfile.sizeBounds, BaseMapGen.skipWater, EClass.sources, MapHeight.step, BaseMapGen.subBiomes, ZoneProfile.useRootSize, BaseMapGen.variation, ZoneProfile.water, BaseMapGen.waterCount, BaseMapGen.waters, MapBounds.x, MapBounds.z, GenBounds.zone, ZoneBlueprint.zoneProfile, and BaseMapGen.zp.

Referenced by GenerateTerrain().

◆ Output()

void MapGen.Output ( )
inline

Definition at line 793 of file MapGen.cs.

794 {
795 Debug.Log(zp.name + "/" + variation.name);
796 Debug.Log("seed:" + EClass._map.seed + " offset: " + OX + "/" + OZ);
797 }
int seed
Definition: Map.cs:19

References EClass._map, Debug, and Map.seed.

◆ Populate()

void MapGen.Populate ( Map  _map)
inline

Definition at line 725 of file MapGen.cs.

726 {
727 map = _map;
728 EClass._zone.isShore = bp.zoneProfile.isShore;
730 if (zp.river)
731 {
733 }
735 layerStratum.FillHeightMap(heights1, OX, 0, OZ, Size, Size, seed);
736 layerStratum.FillHeightMap(heights2, OX, 0, OZ, Size, Size, seed + 1);
737 layerStratum.FillHeightMap(heights3, OX, 0, OZ, Size, Size, seed + 2);
738 layerStratum.FillHeightMap(heights3d, OX, 0, OZ, Size, Size, seed);
739 Point point = new Point();
740 for (int i = 0; i < Size; i++)
741 {
742 for (int j = 0; j < Size; j++)
743 {
744 point.Set(i, j);
745 Cell cell = point.cell;
746 if (cell.IsTopWater && (bool)biomeWater)
747 {
748 if (cell.Left.IsTopWater && cell.Right.IsTopWater && cell.Front.IsTopWater && cell.Back.IsTopWater)
749 {
750 biomeWater.Populate(point);
751 }
752 continue;
753 }
754 BiomeProfile biome = cell.biome;
755 if (!cell.HasBlock)
756 {
757 biome.Populate(point);
758 }
759 }
760 }
761 if (zp.name == "R_Plain")
762 {
763 Crawler crawler = Crawler.Create("pasture");
764 int tries = 10;
765 crawler.CrawlUntil(_map, () => _map.GetRandomPoint(), tries, delegate(Crawler.Result r)
766 {
767 int id = ((EClass.rnd(3) == 0) ? 108 : 105);
768 foreach (Point point2 in r.points)
769 {
770 map.SetObj(point2.x, point2.z, id);
771 int num = 3;
772 if (EClass.rnd(6) == 0)
773 {
774 num++;
775 }
776 point2.growth.SetStage(num);
777 }
778 return false;
779 });
780 }
781 if (crawlers != null)
782 {
783 Crawler[] array = crawlers;
784 for (int k = 0; k < array.Length; k++)
785 {
786 array[k].Crawl(map);
787 }
788 }
789 MakeRoad();
790 Rand.SetSeed();
791 }
Crawler[] crawlers
Definition: BaseMapGen.cs:33
void Populate(Point point, bool interior=false)
Cell Back
Definition: Cell.cs:153
Cell Front
Definition: Cell.cs:129
BiomeProfile biome
Definition: Cell.cs:1075
Cell Left
Definition: Cell.cs:165
Cell Right
Definition: Cell.cs:141
void Crawl(Map map)
Definition: Crawler.cs:107
static Crawler Create(string id)
Definition: Crawler.cs:190
bool CrawlUntil(Map map, Func< Point > onStart, int tries, Func< Result, bool > canComplete, Action onFail=null)
Definition: Crawler.cs:57
void MakeRoad()
Definition: MapGen.cs:475
void MakeRiver(Map _map)
Definition: MapGen.cs:637
Point GetRandomPoint(Point center, int radius, int tries=100, bool mustBeWalkable=true, bool requireLos=true)
Definition: Map.cs:2193
void RefreshAllTiles()
Definition: Map.cs:2086
bool isShore
Definition: ZoneProfile.cs:53

References EClass._map, Cell.Back, Cell.biome, BaseMapGen.biomeWater, BaseMapGen.bp, Point.cell, Crawler.CrawlUntil(), Crawler.Create(), Cell.Front, Map.GetRandomPoint(), Cell.HasBlock, BaseMapGen.heights1, BaseMapGen.heights2, BaseMapGen.heights3, BaseMapGen.heights3d, ZoneProfile.isShore, Cell.IsTopWater, BaseMapGen.layerStratum, Cell.Left, MakeRiver(), GenBounds.map, BaseMapGen.OX, BaseMapGen.OZ, ZoneProfile.Seeds.poi, BiomeProfile.Populate(), Map.RefreshAllTiles(), Cell.Right, ZoneProfile.river, BaseMapGen.seed, ZoneProfile.seeds, Point.Set(), Rand.SetSeed(), GenBounds.Size, ZoneBlueprint.zoneProfile, and BaseMapGen.zp.

Referenced by ZoneBlueprint.GenerateMap().

◆ TryMakeRiver()

bool MapGen.TryMakeRiver ( Point  p1,
Point  p2 
)
inline

Definition at line 671 of file MapGen.cs.

672 {
673 List<Point> list = new List<Point>();
674 int num = 30;
675 for (int i = 0; i < num; i++)
676 {
677 Point point = new Point();
678 point.x = p1.x + (p2.x - p1.x) * i / num;
679 point.z = p1.z + (p2.z - p1.z) * i / num;
680 list.Add(point);
681 }
682 for (int j = 0; j < num; j++)
683 {
684 Point point2 = list[j];
685 if (p1.Equals(point2))
686 {
687 continue;
688 }
689 while (!p1.IsWater)
690 {
691 SetBlock(p1.x, p1.z, 0, 0);
692 SetFloor(p1.x, p1.z, 67, 44);
693 if (EClass.rnd(2) == 0)
694 {
695 if (p1.x != point2.x)
696 {
697 p1.x += ((p1.x <= point2.x) ? 1 : (-1));
698 }
699 else if (p1.z != point2.z)
700 {
701 p1.z += ((p1.z <= point2.z) ? 1 : (-1));
702 }
703 }
704 else if (p1.z != point2.z)
705 {
706 p1.z += ((p1.z <= point2.z) ? 1 : (-1));
707 }
708 else if (p1.x != point2.x)
709 {
710 p1.x += ((p1.x <= point2.x) ? 1 : (-1));
711 }
712 if (p1.Equals(point2))
713 {
714 break;
715 }
716 }
717 if (p1.IsWater || p1.Equals(p2))
718 {
719 return true;
720 }
721 }
722 return true;
723 }
bool IsWater
Definition: Point.cs:129
bool Equals(int _x, int _z)
Definition: Point.cs:924

References Point.Equals(), Point.IsWater, EClass.rnd(), GenBounds.SetBlock(), GenBounds.SetFloor(), Point.x, and Point.z.

Referenced by MakeRiver().

Member Data Documentation

◆ _Instance

MapGen MapGen._Instance
staticprivate

Definition at line 6 of file MapGen.cs.

Property Documentation

◆ Instance

MapGen MapGen.Instance
staticget

Definition at line 8 of file MapGen.cs.

Referenced by ZoneBlueprint.GenerateMap().


The documentation for this class was generated from the following file: