Elin Decompiled Documentation EA 23.329 Nightly
Loading...
Searching...
No Matches
CustomZoneContent.cs
Go to the documentation of this file.
1using Newtonsoft.Json;
2using UnityEngine;
3
4[JsonObject(MemberSerialization.OptOut)]
6{
7 public string parent;
8
9 public bool autoSpawn;
10
11 public override string SourceType => "SourceZone";
12
14 {
15 if (owner == null)
16 {
17 owner = ModUtil.FindSourceRowPackage(r);
18 }
19 CustomZoneContent customZoneContent = new CustomZoneContent
20 {
21 ContentId = "Zone/" + r.id,
22 SourceId = r.id,
23 Owner = owner
24 };
25 string[] tag = r.tag;
26 for (int i = 0; i < tag.Length; i++)
27 {
28 var (text, str, _) = CustomSourceContent.GetParams(tag[i]);
29 if (text == "addMap")
30 {
31 customZoneContent.parent = str.IsEmpty(r.parent.IsEmpty("ntyris"));
32 customZoneContent.autoSpawn = true;
33 }
34 }
35 return customZoneContent;
36 }
37
38 public override void OnGameLoad(GameIOContext context)
39 {
40 if (!autoSpawn || parent == null)
41 {
42 return;
43 }
44 Debug.Log($"#mod-content loading {this}");
45 if (EClass.game.spatials.Find(base.SourceId) != null)
46 {
47 Debug.Log("#mod-content skipping existing custom zone " + base.SourceId);
48 return;
49 }
50 Zone zone = ModUtil.FindZoneByFullName(parent);
51 if (zone != null)
52 {
53 Spatial spatial = SpatialGen.Create(base.SourceId, zone, register: true);
54 EClass.game.world.region.elomap.SetZone(spatial.x, spatial.y, spatial as Zone);
55 Debug.Log($"#mod-content spawned custom zone {spatial}");
56 return;
57 }
58 ModUtil.LogModError("source zone row '" + base.SourceId + "' has invalid addMap parent '" + parent + "'", base.Owner);
59 }
60
61 public override string ToString()
62 {
63 return base.ContentId + "/" + parent;
64 }
65}
string ContentId
Definition: CustomContent.cs:6
static string string string[] kv GetParams(string tag)
override string ToString()
static CustomZoneContent CreateFromRow(SourceZone.Row r, ModPackage owner=null)
override string SourceType
override void OnGameLoad(GameIOContext context)
Definition: EClass.cs:6
static Game game
Definition: EClass.cs:9
void SetZone(int gx, int gy, Zone z, bool updateMesh=false)
Definition: EloMap.cs:234
SpatialManager spatials
Definition: Game.cs:153
new World world
Definition: Game.cs:177
EloMap elomap
Definition: Region.cs:9
static Spatial Create(string id, Spatial parent, bool register, int x=-99999, int y=-99999, int icon=0)
Definition: SpatialGen.cs:16
Zone Find(string id)
int y
Definition: Spatial.cs:106
int x
Definition: Spatial.cs:94
Region region
Definition: World.cs:23
Definition: Zone.cs:12