Elin Decompiled Documentation EA 23.102 Nightly
All Classes Namespaces Files Functions Variables Enumerations Enumerator Properties Events Pages
MapBounds Class Reference
Inheritance diagram for MapBounds:
EClass Map

Public Member Functions

void SetBounds (int _x, int _z, int _maxX, int _maxZ)
 
bool Contains (int dx, int dz)
 
bool Contains (Point p)
 
Point GetCenterPos ()
 
Point GetRandomTopPos ()
 
Point GetRandomRightPos ()
 
Point GetRandomBottomPos ()
 
Point GetRandomLeftPos ()
 
Point GetTopPos (float rate=-1f)
 
Point GetRightPos (float rate=-1f)
 
Point GetBottomPos (float rate=-1f)
 
Point GetLeftPos (float rate=-1f)
 
Point GetRandomPoint ()
 
Point GetSpawnPos (int x, int z, int maxX, int maxZ)
 
bool CanExpand (int a)
 
void Expand (int a)
 
Point GetSurface (int x, int z, bool walkable=true)
 
Point GetRandomSurface (int x, int z, int radius, bool walkable=true, bool allowWater=false)
 
Point GetRandomSurface (bool centered=false, bool walkable=true, bool allowWater=false)
 
Point GetRandomSpawnPos ()
 
Point GetRandomEdge (int r=3)
 
Point GetRandomSpace (int width, int height, int tries=100)
 
void ForeachCell (Action< Cell > action)
 
void ForeachPoint (Action< Point > action)
 
void ForeachXYZ (Action< int, int > action)
 

Public Attributes

int x
 
int z
 
int maxX
 
int maxZ
 
int Size
 

Properties

int CenterX [get]
 
int CenterZ [get]
 
int Width [get]
 
int Height [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]
 

Additional Inherited Members

- 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)
 
- Static Public Attributes inherited from EClass
static Core core
 

Detailed Description

Definition at line 5 of file MapBounds.cs.

Member Function Documentation

◆ CanExpand()

bool MapBounds.CanExpand ( int  a)
inline

Definition at line 138 of file MapBounds.cs.

139 {
140 if (x - a < 1 && z - a < 1 && maxX + a >= EClass._map.Size - 1)
141 {
142 return maxZ + a < EClass._map.Size - 1;
143 }
144 return true;
145 }
Definition: EClass.cs:5
static Map _map
Definition: EClass.cs:18
int Size
Definition: MapBounds.cs:20
int maxZ
Definition: MapBounds.cs:17
int x
Definition: MapBounds.cs:8

References EClass._map, maxZ, Size, x, and z.

◆ Contains() [1/2]

bool MapBounds.Contains ( int  dx,
int  dz 
)
inline

Definition at line 38 of file MapBounds.cs.

39 {
40 if (dx >= x && dz >= z && dx <= maxX)
41 {
42 return dz <= maxZ;
43 }
44 return false;
45 }
int maxX
Definition: MapBounds.cs:14

References maxX, maxZ, x, and z.

Referenced by UIMapPreview._RefreshPoint(), PartialMap.Apply(), Contains(), Point.ForeachNearestPoint(), Point.GetNearestPoint(), and AM_MoveInstalled.HitTest().

◆ Contains() [2/2]

bool MapBounds.Contains ( Point  p)
inline

Definition at line 47 of file MapBounds.cs.

48 {
49 return Contains(p.x, p.z);
50 }
bool Contains(int dx, int dz)
Definition: MapBounds.cs:38
int x
Definition: Point.cs:36
int z
Definition: Point.cs:39

References Contains(), Point.x, and Point.z.

◆ Expand()

void MapBounds.Expand ( int  a)
inline

Definition at line 147 of file MapBounds.cs.

148 {
149 x -= a;
150 z -= a;
151 maxX += a;
152 maxZ += a;
153 if (x < 1)
154 {
155 x = 1;
156 }
157 if (z < 1)
158 {
159 z = 1;
160 }
161 if (maxX >= EClass._map.Size - 1)
162 {
163 maxX = EClass._map.Size - 2;
164 }
165 if (maxZ >= EClass._map.Size - 1)
166 {
167 maxZ = EClass._map.Size - 2;
168 }
169 }

References EClass._map, maxX, maxZ, Size, x, and z.

◆ ForeachCell()

void MapBounds.ForeachCell ( Action< Cell action)
inline

Definition at line 279 of file MapBounds.cs.

280 {
281 Cell[,] cells = EClass._map.cells;
282 for (int i = x; i <= maxX; i++)
283 {
284 for (int j = z; j <= maxZ; j++)
285 {
286 action(cells[i, j]);
287 }
288 }
289 }
Definition: Cell.cs:7
Cell[,] cells
Definition: Map.cs:85

