Elin Decompiled Documentation EA 23.102 Nightly
Loading...
Searching...
No Matches
Crawler Class Reference
Inheritance diagram for Crawler:
EScriptable

Classes

class  Member
 
class  Result
 

Public Types

enum  MoveType { Surface , Block }
 
enum  StartType { Surface , Block }
 

Public Member Functions

bool CrawlUntil (Map map, Func< Point > onStart, int tries, Func< Result, bool > canComplete, Action onFail=null)
 
void Crawl (Map map)
 
Result Crawl (Map map, Point _start, Action< Point > onNewVisit=null)
 

Static Public Member Functions

static Crawler Create (string id)
 
- Static Public Member Functions inherited from EScriptable
static int rnd (int a)
 

Public Attributes

int life
 
int member
 
int radius
 
int repeat
 
bool stickToStartBiome
 
bool skipBorder
 
StartType startType
 
MoveType moveType
 
int Size
 
List< Membermembers = new List<Member>()
 

Static Public Attributes

static int[,] mapping = new int[0, 0]
 
static int sync
 

Detailed Description

Definition at line 5 of file Crawler.cs.

Member Enumeration Documentation

◆ MoveType

Enumerator
Surface 
Block 

Definition at line 19 of file Crawler.cs.

◆ StartType

Enumerator
Surface 
Block 

Definition at line 25 of file Crawler.cs.

26 {
27 Surface,
28 Block
29 }

Member Function Documentation

◆ Crawl() [1/2]

void Crawler.Crawl ( Map  map)
inline

Definition at line 107 of file Crawler.cs.

108 {
109 for (int i = 0; (float)i < map.sizeModifier * (float)repeat + 1f; i++)
110 {
111 Crawl(map, map.GetRandomSurface(), delegate(Point p)
112 {
113 p.cell.biome.Populate(p);
114 });
115 }
116 }
void Populate(Point point, bool interior=false)
BiomeProfile biome
Definition: Cell.cs:1075
void Crawl(Map map)
Definition: Crawler.cs:107
int repeat
Definition: Crawler.cs:41
Point GetRandomSurface(int x, int z, int radius, bool walkable=true, bool allowWater=false)
Definition: MapBounds.cs:182
float sizeModifier
Definition: Map.cs:127
Definition: Point.cs:9
Cell cell
Definition: Point.cs:51

References Cell.biome, Point.cell, Crawl(), MapBounds.GetRandomSurface(), BiomeProfile.Populate(), repeat, and Map.sizeModifier.

Referenced by Crawl(), and CrawlUntil().

◆ Crawl() [2/2]

Result Crawler.Crawl ( Map  map,
Point  _start,
Action< Point onNewVisit = null 
)
inline

Definition at line 118 of file Crawler.cs.

119 {
120 if (members.Count == 0)
121 {
122 for (int i = 0; i < this.member; i++)
123 {
124 members.Add(new Member());
125 }
126 }
127 Point point = _start.Copy();
128 point.Clamp();
129 Result result = new Result();
130 BiomeProfile biome = point.cell.biome;
131 sync++;
132 Size = map.Size;
133 int num = (skipBorder ? 2 : 0);
134 int num2 = (skipBorder ? (Size - 2) : Size);
135 if (mapping.Length != Size)
136 {
137 mapping = new int[map.Size, map.Size];
138 }
139 foreach (Member member2 in members)
140 {
141 member2.pos.Set(point);
142 member2.life = life;
143 }
144 for (int j = 0; j < life; j++)
145 {
146 for (int k = 0; k < members.Count; k++)
147 {
148 Member member = members[k];
149 int num3 = EScriptable.rnd(3) - 1;
150 int num4 = EScriptable.rnd(3) - 1;
151 int num5 = member.pos.x + num3;
152 int num6 = member.pos.z + num4;
153 if (point.Distance(num5, num6) > radius || num5 < num || num6 < num || num5 >= num2 || num6 >= num2)
154 {
155 continue;
156 }
157 Cell cell = map.cells[num5, num6];
158 if (stickToStartBiome && cell.biome != biome)
159 {
160 continue;
161 }
162 switch (moveType)
163 {
164 case MoveType.Surface:
165 if (cell._block != 0 || cell.IsTopWater)
166 {
167 continue;
168 }
169 break;
170 case MoveType.Block:
171 if (cell._block == 0 || !cell.sourceBlock.tileType.IsFullBlock || cell.Installed != null)
172 {
173 continue;
174 }
175 break;
176 }
177 member.pos.Set(num5, num6);
178 if (mapping[num5, num6] != sync)
179 {
180 mapping[num5, num6] = sync;
181 Point point2 = member.pos.Copy();
182 result.points.Add(point2);
183 onNewVisit?.Invoke(point2);
184 }
185 }
186 }
187 return result;
188 }
Definition: Cell.cs:7
byte _block
Definition: Cell.cs:30
SourceBlock.Row sourceBlock
Definition: Cell.cs:1052
Thing Installed
Definition: Cell.cs:975
bool IsTopWater
Definition: Cell.cs:700
static int sync
Definition: Crawler.cs:33
MoveType
Definition: Crawler.cs:20
int life
Definition: Crawler.cs:35
bool skipBorder
Definition: Crawler.cs:45
static int[,] mapping
Definition: Crawler.cs:31
MoveType moveType
Definition: Crawler.cs:49
int Size
Definition: Crawler.cs:52
int radius
Definition: Crawler.cs:39
List< Member > members
Definition: Crawler.cs:55
bool stickToStartBiome
Definition: Crawler.cs:43
int member
Definition: Crawler.cs:37
static int rnd(int a)
Definition: EScriptable.cs:5
int Size
Definition: MapBounds.cs:20
Cell[,] cells
Definition: Map.cs:85
Point Copy()
Definition: Point.cs:467
int Distance(Point p)
Definition: Point.cs:953
Point Clamp(bool useBounds=false)
Definition: Point.cs:972

