17 return EClass.world.region;
33 internal void OnSerializing(StreamingContext context)
35 if (this.cells !=
null)
37 this._ints =
new int[this.w, this.h];
38 for (
int i = 0; i < this.h; i++)
40 for (
int j = 0; j < this.w; j++)
42 this._ints[j, i] = this.cells[j, i].GetInt();
50 internal void OnDeserialized(StreamingContext context)
52 if (this._ints !=
null && this._ints.GetLength(0) > 0)
54 this.w = this._ints.GetLength(0);
55 this.h = this._ints.GetLength(1);
57 for (
int i = 0; i < this.h; i++)
59 for (
int j = 0; j < this.w; j++)
61 this.cells[j, i] =
new EloMap.
Cell(this._ints[j, i]);
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)
90 for (
int i = 0; i < this.h; i++)
92 for (
int j = 0; j < this.w; j++)
98 foreach (
Spatial spatial
in this.region.children)
106 Debug.Log(
"cell is null:" + x.ToString() +
"/" + y.ToString());
111 if (!zone.IsInstance)
113 cell.obj = zone.icon;
117 for (
int k = 0; k < this.h; k++)
119 for (
int l = 0; l < this.w; l++)
122 int num = this.minX + l;
123 int num2 = this.minY + k;
126 this.objmap.SetTile(num, num2, cell2.obj, 0, eTileFlags.None);
128 if (cell2.zone !=
null)
130 if (cell2.zone.UseLight)
132 this.AddLight(num, num2,
"elolight");
134 if (cell2.zone.IsClosed)
136 this.extramap.SetTile(num, num2, 333, 0, eTileFlags.None);
141 this.extramap.UpdateMeshImmediate();
142 this.objmap.UpdateMeshImmediate();
146 public void SetZone(
int gx,
int gy,
Zone z,
bool updateMesh =
false)
151 Debug.Log(
"cell is null:" + gx.ToString() +
"/" + gy.ToString());
154 if (z !=
null && cell.obj == z.icon)
158 cell.obj = ((z !=
null) ? z.icon : 0);
159 if (z !=
null && z.source.tag.Contains(
"iconFlag"))
163 if (cell.zone !=
null && cell.zone.UseLight)
165 this.RemoveLight(gx, gy);
170 this.objmap.Erase(gx, gy);
174 this.objmap.SetTile(gx, gy, cell.obj, 0, eTileFlags.None);
176 if (z !=
null && z.UseLight)
178 this.AddLight(gx, gy,
"elolight");
182 this.objmap.UpdateMeshImmediate();
189 return this.GetCell(pos.x +
this.minX, pos.z +
this.minY);
195 if (gx < this.minX || gy < this.minY || gx >= this.minX + this.w || gy >= this.minY + this.h)
199 return this.cells[gx - this.minX, gy - this.minY];
207 this.group.Tilemaps.ForeachReverse(delegate(STETilemap m)
209 if (m == this.fogmap | skip)
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)
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;
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));
234 t.sprite = TilemapUtils.GetOrCreateTileSprite(this.actor.tileset, row.tiles[0], 0f);
235 string alias = row.alias;
236 if (!(alias ==
"bridge"))
238 if (!(alias ==
"wall") && !(alias ==
"rock"))
240 if (!(alias ==
"sea"))
242 if (alias ==
"beach")
257 if (!row.zoneProfile.IsEmpty())
262 if (row.attribs[0] == 0)
274 foreach (STETilemap stetilemap
in this.group.Tilemaps)
276 if (!(stetilemap == this.fogmap))
278 int tileIdFromTileData = Tileset.GetTileIdFromTileData(stetilemap.GetTileData(gx, gy));
279 if (
EClass.sources.globalTiles.tileAlias.ContainsKey(tileIdFromTileData))
281 list.Add(
EClass.sources.globalTiles.tileAlias.TryGetValue(tileIdFromTileData,
null));
289 public bool CanBuildSite(
int gx,
int gy,
int radius = 0, ElomapSiteType type = ElomapSiteType.Nefia)
293 for (
int i = gy - radius; i < gy + radius + 1; i++)
295 for (
int j = gx - radius; j < gx + radius + 1; j++)
297 if (!this.CanBuildSite(j, i, 0, ElomapSiteType.Nefia))
306 if (cell ==
null || cell.zone !=
null ||
this.cloudmap.GetTileData(gx, gy) != 4294967295U)
311 return row !=
null && row.tag.Contains(
"site") && (row.id != 7 ||
EClass.rnd(5) != 0);
315 public bool IsSnow(
int gx,
int gy)
317 if (this.GetCell(gx, gy) ==
null)
322 return row !=
null && row.id == 7;
328 return this.GetZone(p.x +
this.minX, p.z +
this.minY);
332 public Zone GetZone(
int gx,
int gy)
335 foreach (
Spatial spatial
in this.region.children)
337 if (spatial.x == gx && spatial.y == gy)
340 if (((zone2 !=
null) ? zone2.instance :
null) ==
null && (zone ==
null || zone is
Zone_Field))
342 zone = (spatial as
Zone);
350 public int GetRoadDist(
int gx,
int gy)
352 if (!this.initialized)
354 EClass.scene.elomapActor.Initialize(
EClass.world.region.elomap);
356 for (
int i = 0; i < 100; i++)
358 for (
int j = gy - i; j < gy + i + 1; j++)
360 for (
int k = gx - i; k < gx + i + 1; k++)
362 if (j == gy - i || j == gy + i || k == gx - i || k == gx + i)
364 uint tileData = this.objScatterMap.GetTileData(k, j);
365 if (((tileData != 4294967295U) ? ((tileData & 268369920U) >> 16) : 0U) == 3U)
369 tileData = this.seaMap.GetTileData(k, j);
370 if (((tileData != 4294967295U) ? ((tileData & 268369920U) >> 16) : 0U) == 3U)
382 public void AddLight(
int gx,
int gy,
string id =
"elolight")
384 SpriteRenderer spriteRenderer = Util.Instantiate<SpriteRenderer>(id, this.actor.transLight);
391 this.actor.lights.Add(item);
392 spriteRenderer.transform.position = TilemapUtils.GetGridWorldPos(this.fogmap, gx, gy);
396 public void RemoveLight(
int gx,
int gy)
398 foreach (
EloMapLight eloMapLight
in this.actor.lights)
400 if (eloMapLight.gx == gx && eloMapLight.gy == gy)
402 UnityEngine.Object.DestroyImmediate(eloMapLight.sr.gameObject);
403 this.actor.lights.Remove(eloMapLight);
417 public TilemapGroup group;
420 public STETilemap fogmap;
423 public STETilemap seaMap;
426 public STETilemap objScatterMap;
429 public STETilemap objmap;
432 public STETilemap extramap;
435 public STETilemap cloudmap;
450 public bool initialized;
472 return this.obj * 10;
491 return this.idSurface ==
"snow_edge" || this.idSurface ==
"snow";
497 public string idSurface
502 return ((row !=
null) ? row.alias :
null) ??
"";
508 public string idZoneProfile
512 return this.source.zoneProfile;
522 return this.source.GetName();
528 public bool CanEmbark
532 return this.idZoneProfile !=
null;
542 return this.idSurface ==
"bridge";
548 public bool IsNeighborRoad
552 return this.roadLeft || this.roadRight || this.roadUp || this.roadDown;
557 public Sprite sprite;
566 public bool roadLeft;
569 public bool roadRight;
575 public bool roadDown;