Elin Decompiled Documentation EA 23.102 Nightly
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 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 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 469 of file EloMap.cs.

470 {
471 SpriteRenderer spriteRenderer = Util.Instantiate<SpriteRenderer>(id, actor.transLight);
473 {
474 sr = spriteRenderer,
475 gx = gx,
476 gy = gy
477 };
478 actor.lights.Add(item);
479 spriteRenderer.transform.position = TilemapUtils.GetGridWorldPos(fogmap, gx, gy);
480 }
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 359 of file EloMap.cs.

360 {
361 if (radius != 0)
362 {
363 for (int i = gy - radius; i < gy + radius + 1; i++)
364 {
365 for (int j = gx - radius; j < gx + radius + 1; j++)
366 {
367 if (!CanBuildSite(j, i))
368 {
369 return false;
370 }
371 }
372 }
373 return true;
374 }
375 Cell cell = GetCell(gx, gy);
376 if (cell == null || cell.zone != null || cloudmap.GetTileData(gx, gy) != uint.MaxValue)
377 {
378 return false;
379 }
380 SourceGlobalTile.Row row = GetSources(gx, gy).LastItem();
381 if (type == ElomapSiteType.Mob)
382 {
383 if (row.id == 4 && EClass.rnd(5) == 0)
384 {
385 return false;
386 }
387 if (row.id == 7 && EClass.rnd(2) == 0)
388 {
389 return false;
390 }
391 }
392 else
393 {
394 if (row == null || !row.tag.Contains("site"))
395 {
396 return false;
397 }
398 if (row.id == 7 && EClass.rnd(5) == 0)
399 {
400 return false;
401 }
402 }
403 return true;
404 }
ElomapSiteType
Definition: Cell.cs:7
Definition: EClass.cs:5
static int rnd(int a)
Definition: EClass.cs:50
Cell GetCell(Point pos)
Definition: EloMap.cs:273
bool CanBuildSite(int gx, int gy, int radius=0, ElomapSiteType type=ElomapSiteType.Nefia)
Definition: EloMap.cs:359
List< SourceGlobalTile.Row > GetSources(int gx, int gy)
Definition: EloMap.cs:342
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 278 of file EloMap.cs.

279 {
280 if (gx < minX || gy < minY || gx >= minX + w || gy >= minY + h)
281 {
282 return null;
283 }
284 return cells[gx - minX, gy - minY];
285 }
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 438 of file EloMap.cs.

439 {
440 if (!initialized)
441 {
443 }
444 for (int i = 0; i < 100; i++)
445 {
446 for (int j = gy - i; j < gy + i + 1; j++)
447 {
448 for (int k = gx - i; k < gx + i + 1; k++)
449 {
450 if (j == gy - i || j == gy + i || k == gx - i || k == gx + i)
451 {
452 uint tileData = objScatterMap.GetTileData(k, j);
453 if (((tileData != uint.MaxValue) ? ((tileData & 0xFFF0000) >> 16) : 0) == 3)
454 {
455 return i;
456 }
457 tileData = seaMap.GetTileData(k, j);
458 if (((tileData != uint.MaxValue) ? ((tileData & 0xFFF0000) >> 16) : 0) == 3)
459 {
460 return i;
461 }
462 }
463 }
464 }
465 }
466 return 100;
467 }
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:97
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 342 of file EloMap.cs.

343 {
344 List<SourceGlobalTile.Row> list = new List<SourceGlobalTile.Row>();
345 foreach (STETilemap tilemap in group.Tilemaps)
346 {
347 if (!(tilemap == fogmap))
348 {
349 int tileIdFromTileData = Tileset.GetTileIdFromTileData(tilemap.GetTileData(gx, gy));
350 if (EClass.sources.globalTiles.tileAlias.ContainsKey(tileIdFromTileData))
351 {
352 list.Add(EClass.sources.globalTiles.tileAlias.TryGetValue(tileIdFromTileData));
353 }
354 }
355 }
356 return list;
357 }
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(), and IsSnow().

◆ GetTileInfo()

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

Definition at line 287 of file EloMap.cs.

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

426 {
427 Zone zone = null;
428 foreach (Spatial child in region.children)
429 {
430 if (child.x == gx && child.y == gy && (child as Zone)?.instance == null && (zone == null || zone is Zone_Field))
431 {
432 zone = child as Zone;
433 }
434 }
435 return zone;
436 }
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 420 of file EloMap.cs.

421 {
422 return GetZone(p.x + minX, p.z + minY);
423 }
Zone GetZone(Point p)
Definition: EloMap.cs:420

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 continue;
200 }
201 cell.zone = zone;
202 if (!zone.IsInstance)
203 {
204 cell.obj = zone.icon;
205 }
206 }
207 for (int k = 0; k < h; k++)
208 {
209 for (int l = 0; l < w; l++)
210 {
211 Cell cell2 = cells[l, k];
212 int num = minX + l;
213 int num2 = minY + k;
214 if (cell2.obj != 0)
215 {
216 objmap.SetTile(num, num2, cell2.obj);
217 }
218 if (cell2.zone != null)
219 {
220 if (cell2.zone.UseLight)
221 {
222 AddLight(num, num2);
223 }
224 if (cell2.zone.IsClosed)
225 {
226 extramap.SetTile(num, num2, 333);
227 }
228 }
229 }
230 }
231 extramap.UpdateMeshImmediate();
232 objmap.UpdateMeshImmediate();
233 }
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:469
int icon
Definition: Spatial.cs:82
bool IsInstance
Definition: Zone.cs:480

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 406 of file EloMap.cs.

407 {
408 if (GetCell(gx, gy) == null)
409 {
410 return false;
411 }
412 SourceGlobalTile.Row row = GetSources(gx, gy).LastItem();
413 if (row != null)
414 {
415 return row.id == 7;
416 }
417 return false;
418 }

References GetCell(), and GetSources().

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 482 of file EloMap.cs.

483 {
484 foreach (EloMapLight light in actor.lights)
485 {
486 if (light.gx == gx && light.gy == gy)
487 {
488 Object.DestroyImmediate(light.sr.gameObject);
489 actor.lights.Remove(light);
490 break;
491 }
492 }
493 }
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 235 of file EloMap.cs.

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

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: