Elin Modding Docs Doc
Loading...
Searching...
No Matches
Region.cs
1using System;
2using System.Collections.Generic;
3using System.Linq;
4using Newtonsoft.Json;
5using UnityEngine;
6
7// Token: 0x020006E3 RID: 1763
8public class Region : Zone
9{
10 // Token: 0x17000F35 RID: 3893
11 // (get) Token: 0x060032D9 RID: 13017 RVA: 0x001173DD File Offset: 0x001155DD
12 public override bool WillAutoSave
13 {
14 get
15 {
16 return false;
17 }
18 }
19
20 // Token: 0x17000F36 RID: 3894
21 // (get) Token: 0x060032DA RID: 13018 RVA: 0x001173E0 File Offset: 0x001155E0
22 public override ActionMode DefaultActionMode
23 {
24 get
25 {
26 return ActionMode.Region;
27 }
28 }
29
30 // Token: 0x17000F37 RID: 3895
31 // (get) Token: 0x060032DB RID: 13019 RVA: 0x001173E7 File Offset: 0x001155E7
32 public override bool IsRegion
33 {
34 get
35 {
36 return true;
37 }
38 }
39
40 // Token: 0x17000F38 RID: 3896
41 // (get) Token: 0x060032DC RID: 13020 RVA: 0x001173EA File Offset: 0x001155EA
42 public override int DangerLv
43 {
44 get
45 {
46 return 1;
47 }
48 }
49
50 // Token: 0x17000F39 RID: 3897
51 // (get) Token: 0x060032DD RID: 13021 RVA: 0x001173ED File Offset: 0x001155ED
52 public override bool BlockBorderExit
53 {
54 get
55 {
56 return true;
57 }
58 }
59
60 // Token: 0x17000F3A RID: 3898
61 // (get) Token: 0x060032DE RID: 13022 RVA: 0x001173F0 File Offset: 0x001155F0
62 public override Point RegionPos
63 {
64 get
65 {
66 return this._regionPos.Set(EClass.pc.pos);
67 }
68 }
69
70 // Token: 0x060032DF RID: 13023 RVA: 0x00117408 File Offset: 0x00115608
71 public override void OnActivate()
72 {
73 this.children.ForeachReverse(delegate(Spatial _z)
74 {
75 Zone zone = _z as Zone;
76 if (zone.CanDestroy())
77 {
78 zone.Destroy();
79 }
80 });
81 this.children.ForeachReverse(delegate(Spatial _z)
82 {
83 if (_z.destryoed)
84 {
85 this.children.Remove(_z);
86 }
87 });
88 this.children.ForEach(delegate(Spatial a)
89 {
90 Zone zone = a as Zone;
91 if (zone.IsInstance || (!zone.IsPCFaction && zone is Zone_Field) || zone is Zone_SisterHouse)
92 {
93 return;
94 }
95 this.elomap.SetZone(zone.x, zone.y, zone, false);
96 });
97 this.CheckRandomSites();
98 }
99
100 // Token: 0x060032E0 RID: 13024 RVA: 0x00117474 File Offset: 0x00115674
101 public void CheckRandomSites()
102 {
103 if (EClass.world.date.IsExpired(this.dateCheckSites))
104 {
105 this.dateCheckSites = EClass.world.date.GetRaw(0) + 1440;
106 this.UpdateRandomSites();
107 }
108 if (base.FindZone("foxtown_nefu") == null)
109 {
110 SpatialGen.Create("foxtown_nefu", this, true, -99999, -99999, 0);
111 }
112 if (base.FindZone("little_garden") == null)
113 {
114 SpatialGen.Create("little_garden", this, true, -99999, -99999, 0);
115 }
116 this.elomap.objmap.UpdateMeshImmediate();
117 }
118
119 // Token: 0x060032E1 RID: 13025 RVA: 0x00117514 File Offset: 0x00115714
120 public void RenewRandomSites()
121 {
122 this.dateCheckSites = 0;
123 Msg.Say("renewNefia");
124 Debug.Log(this.ListRandomSites().Count);
125 foreach (Zone zone in this.ListRandomSites())
126 {
127 zone.dateExpire = 1;
128 }
129 }
130
131 // Token: 0x060032E2 RID: 13026 RVA: 0x0011758C File Offset: 0x0011578C
132 public void UpdateRandomSites()
133 {
134 List<Zone> list = this.ListRandomSites();
135 int num = 50 - list.Count;
136 if (num <= 0)
137 {
138 return;
139 }
140 for (int i = 0; i < num; i++)
141 {
142 this.CreateRandomSite(this.GetRandomPoint(), null, false, -1);
143 }
144 }
145
146 // Token: 0x060032E3 RID: 13027 RVA: 0x001175CB File Offset: 0x001157CB
147 public void InitElomap()
148 {
149 EClass.scene.elomapActor.Initialize(this.elomap);
150 }
151
152 // Token: 0x060032E4 RID: 13028 RVA: 0x001175E4 File Offset: 0x001157E4
153 public Zone CreateRandomSite(Zone center, int radius = 8, string idSource = null, bool updateMesh = true)
154 {
155 this.InitElomap();
156 return this.CreateRandomSite(this.GetRandomPoint(center.IsRegion ? (EClass.pc.pos.x + EClass.scene.elomap.minX) : center.x, center.IsRegion ? (EClass.pc.pos.z + EClass.scene.elomap.minY) : center.y, radius, false), idSource, updateMesh, -1);
157 }
158
159 // Token: 0x060032E5 RID: 13029 RVA: 0x00117668 File Offset: 0x00115868
160 private Zone CreateRandomSite(Point pos, string idSource, bool updateMesh, int lv = -1)
161 {
162 if (pos == null)
163 {
164 return null;
165 }
166 if (idSource.IsEmpty())
167 {
168 idSource = this.GetRandomSiteSource().id;
169 }
170 Zone zone = SpatialGen.Create(idSource, this, true, pos.x, pos.z, 0) as Zone;
171 if (lv == -1)
172 {
173 lv = ((EClass.rnd(3) == 0) ? EClass.pc.LV : EClass.pc.FameLv) + EClass.rnd(EClass.rnd(10) + 1) - 3;
174 }
175 zone._dangerLv = Mathf.Max(1, lv);
176 if (zone._dangerLv >= 50 && EClass.player.CountKeyItem("license_adv") == 0)
177 {
178 zone._dangerLv = EClass.rndHalf(50);
179 }
180 if (EClass.debug.enable)
181 {
182 zone._dangerLv = EClass.pc.LV;
183 }
184 zone.isRandomSite = true;
185 zone.dateExpire = EClass.world.date.GetRaw(0) + 10080;
186 if (this.elomap.IsSnow(zone.x, zone.y))
187 {
188 Zone zone2 = zone;
189 int icon = zone2.icon;
190 zone2.icon = icon + 1;
191 }
192 this.elomap.SetZone(zone.x, zone.y, zone, false);
193 if (updateMesh)
194 {
195 this.elomap.objmap.UpdateMeshImmediate();
196 }
197 return zone;
198 }
199
200 // Token: 0x060032E6 RID: 13030 RVA: 0x001177AC File Offset: 0x001159AC
201 public SourceZone.Row GetRandomSiteSource()
202 {
203 return (from a in EClass.sources.zones.rows
204 where a.tag.Contains("random") && (EClass.debug.enable || !a.tag.Contains("debug"))
205 select a).ToList<SourceZone.Row>().RandomItemWeighted((SourceZone.Row a) => (float)a.chance);
206 }
207
208 // Token: 0x060032E7 RID: 13031 RVA: 0x00117818 File Offset: 0x00115A18
209 public Point GetRandomPoint()
210 {
211 Point point = new Point();
212 for (int i = 0; i < 1000; i++)
213 {
214 point = this.map.bounds.GetRandomPoint();
215 point.x += this.elomap.minX;
216 point.z += this.elomap.minY;
217 if (this.elomap.CanBuildSite(point.x, point.z, 1, ElomapSiteType.Nefia))
218 {
219 return point;
220 }
221 }
222 return null;
223 }
224
225 // Token: 0x060032E8 RID: 13032 RVA: 0x0011789C File Offset: 0x00115A9C
226 public Point GetRandomPoint(int orgX, int orgY, int radius = 8, bool increaseRadius = false)
227 {
228 Point point = new Point();
229 for (int i = 0; i < 1000; i++)
230 {
231 point.x = orgX + Rand.Range(-radius / 2, radius / 2);
232 point.z = orgY + Rand.Range(-radius / 2, radius / 2);
233 if (i % 100 == 0 && increaseRadius)
234 {
235 radius++;
236 }
237 if (this.elomap.CanBuildSite(point.x, point.z, 0, ElomapSiteType.Nefia))
238 {
239 return point;
240 }
241 }
242 return null;
243 }
244
245 // Token: 0x060032E9 RID: 13033 RVA: 0x00117918 File Offset: 0x00115B18
246 public bool CanCreateZone(Point pos)
247 {
248 EClass.scene.elomapActor.Initialize(EClass.world.region.elomap);
249 EloMap.TileInfo tileInfo = EClass.scene.elomapActor.elomap.GetTileInfo(pos.x, pos.z);
250 return !tileInfo.idZoneProfile.IsEmpty() && !tileInfo.blocked;
251 }
252
253 // Token: 0x060032EA RID: 13034 RVA: 0x0011797C File Offset: 0x00115B7C
254 public Zone CreateZone(Point pos)
255 {
256 return SpatialGen.Create("field", this, true, pos.x, pos.z, 0) as Zone;
257 }
258
259 // Token: 0x060032EB RID: 13035 RVA: 0x0011799C File Offset: 0x00115B9C
260 public List<Zone> ListTowns()
261 {
262 List<Zone> list = new List<Zone>();
263 foreach (Spatial spatial in EClass.game.spatials.map.Values)
264 {
265 if (spatial.CanSpawnAdv)
266 {
267 list.Add(spatial as Zone);
268 }
269 }
270 return list;
271 }
272
273 // Token: 0x060032EC RID: 13036 RVA: 0x00117A14 File Offset: 0x00115C14
274 public Zone GetRandomTown()
275 {
276 List<Zone> source = this.ListTowns();
277 Zone zone = null;
278 for (int i = 0; i < 5; i++)
279 {
280 zone = source.RandomItem<Zone>();
281 Zone_SubTown zone_SubTown = zone as Zone_SubTown;
282 }
283 return zone;
284 }
285
286 // Token: 0x060032ED RID: 13037 RVA: 0x00117A45 File Offset: 0x00115C45
287 public List<Zone> ListRandomSites()
288 {
289 return (from Zone a in this.children
290 where a.isRandomSite
291 select a).ToList<Zone>();
292 }
293
294 // Token: 0x060032EE RID: 13038 RVA: 0x00117A7C File Offset: 0x00115C7C
295 public List<Zone> ListZonesInRadius(Zone center, int radius = 10)
296 {
297 List<Zone> list = new List<Zone>();
298 foreach (Zone zone in EClass.game.spatials.Zones)
299 {
300 if (zone.Dist(center) <= radius && zone != center && !(zone.source.parent != base.source.id))
301 {
302 list.Add(zone);
303 }
304 }
305 return list;
306 }
307
308 // Token: 0x060032EF RID: 13039 RVA: 0x00117B0C File Offset: 0x00115D0C
309 public List<Zone> ListTravelZones(int radius = 100)
310 {
311 bool isRegion = EClass.pc.currentZone.IsRegion;
312 List<Zone> list = new List<Zone>();
313 if (!isRegion)
314 {
315 new Point(EClass.pc.currentZone.x - EClass.scene.elomap.minX, EClass.pc.currentZone.y - EClass.scene.elomap.minY);
316 }
317 else
318 {
319 Point pos = EClass.pc.pos;
320 }
321 foreach (Zone zone in EClass.game.spatials.Zones)
322 {
323 if (zone.CanFastTravel && !zone.IsInstance && (zone.isKnown || EClass.debug.returnAnywhere) && zone.parent == this)
324 {
325 list.Add(zone);
326 zone.tempDist = zone.Dist(EClass.pc.pos);
327 }
328 }
329 return list;
330 }
331
332 // Token: 0x04001BF5 RID: 7157
333 public EloMap elomap = new EloMap();
334
335 // Token: 0x04001BF6 RID: 7158
336 [JsonProperty]
337 public int dateCheckSites;
338}
Definition Msg.cs:7
Definition Point.cs:11
Definition Zone.cs:14