References EClass._map, Map.cells, maxX, maxZ, x, and z.

Referenced by Map.AddBackerTree(), QuestVernis.CanUpdateOnTalk(), FactionBranch.DailyOutcome(), HomeResourceNature.GetDestValue(), Zone.GetElectricity(), Zone.GetSoilCost(), QuestVernis.GetTextProgress(), Zone.GrowPlants(), Zone.RainWater(), and Zone.RefreshElectricity().

◆ ForeachPoint()

void MapBounds.ForeachPoint ( Action< Point action)
inline

Definition at line 291 of file MapBounds.cs.

292 {
293 Point point = new Point();
294 for (int i = x; i <= maxX; i++)
295 {
296 for (int j = z; j <= maxZ; j++)
297 {
298 action(point.Set(i, j));
299 }
300 }
301 }
Definition: Point.cs:9
Point Set(int _x, int _z)
Definition: Point.cs:479

References maxX, maxZ, Point.Set(), x, and z.

Referenced by TaskWater.ListPoints().

◆ ForeachXYZ()

void MapBounds.ForeachXYZ ( Action< int, int >  action)
inline

Definition at line 303 of file MapBounds.cs.

304 {
305 for (int i = x; i <= maxX; i++)
306 {
307 for (int j = z; j <= maxZ; j++)
308 {
309 action(i, j);
310 }
311 }
312 }

References maxX, maxZ, x, and z.

◆ GetBottomPos()

Point MapBounds.GetBottomPos ( float  rate = -1f)
inline

Definition at line 87 of file MapBounds.cs.

88 {
89 return GetSpawnPos(x, z, maxX, z);
90 }
Point GetSpawnPos(int x, int z, int maxX, int maxZ)
Definition: MapBounds.cs:102

References GetSpawnPos(), maxX, x, and z.

Referenced by Zone.GetSpawnPos().

◆ GetCenterPos()

◆ GetLeftPos()

Point MapBounds.GetLeftPos ( float  rate = -1f)
inline

Definition at line 92 of file MapBounds.cs.

93 {
94 return GetSpawnPos(x, z, x, maxZ);
95 }

References GetSpawnPos(), maxZ, x, and z.

Referenced by Zone.GetSpawnPos().

◆ GetRandomBottomPos()

Point MapBounds.GetRandomBottomPos ( )
inline

Definition at line 67 of file MapBounds.cs.

68 {
69 return new Point(x + EClass.rnd(maxX - x), z);
70 }
static int rnd(int a)
Definition: EClass.cs:50

References maxX, EClass.rnd(), x, and z.

◆ GetRandomEdge()

Point MapBounds.GetRandomEdge ( int  r = 3)
inline

Definition at line 221 of file MapBounds.cs.

222 {
223 int num = 0;
224 int num2 = 0;
225 for (int i = 0; i < 10000; i++)
226 {
227 if (EClass.rnd(2) == 0)
228 {
229 num = ((EClass.rnd(2) == 0) ? (x + EClass.rnd(r)) : (maxX - EClass.rnd(r)));
230 num2 = z + EClass.rnd(Height);
231 }
232 else
233 {
234 num2 = ((EClass.rnd(2) == 0) ? (z + EClass.rnd(r)) : (maxZ - EClass.rnd(r)));
235 num = x + EClass.rnd(Width);
236 }
237 Point surface = GetSurface(num, num2, walkable: false);
238 if (surface.IsValid)
239 {
240 return surface;
241 }
242 }
243 return GetSurface(Size / 2, Size / 2, walkable: false);
244 }
Point GetSurface(int x, int z, bool walkable=true)
Definition: MapBounds.cs:171
int Width
Definition: MapBounds.cs:26
int Height
Definition: MapBounds.cs:28
bool IsValid
Definition: Point.cs:88

References GetSurface(), Height, Point.IsValid, maxX, maxZ, EClass.rnd(), Size, Width, x, and z.

Referenced by ZoneEventQuest.Spawn(), and ZoneEventQuest.SpawnBoss().

◆ GetRandomLeftPos()

Point MapBounds.GetRandomLeftPos ( )
inline

Definition at line 72 of file MapBounds.cs.

73 {
74 return new Point(x, z + EClass.rnd(maxZ - z));
75 }

References maxZ, EClass.rnd(), x, and z.

◆ GetRandomPoint()

◆ GetRandomRightPos()

Point MapBounds.GetRandomRightPos ( )
inline

Definition at line 62 of file MapBounds.cs.

