Elin Modding Docs Doc
Loading...
Searching...
No Matches
EloMap.cs
1using System;
2using System.Collections.Generic;
3using System.Runtime.Serialization;
4using CreativeSpore.SuperTilemapEditor;
5using Newtonsoft.Json;
6using UnityEngine;
7
8// Token: 0x02000659 RID: 1625
9public class EloMap : EClass
10{
11 // Token: 0x17000CEF RID: 3311
12 // (get) Token: 0x06002DA8 RID: 11688 RVA: 0x000FFBD8 File Offset: 0x000FDDD8
13 public Region region
14 {
15 get
16 {
17 return EClass.world.region;
18 }
19 }
20
21 // Token: 0x17000CF0 RID: 3312
22 // (get) Token: 0x06002DA9 RID: 11689 RVA: 0x000FFBE4 File Offset: 0x000FDDE4
23 public string idMap
24 {
25 get
26 {
27 return "map_ntyris";
28 }
29 }
30
31 // Token: 0x06002DAA RID: 11690 RVA: 0x000FFBEC File Offset: 0x000FDDEC
32 [OnSerializing]
33 internal void OnSerializing(StreamingContext context)
34 {
35 if (this.cells != null)
36 {
37 this._ints = new int[this.w, this.h];
38 for (int i = 0; i < this.h; i++)
39 {
40 for (int j = 0; j < this.w; j++)
41 {
42 this._ints[j, i] = this.cells[j, i].GetInt();
43 }
44 }
45 }
46 }
47
48 // Token: 0x06002DAB RID: 11691 RVA: 0x000FFC5C File Offset: 0x000FDE5C
49 [OnDeserialized]
50 internal void OnDeserialized(StreamingContext context)
51 {
52 if (this._ints != null && this._ints.GetLength(0) > 0)
53 {
54 this.w = this._ints.GetLength(0);
55 this.h = this._ints.GetLength(1);
56 this.cells = new EloMap.Cell[this.w, this.h];
57 for (int i = 0; i < this.h; i++)
58 {
59 for (int j = 0; j < this.w; j++)
60 {
61 this.cells[j, i] = new EloMap.Cell(this._ints[j, i]);
62 }
63 }
64 }
65 }
66
67 // Token: 0x06002DAC RID: 11692 RVA: 0x000FFD00 File Offset: 0x000FDF00
68 public void Init(EloMapActor _actor)
69 {
70 if (this.initialized)
71 {
72 return;
73 }
74 this.actor = _actor;
75 this.initialized = true;
76 this.group = this.actor.transMap.GetComponentInChildren<TilemapGroup>();
77 this.seaMap = this.group.Tilemaps[0];
78 this.cloudmap = this.group.Tilemaps[7];
79 this.extramap = this.group.Tilemaps[6];
80 this.fogmap = this.group.Tilemaps[5];
81 this.objmap = this.group.Tilemaps[4];
82 this.objScatterMap = this.group.Tilemaps[3];
83 this.w = this.fogmap.GridWidth;
84 this.h = this.fogmap.GridHeight;
85 this.minX = this.fogmap.MinGridX;
86 this.minY = this.fogmap.MinGridY;
87 if (this.cells == null)
88 {
89 this.cells = new EloMap.Cell[this.w, this.h];
90 for (int i = 0; i < this.h; i++)
91 {
92 for (int j = 0; j < this.w; j++)
93 {
94 this.cells[j, i] = new EloMap.Cell();
95 }
96 }
97 }
98 foreach (Spatial spatial in this.region.children)
99 {
100 int x = spatial.x;
101 int y = spatial.y;
102 Zone zone = spatial as Zone;
103 EloMap.Cell cell = this.GetCell(x, y);
104 if (cell == null)
105 {
106 Debug.Log("cell is null:" + x.ToString() + "/" + y.ToString());
107 }
108 else
109 {
110 cell.zone = zone;
111 if (!zone.IsInstance)
112 {
113 cell.obj = zone.icon;
114 }
115 }
116 }
117 for (int k = 0; k < this.h; k++)
118 {
119 for (int l = 0; l < this.w; l++)
120 {
121 EloMap.Cell cell2 = this.cells[l, k];
122 int num = this.minX + l;
123 int num2 = this.minY + k;
124 if (cell2.obj != 0)
125 {
126 this.objmap.SetTile(num, num2, cell2.obj, 0, eTileFlags.None);
127 }
128 if (cell2.zone != null)
129 {
130 if (cell2.zone.UseLight)
131 {
132 this.AddLight(num, num2, "elolight");
133 }
134 if (cell2.zone.IsClosed)
135 {
136 this.extramap.SetTile(num, num2, 333, 0, eTileFlags.None);
137 }
138 }
139 }
140 }
141 this.extramap.UpdateMeshImmediate();
142 this.objmap.UpdateMeshImmediate();
143 }
144
145 // Token: 0x06002DAD RID: 11693 RVA: 0x000FFFE8 File Offset: 0x000FE1E8
146 public void SetZone(int gx, int gy, Zone z, bool updateMesh = false)
147 {
148 EloMap.Cell cell = this.GetCell(gx, gy);
149 if (cell == null)
150 {
151 Debug.Log("cell is null:" + gx.ToString() + "/" + gy.ToString());
152 return;
153 }
154 if (z != null && cell.obj == z.icon)
155 {
156 return;
157 }
158 cell.obj = ((z != null) ? z.icon : 0);
159 if (z != null && z.source.tag.Contains("iconFlag"))
160 {
161 cell.obj = 306;
162 }
163 if (cell.zone != null && cell.zone.UseLight)
164 {
165 this.RemoveLight(gx, gy);
166 }
167 cell.zone = z;
168 if (cell.obj == 0)
169 {
170 this.objmap.Erase(gx, gy);
171 }
172 else
173 {
174 this.objmap.SetTile(gx, gy, cell.obj, 0, eTileFlags.None);
175 }
176 if (z != null && z.UseLight)
177 {
178 this.AddLight(gx, gy, "elolight");
179 }
180 if (updateMesh)
181 {
182 this.objmap.UpdateMeshImmediate();
183 }
184 }
185
186 // Token: 0x06002DAE RID: 11694 RVA: 0x001000E4 File Offset: 0x000FE2E4
187 public EloMap.Cell GetCell(Point pos)
188 {
189 return this.GetCell(pos.x + this.minX, pos.z + this.minY);
190 }
191
192 // Token: 0x06002DAF RID: 11695 RVA: 0x00100108 File Offset: 0x000FE308
193 public EloMap.Cell GetCell(int gx, int gy)
194 {
195 if (gx < this.minX || gy < this.minY || gx >= this.minX + this.w || gy >= this.minY + this.h)
196 {
197 return null;
198 }
199 return this.cells[gx - this.minX, gy - this.minY];
200 }
201
202 // Token: 0x06002DB0 RID: 11696 RVA: 0x00100164 File Offset: 0x000FE364
203 public EloMap.TileInfo GetTileInfo(int gx, int gy)
204 {
206 bool skip = false;
207 this.group.Tilemaps.ForeachReverse(delegate(STETilemap m)
208 {
209 if (m == this.fogmap | skip)
210 {
211 return;
212 }
213 int tileIdFromTileData = Tileset.GetTileIdFromTileData(m.GetTileData(gx, gy));
214 TileData tileData = new TileData(m.GetTileData(gx, gy));
215 int tileId = tileData.tileId;
216 if (tileId >= 22 && tileId <= 25)
217 {
218 bool flipHorizontal = tileData.flipHorizontal;
219 bool flipVertical = tileData.flipVertical;
220 bool rot = tileData.rot90;
221 int num = (flipHorizontal ? 1 : 0) + (flipVertical ? 1 : 0) * 2 + (rot ? 1 : 0) * 4;
222 t.isRoad = true;
223 t.roadLeft = (tileId == 23 || (tileId == 24 && (num == 4 || num == 0)) || (tileId == 25 && num != 6));
224 t.roadRight = (tileId == 23 || (tileId == 24 && (num == 6 || num == 1)) || (tileId == 25 && num != 4));
225 t.roadUp = (tileId == 22 || (tileId == 24 && (num == 4 || num == 6)) || (tileId == 25 && num != 0));
226 t.roadDown = (tileId == 22 || (tileId == 24 && (num == 0 || num == 1)) || (tileId == 25 && num != 2));
227 }
228 SourceGlobalTile.Row row = EClass.sources.globalTiles.tileAlias.TryGetValue(tileIdFromTileData, null);
229 if (row == null)
230 {
231 return;
232 }
233 t.source = row;
234 t.sprite = TilemapUtils.GetOrCreateTileSprite(this.actor.tileset, row.tiles[0], 0f);
235 string alias = row.alias;
236 if (!(alias == "bridge"))
237 {
238 if (!(alias == "wall") && !(alias == "rock"))
239 {
240 if (!(alias == "sea"))
241 {
242 if (alias == "beach")
243 {
244 t.shore = true;
245 }
246 }
247 else
248 {
249 t.sea = true;
250 }
251 }
252 else
253 {
254 t.rock = true;
255 }
256 }
257 if (!row.zoneProfile.IsEmpty())
258 {
259 skip = true;
260 return;
261 }
262 if (row.attribs[0] == 0)
263 {
264 t.blocked = true;
265 }
266 });
267 return t;
268 }
269
270 // Token: 0x06002DB1 RID: 11697 RVA: 0x001001C0 File Offset: 0x000FE3C0
271 public List<SourceGlobalTile.Row> GetSources(int gx, int gy)
272 {
273 List<SourceGlobalTile.Row> list = new List<SourceGlobalTile.Row>();
274 foreach (STETilemap stetilemap in this.group.Tilemaps)
275 {
276 if (!(stetilemap == this.fogmap))
277 {
278 int tileIdFromTileData = Tileset.GetTileIdFromTileData(stetilemap.GetTileData(gx, gy));
279 if (EClass.sources.globalTiles.tileAlias.ContainsKey(tileIdFromTileData))
280 {
281 list.Add(EClass.sources.globalTiles.tileAlias.TryGetValue(tileIdFromTileData, null));
282 }
283 }
284 }
285 return list;
286 }
287
288 // Token: 0x06002DB2 RID: 11698 RVA: 0x00100268 File Offset: 0x000FE468
289 public bool CanBuildSite(int gx, int gy, int radius = 0, ElomapSiteType type = ElomapSiteType.Nefia)
290 {
291 if (radius != 0)
292 {
293 for (int i = gy - radius; i < gy + radius + 1; i++)
294 {
295 for (int j = gx - radius; j < gx + radius + 1; j++)
296 {
297 if (!this.CanBuildSite(j, i, 0, ElomapSiteType.Nefia))
298 {
299 return false;
300 }
301 }
302 }
303 return true;
304 }
305 EloMap.Cell cell = this.GetCell(gx, gy);
306 if (cell == null || cell.zone != null || this.cloudmap.GetTileData(gx, gy) != 4294967295U)
307 {
308 return false;
309 }
310 SourceGlobalTile.Row row = this.GetSources(gx, gy).LastItem<SourceGlobalTile.Row>();
311 return row != null && row.tag.Contains("site") && (row.id != 7 || EClass.rnd(5) != 0);
312 }
313
314 // Token: 0x06002DB3 RID: 11699 RVA: 0x0010030C File Offset: 0x000FE50C
315 public bool IsSnow(int gx, int gy)
316 {
317 if (this.GetCell(gx, gy) == null)
318 {
319 return false;
320 }
321 SourceGlobalTile.Row row = this.GetSources(gx, gy).LastItem<SourceGlobalTile.Row>();
322 return row != null && row.id == 7;
323 }
324
325 // Token: 0x06002DB4 RID: 11700 RVA: 0x00100341 File Offset: 0x000FE541
326 public Zone GetZone(Point p)
327 {
328 return this.GetZone(p.x + this.minX, p.z + this.minY);
329 }
330
331 // Token: 0x06002DB5 RID: 11701 RVA: 0x00100364 File Offset: 0x000FE564
332 public Zone GetZone(int gx, int gy)
333 {
334 Zone zone = null;
335 foreach (Spatial spatial in this.region.children)
336 {
337 if (spatial.x == gx && spatial.y == gy)
338 {
339 Zone zone2 = spatial as Zone;
340 if (((zone2 != null) ? zone2.instance : null) == null && (zone == null || zone is Zone_Field))
341 {
342 zone = (spatial as Zone);
343 }
344 }
345 }
346 return zone;
347 }
348
349 // Token: 0x06002DB6 RID: 11702 RVA: 0x001003F0 File Offset: 0x000FE5F0
350 public int GetRoadDist(int gx, int gy)
351 {
352 if (!this.initialized)
353 {
354 EClass.scene.elomapActor.Initialize(EClass.world.region.elomap);
355 }
356 for (int i = 0; i < 100; i++)
357 {
358 for (int j = gy - i; j < gy + i + 1; j++)
359 {
360 for (int k = gx - i; k < gx + i + 1; k++)
361 {
362 if (j == gy - i || j == gy + i || k == gx - i || k == gx + i)
363 {
364 uint tileData = this.objScatterMap.GetTileData(k, j);
365 if (((tileData != 4294967295U) ? ((tileData & 268369920U) >> 16) : 0U) == 3U)
366 {
367 return i;
368 }
369 tileData = this.seaMap.GetTileData(k, j);
370 if (((tileData != 4294967295U) ? ((tileData & 268369920U) >> 16) : 0U) == 3U)
371 {
372 return i;
373 }
374 }
375 }
376 }
377 }
378 return 100;
379 }
380
381 // Token: 0x06002DB7 RID: 11703 RVA: 0x001004BC File Offset: 0x000FE6BC
382 public void AddLight(int gx, int gy, string id = "elolight")
383 {
384 SpriteRenderer spriteRenderer = Util.Instantiate<SpriteRenderer>(id, this.actor.transLight);
385 EloMapLight item = new EloMapLight
386 {
387 sr = spriteRenderer,
388 gx = gx,
389 gy = gy
390 };
391 this.actor.lights.Add(item);
392 spriteRenderer.transform.position = TilemapUtils.GetGridWorldPos(this.fogmap, gx, gy);
393 }
394
395 // Token: 0x06002DB8 RID: 11704 RVA: 0x00100520 File Offset: 0x000FE720
396 public void RemoveLight(int gx, int gy)
397 {
398 foreach (EloMapLight eloMapLight in this.actor.lights)
399 {
400 if (eloMapLight.gx == gx && eloMapLight.gy == gy)
401 {
402 UnityEngine.Object.DestroyImmediate(eloMapLight.sr.gameObject);
403 this.actor.lights.Remove(eloMapLight);
404 break;
405 }
406 }
407 }
408
409 // Token: 0x040019B5 RID: 6581
410 [JsonProperty]
411 public int[,] _ints;
412
413 // Token: 0x040019B6 RID: 6582
414 public EloMap.Cell[,] cells;
415
416 // Token: 0x040019B7 RID: 6583
417 public TilemapGroup group;
418
419 // Token: 0x040019B8 RID: 6584
420 public STETilemap fogmap;
421
422 // Token: 0x040019B9 RID: 6585
423 public STETilemap seaMap;
424
425 // Token: 0x040019BA RID: 6586
426 public STETilemap objScatterMap;
427
428 // Token: 0x040019BB RID: 6587
429 public STETilemap objmap;
430
431 // Token: 0x040019BC RID: 6588
432 public STETilemap extramap;
433
434 // Token: 0x040019BD RID: 6589
435 public STETilemap cloudmap;
436
437 // Token: 0x040019BE RID: 6590
438 public int w;
439
440 // Token: 0x040019BF RID: 6591
441 public int h;
442
443 // Token: 0x040019C0 RID: 6592
444 public int minX;
445
446 // Token: 0x040019C1 RID: 6593
447 public int minY;
448
449 // Token: 0x040019C2 RID: 6594
450 public bool initialized;
451
452 // Token: 0x040019C3 RID: 6595
453 public EloMapActor actor;
454
455 // Token: 0x02000BC6 RID: 3014
456 public class Cell
457 {
458 // Token: 0x06004575 RID: 17781 RVA: 0x0015EB64 File Offset: 0x0015CD64
459 public Cell()
460 {
461 }
462
463 // Token: 0x06004576 RID: 17782 RVA: 0x0015EB6C File Offset: 0x0015CD6C
464 public Cell(int i)
465 {
466 this.obj = i / 10;
467 }
468
469 // Token: 0x06004577 RID: 17783 RVA: 0x0015EB7E File Offset: 0x0015CD7E
470 public int GetInt()
471 {
472 return this.obj * 10;
473 }
474
475 // Token: 0x04002F2C RID: 12076
476 public Zone zone;
477
478 // Token: 0x04002F2D RID: 12077
479 public int obj;
480 }
481
482 // Token: 0x02000BC7 RID: 3015
483 public class TileInfo
484 {
485 // Token: 0x170011F2 RID: 4594
486 // (get) Token: 0x06004578 RID: 17784 RVA: 0x0015EB89 File Offset: 0x0015CD89
487 public bool IsSnow
488 {
489 get
490 {
491 return this.idSurface == "snow_edge" || this.idSurface == "snow";
492 }
493 }
494
495 // Token: 0x170011F3 RID: 4595
496 // (get) Token: 0x06004579 RID: 17785 RVA: 0x0015EBAF File Offset: 0x0015CDAF
497 public string idSurface
498 {
499 get
500 {
501 SourceGlobalTile.Row row = this.source;
502 return ((row != null) ? row.alias : null) ?? "";
503 }
504 }
505
506 // Token: 0x170011F4 RID: 4596
507 // (get) Token: 0x0600457A RID: 17786 RVA: 0x0015EBCC File Offset: 0x0015CDCC
508 public string idZoneProfile
509 {
510 get
511 {
512 return this.source.zoneProfile;
513 }
514 }
515
516 // Token: 0x170011F5 RID: 4597
517 // (get) Token: 0x0600457B RID: 17787 RVA: 0x0015EBD9 File Offset: 0x0015CDD9
518 public string name
519 {
520 get
521 {
522 return this.source.GetName();
523 }
524 }
525
526 // Token: 0x170011F6 RID: 4598
527 // (get) Token: 0x0600457C RID: 17788 RVA: 0x0015EBE6 File Offset: 0x0015CDE6
528 public bool CanEmbark
529 {
530 get
531 {
532 return this.idZoneProfile != null;
533 }
534 }
535
536 // Token: 0x170011F7 RID: 4599
537 // (get) Token: 0x0600457D RID: 17789 RVA: 0x0015EBF1 File Offset: 0x0015CDF1
538 public bool IsBridge
539 {
540 get
541 {
542 return this.idSurface == "bridge";
543 }
544 }
545
546 // Token: 0x170011F8 RID: 4600
547 // (get) Token: 0x0600457E RID: 17790 RVA: 0x0015EC03 File Offset: 0x0015CE03
548 public bool IsNeighborRoad
549 {
550 get
551 {
552 return this.roadLeft || this.roadRight || this.roadUp || this.roadDown;
553 }
554 }
555
556 // Token: 0x04002F2E RID: 12078
557 public Sprite sprite;
558
559 // Token: 0x04002F2F RID: 12079
560 public bool blocked;
561
562 // Token: 0x04002F30 RID: 12080
563 public bool isRoad;
564
565 // Token: 0x04002F31 RID: 12081
566 public bool roadLeft;
567
568 // Token: 0x04002F32 RID: 12082
569 public bool roadRight;
570
571 // Token: 0x04002F33 RID: 12083
572 public bool roadUp;
573
574 // Token: 0x04002F34 RID: 12084
575 public bool roadDown;
576
577 // Token: 0x04002F35 RID: 12085
578 public bool rock;
579
580 // Token: 0x04002F36 RID: 12086
581 public bool sea;
582
583 // Token: 0x04002F37 RID: 12087
584 public bool shore;
585
586 // Token: 0x04002F38 RID: 12088
587 public SourceGlobalTile.Row source;
588 }
589}
Definition Point.cs:11
Definition Zone.cs:14