Elin Decompiled Documentation EA 23.198 Nightly Patch 1
Loading...
Searching...
No Matches
EloMap Class Reference
Inheritance diagram for EloMap:
EClass

Classes

class  Cell
 
class  TileInfo
 

Public Member Functions

void Init (EloMapActor _actor)
 
void SetZone (int gx, int gy, Zone z, bool updateMesh=false)
 
Cell GetCell (Point pos)
 
Cell GetCell (int gx, int gy)
 
TileInfo GetTileInfo (int gx, int gy)
 
List< SourceGlobalTile.RowGetSources (int gx, int gy)
 
bool CanBuildSite (int gx, int gy, int radius=0, ElomapSiteType type=ElomapSiteType.Nefia)
 
bool IsWater (int gx, int gy)
 
bool IsSnow (int gx, int gy)
 
Zone GetZone (Point p)
 
Zone GetZone (int gx, int gy)
 
int GetRoadDist (int gx, int gy)
 
void AddLight (int gx, int gy, string id="elolight")
 
void RemoveLight (int gx, int gy)
 

Public Attributes

int[,] _ints
 
Cell[,] cells
 
TilemapGroup group
 
STETilemap fogmap
 
STETilemap seaMap
 
STETilemap objScatterMap
 
STETilemap objmap
 
STETilemap extramap
 
STETilemap cloudmap
 
int w
 
int h
 
int minX
 
int minY
 
bool initialized
 
EloMapActor actor
 

Package Functions

void OnSerializing (StreamingContext context)
 
void OnDeserialized (StreamingContext context)
 

Properties

Region region [get]
 
string idMap [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 rndSeed (int a, int seed)
 
static int rnd (long a)
 
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 7 of file EloMap.cs.

Member Function Documentation

◆ AddLight()

void EloMap.AddLight ( int  gx,
int  gy,
string  id = "elolight" 
)
inline

Definition at line 497 of file EloMap.cs.

498 {
499 SpriteRenderer spriteRenderer = Util.Instantiate<SpriteRenderer>(id, actor.transLight);
501 {
502 sr = spriteRenderer,
503 gx = gx,
504 gy = gy
505 };
506 actor.lights.Add(item);
507 spriteRenderer.transform.position = TilemapUtils.GetGridWorldPos(fogmap, gx, gy);
508 }
Transform transLight
Definition: EloMapActor.cs:11
List< EloMapLight > lights
Definition: EloMapActor.cs:19
STETilemap fogmap
Definition: EloMap.cs:96
EloMapActor actor
Definition: EloMap.cs:118
Definition: Util.cs:10
static Transform Instantiate(string path, Component parent=null)
Definition: Util.cs:67

References actor, fogmap, item, EloMapActor.lights, EloMapActor.transLight, and Util.

Referenced by Init(), and SetZone().

◆ CanBuildSite()

bool EloMap.CanBuildSite ( int  gx,
int  gy,
int  radius = 0,
ElomapSiteType  type = ElomapSiteType::Nefia 
)
inline

Definition at line 358 of file EloMap.cs.

359 {
360 if (radius != 0)
361 {
362 for (int i = gy - radius; i < gy + radius + 1; i++)
363 {
364 for (int j = gx - radius; j < gx + radius + 1; j++)
365 {
366 if (!CanBuildSite(j, i, 0, type))
367 {
368 return false;
369 }
370 }
371 }
372 return true;
373 }
374 Cell cell = GetCell(gx, gy);
375 if (cell == null || cell.zone != null || cloudmap.GetTileData(gx, gy) != uint.MaxValue)
376 {
377 return false;
378 }
379 SourceGlobalTile.Row row = GetSources(gx, gy).LastItem();
380 if (row == null)
381 {
382 return false;
383 }
384 switch (type)
385 {
386 case ElomapSiteType.NefiaWater:
387 if (row.id != 4)
388 {
389 return false;
390 }
391 break;
392 case ElomapSiteType.Mob:
393 if (row.id == 4 && EClass.rnd(5) == 0)
394 {
395 return false;
396 }
397 if (row.id == 7 && EClass.rnd(2) == 0)
398 {
399 return false;
400 }
401 break;
402 default:
403 if (row == null || !row.tag.Contains("site"))
404 {
405 return false;
406 }
407 if (row.id == 7 && EClass.rnd(5) == 0)
408 {
409 return false;
410 }
411 break;
412 }
413 return true;
414 }
ElomapSiteType
Definition: Cell.cs:7
Definition: EClass.cs:5
static int rnd(long a)
Definition: EClass.cs:58
Cell GetCell(Point pos)
Definition: EloMap.cs:272
bool CanBuildSite(int gx, int gy, int radius=0, ElomapSiteType type=ElomapSiteType.Nefia)
Definition: EloMap.cs:358
List< SourceGlobalTile.Row > GetSources(int gx, int gy)
Definition: EloMap.cs:341
STETilemap cloudmap
Definition: EloMap.cs:106

References CanBuildSite(), cloudmap, GetCell(), GetSources(), SourceGlobalTile.Row.id, EClass.rnd(), SourceGlobalTile.Row.tag, and EloMap.Cell.zone.

Referenced by CanBuildSite(), TraitScrollMapTreasure.GetDest(), and Region.GetRandomPoint().

◆ GetCell() [1/2]

Cell EloMap.GetCell ( int  gx,
int  gy 
)
inline

Definition at line 277 of file EloMap.cs.

278 {
279 if (gx < minX || gy < minY || gx >= minX + w || gy >= minY + h)
280 {
281 return null;
282 }
283 return cells[gx - minX, gy - minY];
284 }
Cell[,] cells
Definition: EloMap.cs:92
int minX
Definition: EloMap.cs:112
int w
Definition: EloMap.cs:108
int minY
Definition: EloMap.cs:114
int h
Definition: EloMap.cs:110

References cells, h, minX, minY, and w.

◆ GetCell() [2/2]

Cell EloMap.GetCell ( Point  pos)
inline

◆ GetRoadDist()

int EloMap.GetRoadDist ( int  gx,
int  gy 
)
inline

Definition at line 466 of file EloMap.cs.

467 {
468 if (!initialized)
469 {
471 }
472 for (int i = 0; i < 100; i++)
473 {
474 for (int j = gy - i; j < gy + i + 1; j++)
475 {
476 for (int k = gx - i; k < gx + i + 1; k++)
477 {
478 if (j == gy - i || j == gy + i || k == gx - i || k == gx + i)
479 {
480 uint tileData = objScatterMap.GetTileData(k, j);
481 if (((tileData != uint.MaxValue) ? ((tileData & 0xFFF0000) >> 16) : 0) == 3)
482 {
483 return i;
484 }
485 tileData = seaMap.GetTileData(k, j);
486 if (((tileData != uint.MaxValue) ? ((tileData & 0xFFF0000) >> 16) : 0) == 3)
487 {
488 return i;
489 }
490 }
491 }
492 }
493 }
494 return 100;
495 }
static Scene scene
Definition: EClass.cs:30
static World world
Definition: EClass.cs:40
void Initialize(EloMap _elomap)
Definition: EloMapActor.cs:28
STETilemap seaMap
Definition: EloMap.cs:98
STETilemap objScatterMap
Definition: EloMap.cs:100
bool initialized
Definition: EloMap.cs:116
EloMap elomap
Definition: Region.cs:8
EloMapActor elomapActor
Definition: Scene.cs:101
Region region
Definition: World.cs:23

References Region.elomap, Scene.elomapActor, EloMapActor.Initialize(), initialized, objScatterMap, World.region, EClass.scene, seaMap, and EClass.world.

Referenced by Player.EnterLocalZone(), and RegionPoint.SetRegionPoint().

◆ GetSources()

List< SourceGlobalTile.Row > EloMap.GetSources ( int  gx,
int  gy 
)
inline

Definition at line 341 of file EloMap.cs.

342 {
343 List<SourceGlobalTile.Row> list = new List<SourceGlobalTile.Row>();
344 foreach (STETilemap tilemap in group.Tilemaps)
345 {
346 if (!(tilemap == fogmap))
347 {
348 int tileIdFromTileData = Tileset.GetTileIdFromTileData(tilemap.GetTileData(gx, gy));
349 if (EClass.sources.globalTiles.tileAlias.ContainsKey(tileIdFromTileData))
350 {
351 list.Add(EClass.sources.globalTiles.tileAlias.TryGetValue(tileIdFromTileData));
352 }
353 }
354 }
355 return list;
356 }
static SourceManager sources
Definition: EClass.cs:42
TilemapGroup group
Definition: EloMap.cs:94
Dictionary< int, Row > tileAlias
SourceGlobalTile globalTiles

References fogmap, SourceManager.globalTiles, group, EClass.sources, and SourceGlobalTile.tileAlias.

Referenced by CanBuildSite(), IsSnow(), and IsWater().

◆ GetTileInfo()

TileInfo EloMap.GetTileInfo ( int  gx,
int  gy 
)
inline

Definition at line 286 of file EloMap.cs.

287 {
288 TileInfo t = new TileInfo();
289 bool skip = false;
290 group.Tilemaps.ForeachReverse(delegate(STETilemap m)
291 {
292 if (!(m == fogmap || skip))
293 {
294 int tileIdFromTileData = Tileset.GetTileIdFromTileData(m.GetTileData(gx, gy));
295 TileData tileData = new TileData(m.GetTileData(gx, gy));
296 int tileId = tileData.tileId;
297 if (tileId >= 22 && tileId <= 25)
298 {
299 bool flipHorizontal = tileData.flipHorizontal;
300 bool flipVertical = tileData.flipVertical;
301 bool rot = tileData.rot90;
302 int num = (flipHorizontal ? 1 : 0) + (flipVertical ? 1 : 0) * 2 + (rot ? 1 : 0) * 4;
303 t.isRoad = true;
304 t.roadLeft = tileId == 23 || (tileId == 24 && (num == 4 || num == 0)) || (tileId == 25 && num != 6);
305 t.roadRight = tileId == 23 || (tileId == 24 && (num == 6 || num == 1)) || (tileId == 25 && num != 4);
306 t.roadUp = tileId == 22 || (tileId == 24 && (num == 4 || num == 6)) || (tileId == 25 && num != 0);
307 t.roadDown = tileId == 22 || (tileId == 24 && (num == 0 || num == 1)) || (tileId == 25 && num != 2);
308 }
309 SourceGlobalTile.Row row = EClass.sources.globalTiles.tileAlias.TryGetValue(tileIdFromTileData);
310 if (row != null)
311 {
312 t.source = row;
313 t.sprite = TilemapUtils.GetOrCreateTileSprite(actor.tileset, row.tiles[0]);
314 switch (row.alias)
315 {
316 case "wall":
317 case "rock":
318 t.rock = true;
319 break;
320 case "sea":
321 t.sea = true;
322 break;
323 case "beach":
324 t.shore = true;
325 break;
326 }
327 if (!row.zoneProfile.IsEmpty())
328 {
329 skip = true;
330 }
331 else if (row.attribs[0] == 0)
332 {
333 t.blocked = true;
334 }
335 }
336 }
337 });
338 return t;
339 }
if(item3.idFile==idFirstFile &&item3.id==idFirstTopic)
Definition: UIBook.cs:627
Tileset tileset
Definition: EloMapActor.cs:15

References actor, SourceGlobalTile.Row.alias, SourceGlobalTile.Row.attribs, fogmap, SourceManager.globalTiles, group, if(), EClass.sources, SourceGlobalTile.tileAlias, SourceGlobalTile.Row.tiles, EloMapActor.tileset, and SourceGlobalTile.Row.zoneProfile.

Referenced by Region.CanCreateZone(), Spatial.Dist(), Zone.GetProfile(), Region.OnActivate(), TileSelectorElona.OnRenderTile(), TileSelectorElona.OnUpdateInput(), Weather.RefreshWeather(), RegionPoint.SetRegionPoint(), and Chara.Tick().

◆ GetZone() [1/2]

Zone EloMap.GetZone ( int  gx,
int  gy 
)
inline

Definition at line 453 of file EloMap.cs.

454 {
455 Zone zone = null;
456 foreach (Spatial child in region.children)
457 {
458 if (child.x == gx && child.y == gy && (child as Zone)?.instance == null && (zone == null || zone is Zone_Field))
459 {
460 zone = child as Zone;
461 }
462 }
463 return zone;
464 }
Region region
Definition: EloMap.cs:120
int y
Definition: Spatial.cs:106
int x
Definition: Spatial.cs:94
List< Spatial > children
Definition: Spatial.cs:37
Definition: Zone.cs:12

References Spatial.children, region, Spatial.x, and Spatial.y.

◆ GetZone() [2/2]

Zone EloMap.GetZone ( Point  p)
inline

Definition at line 448 of file EloMap.cs.

449 {
450 return GetZone(p.x + minX, p.z + minY);
451 }
Zone GetZone(Point p)
Definition: EloMap.cs:448

References GetZone(), minX, minY, Point.x, and Point.z.

Referenced by GetZone(), EloMapTileSelector.OnUpdateInput(), TileSelectorElona.OnUpdateInput(), LayerTravel.Refresh(), and PointTarget.Update().

◆ Init()

void EloMap.Init ( EloMapActor  _actor)
inline

Definition at line 160 of file EloMap.cs.

161 {
162 if (initialized)
163 {
164 return;
165 }
166 actor = _actor;
167 initialized = true;
168 group = actor.transMap.GetComponentInChildren<TilemapGroup>();
169 seaMap = group.Tilemaps[0];
170 cloudmap = group.Tilemaps[7];
171 extramap = group.Tilemaps[6];
172 fogmap = group.Tilemaps[5];
173 objmap = group.Tilemaps[4];
174 objScatterMap = group.Tilemaps[3];
175 w = fogmap.GridWidth;
176 h = fogmap.GridHeight;
177 minX = fogmap.MinGridX;
178 minY = fogmap.MinGridY;
179 if (cells == null)
180 {
181 cells = new Cell[w, h];
182 for (int i = 0; i < h; i++)
183 {
184 for (int j = 0; j < w; j++)
185 {
186 cells[j, i] = new Cell();
187 }
188 }
189 }
190 foreach (Spatial child in region.children)
191 {
192 int x = child.x;
193 int y = child.y;
194 Zone zone = child as Zone;
195 Cell cell = GetCell(x, y);
196 if (cell == null)
197 {
198 Debug.Log("cell is null:" + x + "/" + y);
199 }
200 else if (!zone.IsInstance)
201 {
202 cell.zone = zone;
203 cell.obj = zone.icon;
204 }
205 }
206 for (int k = 0; k < h; k++)
207 {
208 for (int l = 0; l < w; l++)
209 {
210 Cell cell2 = cells[l, k];
211 int num = minX + l;
212 int num2 = minY + k;
213 if (cell2.obj != 0)
214 {
215 objmap.SetTile(num, num2, cell2.obj);
216 }
217 if (cell2.zone != null)
218 {
219 if (cell2.zone.UseLight)
220 {
221 AddLight(num, num2);
222 }
223 if (cell2.zone.IsClosed)
224 {
225 extramap.SetTile(num, num2, 333);
226 }
227 }
228 }
229 }
230 extramap.UpdateMeshImmediate();
231 objmap.UpdateMeshImmediate();
232 }
byte obj
Definition: Cell.cs:38
Transform transMap
Definition: EloMapActor.cs:9
STETilemap extramap
Definition: EloMap.cs:104
STETilemap objmap
Definition: EloMap.cs:102
void AddLight(int gx, int gy, string id="elolight")
Definition: EloMap.cs:497
int icon
Definition: Spatial.cs:82
bool IsInstance
Definition: Zone.cs:484

References actor, AddLight(), cells, Spatial.children, cloudmap, Debug, extramap, fogmap, GetCell(), group, h, Spatial.icon, initialized, Spatial.IsClosed, Zone.IsInstance, minX, minY, EloMap.Cell.obj, objmap, objScatterMap, region, seaMap, EloMapActor.transMap, Zone.UseLight, w, Spatial.x, Spatial.y, and EloMap.Cell.zone.

Referenced by EloMapActor.Initialize().

◆ IsSnow()

bool EloMap.IsSnow ( int  gx,
int  gy 
)
inline

Definition at line 434 of file EloMap.cs.

435 {
436 if (GetCell(gx, gy) == null)
437 {
438 return false;
439 }
440 SourceGlobalTile.Row row = GetSources(gx, gy).LastItem();
441 if (row != null)
442 {
443 return row.id == 7;
444 }
445 return false;
446 }

References GetCell(), and GetSources().

Referenced by Region.CreateRandomSite().

◆ IsWater()

bool EloMap.IsWater ( int  gx,
int  gy 
)
inline

Definition at line 416 of file EloMap.cs.

417 {
418 if (GetCell(gx, gy) == null)
419 {
420 return false;
421 }
422 SourceGlobalTile.Row row = GetSources(gx, gy).LastItem();
423 if (row != null)
424 {
425 if (row.id != 4)
426 {
427 return row.id == 15;
428 }
429 return true;
430 }
431 return false;
432 }

References GetCell(), GetSources(), and SourceGlobalTile.Row.id.

Referenced by Region.CreateRandomSite().

◆ OnDeserialized()

void EloMap.OnDeserialized ( StreamingContext  context)
inlinepackage

Definition at line 142 of file EloMap.cs.

143 {
144 if (_ints == null || _ints.GetLength(0) <= 0)
145 {
146 return;
147 }
148 w = _ints.GetLength(0);
149 h = _ints.GetLength(1);
150 cells = new Cell[w, h];
151 for (int i = 0; i < h; i++)
152 {
153 for (int j = 0; j < w; j++)
154 {
155 cells[j, i] = new Cell(_ints[j, i]);
156 }
157 }
158 }
int[,] _ints
Definition: EloMap.cs:90

References _ints, cells, h, and w.

◆ OnSerializing()

void EloMap.OnSerializing ( StreamingContext  context)
inlinepackage

Definition at line 125 of file EloMap.cs.

126 {
127 if (cells == null)
128 {
129 return;
130 }
131 _ints = new int[w, h];
132 for (int i = 0; i < h; i++)
133 {
134 for (int j = 0; j < w; j++)
135 {
136 _ints[j, i] = cells[j, i].GetInt();
137 }
138 }
139 }
int GetInt()
Definition: EloMap.cs:24

References _ints, cells, EloMap.Cell.GetInt(), h, and w.

◆ RemoveLight()

void EloMap.RemoveLight ( int  gx,
int  gy 
)
inline

Definition at line 510 of file EloMap.cs.

511 {
512 foreach (EloMapLight light in actor.lights)
513 {
514 if (light.gx == gx && light.gy == gy)
515 {
516 Object.DestroyImmediate(light.sr.gameObject);
517 actor.lights.Remove(light);
518 break;
519 }
520 }
521 }
SpriteRenderer sr
Definition: EloMapLight.cs:5

References actor, EloMapLight.gx, EloMapLight.gy, EloMapActor.lights, and EloMapLight.sr.

Referenced by SetZone().

◆ SetZone()

void EloMap.SetZone ( int  gx,
int  gy,
Zone  z,
bool  updateMesh = false 
)
inline

Definition at line 234 of file EloMap.cs.

235 {
236 Cell cell = GetCell(gx, gy);
237 if (cell == null)
238 {
239 Debug.Log("cell is null:" + gx + "/" + gy);
240 }
241 else if (z == null || cell.obj != z.icon)
242 {
243 cell.obj = z?.icon ?? 0;
244 if (z != null && z.source.tag.Contains("iconFlag"))
245 {
246 cell.obj = 306;
247 }
248 if (cell.zone != null && cell.zone.UseLight)
249 {
250 RemoveLight(gx, gy);
251 }
252 cell.zone = z;
253 if (cell.obj == 0)
254 {
255 objmap.Erase(gx, gy);
256 }
257 else
258 {
259 objmap.SetTile(gx, gy, cell.obj);
260 }
261 if (z != null && z.UseLight)
262 {
263 AddLight(gx, gy);
264 }
265 if (updateMesh)
266 {
267 objmap.UpdateMeshImmediate();
268 }
269 }
270 }
void RemoveLight(int gx, int gy)
Definition: EloMap.cs:510
SourceZone.Row source
Definition: Spatial.cs:441
virtual bool UseLight
Definition: Zone.cs:393

References AddLight(), Debug, GetCell(), Spatial.icon, EloMap.Cell.obj, objmap, RemoveLight(), Spatial.source, Zone.UseLight, and EloMap.Cell.zone.

Referenced by Zone.ClaimZone(), Region.CreateRandomSite(), Zone.Destroy(), TraitDeedRelocate.OnRead(), and TraitMapBoard.TrySetAct().

Member Data Documentation

◆ _ints

int [,] EloMap._ints

Definition at line 90 of file EloMap.cs.

Referenced by OnDeserialized(), and OnSerializing().

◆ actor

◆ cells

Cell [,] EloMap.cells

◆ cloudmap

STETilemap EloMap.cloudmap

Definition at line 106 of file EloMap.cs.

Referenced by CanBuildSite(), Init(), and MapGenRegion.OnGenerateTerrain().

◆ extramap

STETilemap EloMap.extramap

Definition at line 104 of file EloMap.cs.

Referenced by Init().

◆ fogmap

◆ group

TilemapGroup EloMap.group

Definition at line 94 of file EloMap.cs.

Referenced by GetSources(), GetTileInfo(), Init(), and MapGenRegion.OnGenerateTerrain().

◆ h

int EloMap.h

◆ initialized

bool EloMap.initialized

Definition at line 116 of file EloMap.cs.

Referenced by GetRoadDist(), Init(), and EloMapActor.Initialize().

◆ minX

◆ minY

◆ objmap

STETilemap EloMap.objmap

◆ objScatterMap

STETilemap EloMap.objScatterMap

Definition at line 100 of file EloMap.cs.

Referenced by GetRoadDist(), and Init().

◆ seaMap

STETilemap EloMap.seaMap

Definition at line 98 of file EloMap.cs.

Referenced by GetRoadDist(), and Init().

◆ w

int EloMap.w

Property Documentation

◆ idMap

string EloMap.idMap
get

Definition at line 122 of file EloMap.cs.

Referenced by EloMapActor.Initialize().

◆ region

Region EloMap.region
get

Definition at line 120 of file EloMap.cs.

Referenced by GetZone(), and Init().


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