63 {
64 return new Point(maxX, z + EClass.rnd(maxZ - z));
65 }

References maxX, maxZ, EClass.rnd(), and z.

◆ GetRandomSpace()

Point MapBounds.GetRandomSpace ( int  width,
int  height,
int  tries = 100 
)
inline

Definition at line 246 of file MapBounds.cs.

247 {
248 Point point = new Point();
249 Point point2 = new Point();
250 for (int i = 0; i < tries; i++)
251 {
252 bool flag = true;
253 point2.Set(x + EClass.rnd(maxX - x), z + EClass.rnd(maxZ - z));
254 for (int j = 0; j < height; j++)
255 {
256 for (int k = 0; k < width; k++)
257 {
258 point.Set(point2.x + k, point2.z + j);
259 if (point.x > maxX || point.z > maxZ || point.IsBlocked || point.cell.HasZoneStairs())
260 {
261 flag = false;
262 break;
263 }
264 }
265 if (!flag)
266 {
267 break;
268 }
269 }
270 if (flag)
271 {
272 return point2;
273 }
274 }
275 Debug.Log("valid space not found:" + width + "/" + height);
276 return null;
277 }
bool HasZoneStairs(bool includeLocked=true)
Definition: Cell.cs:1713
bool IsBlocked
Definition: Point.cs:339
Cell cell
Definition: Point.cs:51

References Point.cell, Debug, Cell.HasZoneStairs(), Point.IsBlocked, maxX, maxZ, EClass.rnd(), Point.Set(), x, Point.x, z, and Point.z.

Referenced by Zone.TryGenerateShrine().

◆ GetRandomSpawnPos()

Point MapBounds.GetRandomSpawnPos ( )
inline

Definition at line 208 of file MapBounds.cs.

209 {
210 for (int i = 0; i < 10000; i++)
211 {
212 Point randomPoint = EClass._map.GetRandomPoint();
213 if (!randomPoint.cell.blocked && randomPoint.cell.room == null && randomPoint.cell.light <= 0 && randomPoint.IsValid)
214 {
215 return randomPoint;
216 }
217 }
218 return GetCenterPos().GetNearestPoint();
219 }
Room room
Definition: Cell.cs:102
byte light
Definition: Cell.cs:60
Point GetCenterPos()
Definition: MapBounds.cs:52
Point GetRandomPoint(Point center, int radius, int tries=100, bool mustBeWalkable=true, bool requireLos=true)
Definition: Map.cs:2193
Point GetNearestPoint(bool allowBlock=false, bool allowChara=true, bool allowInstalled=true, bool ignoreCenter=false)
Definition: Point.cs:595

References EClass._map, Algorithms.WeightCell.blocked, Point.cell, GetCenterPos(), Point.GetNearestPoint(), Map.GetRandomPoint(), Point.IsValid, Cell.light, and Cell.room.

Referenced by Zone_DungeonPuppy.OnGenerateMap().

◆ GetRandomSurface() [1/2]

Point MapBounds.GetRandomSurface ( bool  centered = false,
bool  walkable = true,
bool  allowWater = false 
)
inline

Definition at line 195 of file MapBounds.cs.

196 {
197 for (int i = 0; i < 10000; i++)
198 {
199 Point surface = GetSurface(centered ? (CenterX + EClass.rnd(Width / 4) - EClass.rnd(Width / 4)) : (x + EClass.rnd(Width)), centered ? (CenterZ + EClass.rnd(Height / 4) - EClass.rnd(Height / 4)) : (z + EClass.rnd(Height)), walkable);
200 if (surface.IsValid && (allowWater || !surface.IsWater))
201 {
202 return surface;
203 }
204 }
205 return GetSurface(CenterX, CenterZ, walkable: false);
206 }
bool IsWater
Definition: Point.cs:129

References CenterX, CenterZ, GetSurface(), Height, Point.IsValid, Point.IsWater, EClass.rnd(), Width, x, and z.

◆ GetRandomSurface() [2/2]

Point MapBounds.GetRandomSurface ( int  x,
int  z,
int  radius,
bool  walkable = true,
bool  allowWater = false 
)
inline

Definition at line 182 of file MapBounds.cs.

183 {
184 for (int i = 0; i < radius * radius * 2; i++)
185 {
186 Point surface = GetSurface(x + EClass.rnd(radius) - EClass.rnd(radius), z + EClass.rnd(radius) - EClass.rnd(radius), walkable);
187 if (surface.IsValid && (allowWater || !surface.IsWater))
188 {
189 return surface;
190 }
191 }
192 return EClass._map.GetCenterPos();
193 }

