Elin Decompiled Documentation EA 23.153 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 21 of file Crawler.cs.

◆ StartType

Enumerator
Surface 
Block 

Definition at line 27 of file Crawler.cs.

28 {
29 Surface,
30 Block
31 }

Member Function Documentation

◆ Crawl() [1/2]

void Crawler.Crawl ( Map  map)
inline

Definition at line 109 of file Crawler.cs.

110 {
111 for (int i = 0; (float)i < map.sizeModifier * (float)repeat + 1f; i++)
112 {
113 Crawl(map, map.GetRandomSurface(), delegate(Point p)
114 {
115 p.cell.biome.Populate(p);
116 });
117 }
118 }
void Populate(Point point, bool interior=false)
BiomeProfile biome
Definition: Cell.cs:1075
void Crawl(Map map)
Definition: Crawler.cs:109
int repeat
Definition: Crawler.cs:43
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 120 of file Crawler.cs.

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

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 59 of file Crawler.cs.

60 {
61 if (tries <= 0)
62 {
63 return false;
64 }
65 for (int i = 0; i < tries; i++)
66 {
67 bool flag = false;
68 for (int j = 0; j < 100; j++)
69 {
70 Point point = onStart();
71 switch (startType)
72 {
73 case StartType.Surface:
74 if (!point.HasBlock)
75 {
76 flag = true;
77 }
78 break;
79 case StartType.Block:
80 if (point.sourceBlock.tileType.IsFullBlock && point.Installed == null)
81 {
82 flag = true;
83 }
84 break;
85 }
86 }
87 if (!flag)
88 {
89 continue;
90 }
91 Result arg = Crawl(map, onStart());
92 if (canComplete(arg))
93 {
94 if (i > 0)
95 {
96 Debug.Log("CrawlUntil Complete:" + i);
97 }
98 return true;
99 }
100 }
101 if (onFail != null)
102 {
103 Debug.Log("CrawlUntil Fail" + tries);
104 onFail?.Invoke();
105 }
106 return false;
107 }
StartType startType
Definition: Crawler.cs:49
StartType
Definition: Crawler.cs:28
Thing Installed
Definition: Point.cs:315
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 Zone.Generate(), MapGenDungen.OnGenerateTerrain(), MapGen.Populate(), Zone.SpawnAltar(), and Zone.TryGenerateOre().

◆ Create()

static Crawler Crawler.Create ( string  id)
inlinestatic

Definition at line 193 of file Crawler.cs.

194 {
195 return ResourceCache.Load<Crawler>("World/Map/Crawler/crawler " + id);
196 }

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

Member Data Documentation

◆ life

int Crawler.life

Definition at line 37 of file Crawler.cs.

Referenced by Crawl().

◆ mapping

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

Definition at line 33 of file Crawler.cs.

Referenced by Crawl().

◆ member

int Crawler.member

Definition at line 39 of file Crawler.cs.

Referenced by Crawl().

◆ members

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

Definition at line 57 of file Crawler.cs.

Referenced by Crawl().

◆ moveType

MoveType Crawler.moveType

Definition at line 51 of file Crawler.cs.

Referenced by Crawl().

◆ radius

int Crawler.radius

Definition at line 41 of file Crawler.cs.

Referenced by Crawl().

◆ repeat

int Crawler.repeat

Definition at line 43 of file Crawler.cs.

Referenced by Crawl().

◆ Size

int Crawler.Size

Definition at line 54 of file Crawler.cs.

Referenced by Crawl().

◆ skipBorder

bool Crawler.skipBorder

Definition at line 47 of file Crawler.cs.

Referenced by Crawl().

◆ startType

StartType Crawler.startType

Definition at line 49 of file Crawler.cs.

Referenced by CrawlUntil().

◆ stickToStartBiome

bool Crawler.stickToStartBiome

Definition at line 45 of file Crawler.cs.

Referenced by Crawl().

◆ sync

int Crawler.sync
static

Definition at line 35 of file Crawler.cs.

Referenced by Crawl().


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