References Cell._block, Cell.biome, Point.cell, Cell.cells, Point.Clamp(), Point.Copy(), Cell.Installed, Cell.IsTopWater, life, mapping, member, members, moveType, Crawler.Member.pos, radius, EScriptable.rnd(), Point.Set(), Size, MapBounds.Size, skipBorder, Cell.sourceBlock, stickToStartBiome, and sync.

◆ CrawlUntil()

bool Crawler.CrawlUntil ( Map  map,
Func< Point onStart,
int  tries,
Func< Result, bool >  canComplete,
Action  onFail = null 
)
inline

Definition at line 57 of file Crawler.cs.

58 {
59 if (tries <= 0)
60 {
61 return false;
62 }
63 for (int i = 0; i < tries; i++)
64 {
65 bool flag = false;
66 for (int j = 0; j < 100; j++)
67 {
68 Point point = onStart();
69 switch (startType)
70 {
71 case StartType.Surface:
72 if (!point.HasBlock)
73 {
74 flag = true;
75 }
76 break;
77 case StartType.Block:
78 if (point.sourceBlock.tileType.IsFullBlock && point.Installed == null)
79 {
80 flag = true;
81 }
82 break;
83 }
84 }
85 if (!flag)
86 {
87 continue;
88 }
89 Result arg = Crawl(map, onStart());
90 if (canComplete(arg))
91 {
92 if (i > 0)
93 {
94 Debug.Log("CrawlUntil Complete:" + i);
95 }
96 return true;
97 }
98 }
99 if (onFail != null)
100 {
101 Debug.Log("CrawlUntil Fail" + tries);
102 onFail?.Invoke();
103 }
104 return false;
105 }
StartType startType
Definition: Crawler.cs:47
StartType
Definition: Crawler.cs:26
Thing Installed
Definition: Point.cs:303
SourceBlock.Row sourceBlock
Definition: Point.cs:63
bool HasBlock
Definition: Point.cs:141

References Crawl(), Debug, Point.HasBlock, Point.Installed, Point.sourceBlock, and startType.

Referenced by MapGenDungen.OnGenerateTerrain(), MapGen.Populate(), Zone.SpawnAltar(), and Zone.TryGenerateOre().

◆ Create()

static Crawler Crawler.Create ( string  id)
inlinestatic

Definition at line 190 of file Crawler.cs.

191 {
192 return ResourceCache.Load<Crawler>("World/Map/Crawler/crawler " + id);
193 }

Referenced by MapGenDungen.OnGenerateTerrain(), MapGen.Populate(), and Zone.TryGenerateOre().

Member Data Documentation

◆ life

int Crawler.life

Definition at line 35 of file Crawler.cs.

Referenced by Crawl().

◆ mapping

int [,] Crawler.mapping = new int[0, 0]
static

Definition at line 31 of file Crawler.cs.

Referenced by Crawl().

◆ member

int Crawler.member

Definition at line 37 of file Crawler.cs.

Referenced by Crawl().

◆ members

List<Member> Crawler.members = new List<Member>()

Definition at line 55 of file Crawler.cs.

Referenced by Crawl().

◆ moveType

MoveType Crawler.moveType

Definition at line 49 of file Crawler.cs.

Referenced by Crawl().

◆ radius

int Crawler.radius

Definition at line 39 of file Crawler.cs.

Referenced by Crawl().

◆ repeat

int Crawler.repeat

Definition at line 41 of file Crawler.cs.

Referenced by Crawl().

◆ Size

int Crawler.Size

Definition at line 52 of file Crawler.cs.

Referenced by Crawl().

◆ skipBorder

bool Crawler.skipBorder

Definition at line 45 of file Crawler.cs.

Referenced by Crawl().

◆ startType

StartType Crawler.startType

Definition at line 47 of file Crawler.cs.

Referenced by CrawlUntil().

◆ stickToStartBiome

bool Crawler.stickToStartBiome

Definition at line 43 of file Crawler.cs.

Referenced by Crawl().

◆ sync

int Crawler.sync
static

Definition at line 33 of file Crawler.cs.

Referenced by Crawl().


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