References EClass._map, GetCenterPos(), GetSurface(), Point.IsValid, Point.IsWater, EClass.rnd(), x, and z.

Referenced by Crawler.Crawl(), EffectMeteor.Create(), Zone.Generate(), FactionBranch.GenerateGarbage(), Zone_SnowGrave.GenerateGrave(), Zone.GetRandomVisitPos(), Zone.GetSpawnPos(), ZoneEventSiege.OnFirstTick(), TraitGiftNewYear.OnUse(), Zone_Dungeon.PlaceRail(), AIWork_Chore.SetDestPos(), Zone.TryAddThingInSpot< T >(), and Zone.TrySpawnFollower().

◆ GetRandomTopPos()

Point MapBounds.GetRandomTopPos ( )
inline

Definition at line 57 of file MapBounds.cs.

58 {
59 return new Point(x + EClass.rnd(maxX - x), maxZ);
60 }

References maxX, maxZ, EClass.rnd(), and x.

◆ GetRightPos()

Point MapBounds.GetRightPos ( float  rate = -1f)
inline

Definition at line 82 of file MapBounds.cs.

83 {
84 return GetSpawnPos(maxX, z, maxX, maxZ);
85 }

References GetSpawnPos(), maxX, maxZ, and z.

Referenced by Zone.GetSpawnPos().

◆ GetSpawnPos()

Point MapBounds.GetSpawnPos ( int  x,
int  z,
int  maxX,
int  maxZ 
)
inline

Definition at line 102 of file MapBounds.cs.

103 {
104 Point point = new Point();
105 for (int i = z; i < maxZ + 1; i++)
106 {
107 for (int j = x; j < maxX + 1; j++)
108 {
109 point.Set(j, i);
110 foreach (Thing thing in point.Things)
111 {
112 if (thing.trait is TraitRoadSign)
113 {
114 if (thing.dir == 0)
115 {
116 point.z--;
117 }
118 else if (thing.dir == 1)
119 {
120 point.x++;
121 }
122 else if (thing.dir == 2)
123 {
124 point.z++;
125 }
126 else
127 {
128 point.x--;
129 }
130 return point;
131 }
132 }
133 }
134 }
135 return new Point(x + (maxX - x) / 2, z + (maxZ - z) / 2);
136 }
Trait trait
Definition: Card.cs:49
int dir
Definition: Card.cs:142
List< Thing > Things
Definition: Point.cs:314
Definition: Thing.cs:8

References Card.dir, maxX, maxZ, Point.Set(), Point.Things, Card.trait, x, Point.x, z, and Point.z.

Referenced by GetBottomPos(), GetLeftPos(), GetRightPos(), and GetTopPos().

◆ GetSurface()

Point MapBounds.GetSurface ( int  x,
int  z,
bool  walkable = true 
)
inline

Definition at line 171 of file MapBounds.cs.

172 {
173 Point point = new Point(x, z);
174 point.Clamp();
175 if (!walkable || !point.cell.blocked)
176 {
177 return point;
178 }
179 return Point.Invalid;
180 }
static Point Invalid
Definition: Point.cs:28
Point Clamp(bool useBounds=false)
Definition: Point.cs:972

References Algorithms.WeightCell.blocked, Point.cell, Point.Clamp(), Point.Invalid, x, and z.

Referenced by Map.GetRandomEdge(), GetRandomEdge(), and GetRandomSurface().

◆ GetTopPos()

Point MapBounds.GetTopPos ( float  rate = -1f)
inline

Definition at line 77 of file MapBounds.cs.

78 {
79 return GetSpawnPos(x, maxZ, maxX, maxZ);
80 }

References GetSpawnPos(), maxX, maxZ, and x.

Referenced by Zone.GetSpawnPos().

◆ SetBounds()

void MapBounds.SetBounds ( int  _x,
int  _z,
int  _maxX,
int  _maxZ 
)
inline

Definition at line 30 of file MapBounds.cs.

31 {
32 x = _x;
33 z = _z;
34 maxX = _maxX;
35 maxZ = _maxZ;
36 }

References maxX, maxZ, x, and z.

Referenced by Map.Load(), and Map.SetBounds().

Member Data Documentation

◆ maxX

◆ maxZ

◆ Size

◆ x

◆ z

Property Documentation

◆ CenterX

int MapBounds.CenterX
get

Definition at line 22 of file MapBounds.cs.

Referenced by GetCenterPos(), and GetRandomSurface().

◆ CenterZ

int MapBounds.CenterZ
get

Definition at line 24 of file MapBounds.cs.

Referenced by GetCenterPos(), and GetRandomSurface().

◆ Height

◆ Width


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