Elin Modding Docs Doc
Loading...
Searching...
No Matches
Weather.cs
1using System;
2using System.Collections.Generic;
3using System.Linq;
4using Newtonsoft.Json;
5
6// Token: 0x020006F3 RID: 1779
7public class Weather : EClass
8{
9 // Token: 0x17000F89 RID: 3977
10 // (get) Token: 0x060033D1 RID: 13265 RVA: 0x0011B23E File Offset: 0x0011943E
11 public Weather.Condition CurrentCondition
12 {
13 get
14 {
15 if (EClass._map.config.fixedCondition == Weather.Condition.None)
16 {
17 return this._currentCondition;
18 }
19 return EClass._map.config.fixedCondition;
20 }
21 }
22
23 // Token: 0x17000F8A RID: 3978
24 // (get) Token: 0x060033D2 RID: 13266 RVA: 0x0011B268 File Offset: 0x00119468
25 public Season season
26 {
27 get
28 {
29 return EClass.world.season;
30 }
31 }
32
33 // Token: 0x17000F8B RID: 3979
34 // (get) Token: 0x060033D3 RID: 13267 RVA: 0x0011B274 File Offset: 0x00119474
35 public bool IsHazard
36 {
37 get
38 {
39 return this.CurrentCondition == Weather.Condition.Rain || this.CurrentCondition == Weather.Condition.RainHeavy || this.CurrentCondition == Weather.Condition.Snow || this.CurrentCondition == Weather.Condition.SnowHeavy || this.CurrentCondition == Weather.Condition.Ether;
40 }
41 }
42
43 // Token: 0x17000F8C RID: 3980
44 // (get) Token: 0x060033D4 RID: 13268 RVA: 0x0011B2A5 File Offset: 0x001194A5
45 public bool IsFineOrCloudy
46 {
47 get
48 {
49 return this.CurrentCondition == Weather.Condition.Fine || this.CurrentCondition == Weather.Condition.Cloudy;
50 }
51 }
52
53 // Token: 0x17000F8D RID: 3981
54 // (get) Token: 0x060033D5 RID: 13269 RVA: 0x0011B2BA File Offset: 0x001194BA
55 public bool IsRaining
56 {
57 get
58 {
59 return this.CurrentCondition == Weather.Condition.Rain || this.CurrentCondition == Weather.Condition.RainHeavy;
60 }
61 }
62
63 // Token: 0x17000F8E RID: 3982
64 // (get) Token: 0x060033D6 RID: 13270 RVA: 0x0011B2D0 File Offset: 0x001194D0
65 public bool IsSnowing
66 {
67 get
68 {
69 return this.CurrentCondition == Weather.Condition.Snow || this.CurrentCondition == Weather.Condition.SnowHeavy;
70 }
71 }
72
73 // Token: 0x17000F8F RID: 3983
74 // (get) Token: 0x060033D7 RID: 13271 RVA: 0x0011B2E6 File Offset: 0x001194E6
75 public bool IsBlossom
76 {
77 get
78 {
79 return this.CurrentCondition == Weather.Condition.Blossom || (this.IsFineOrCloudy && EClass._map.config.blossom);
80 }
81 }
82
83 // Token: 0x17000F90 RID: 3984
84 // (get) Token: 0x060033D8 RID: 13272 RVA: 0x0011B30C File Offset: 0x0011950C
85 public bool IsEther
86 {
87 get
88 {
89 return this.CurrentCondition == Weather.Condition.Ether;
90 }
91 }
92
93 // Token: 0x060033D9 RID: 13273 RVA: 0x0011B317 File Offset: 0x00119517
94 public string GetName()
95 {
96 return this.GetName(this.CurrentCondition);
97 }
98
99 // Token: 0x060033DA RID: 13274 RVA: 0x0011B325 File Offset: 0x00119525
100 public string GetName(Weather.Condition condition)
101 {
102 return ("weather" + condition.ToString()).lang();
103 }
104
105 // Token: 0x060033DB RID: 13275 RVA: 0x0011B344 File Offset: 0x00119544
106 public void RefreshWeather()
107 {
108 if (EClass._map.IsIndoor)
109 {
110 return;
111 }
112 bool flag = EClass._zone.IsSnowCovered;
113 if (EClass._zone is Region)
114 {
115 EloMap elomap = EClass.scene.elomapActor.elomap;
116 EloMap.TileInfo tileInfo = elomap.GetTileInfo(EClass.pc.pos.x + elomap.minX, EClass.pc.pos.z + elomap.minY);
117 flag = (tileInfo != null && tileInfo.IsSnow);
118 if (EClass.world.season.isWinter)
119 {
120 flag = true;
121 }
122 }
123 if (this.IsSnowing)
124 {
125 if (!flag)
126 {
127 this._currentCondition = ((this._currentCondition == Weather.Condition.Snow) ? Weather.Condition.Rain : Weather.Condition.RainHeavy);
128 return;
129 }
130 }
131 else if (this.IsRaining && flag)
132 {
133 this._currentCondition = ((this._currentCondition == Weather.Condition.Rain) ? Weather.Condition.Snow : Weather.Condition.SnowHeavy);
134 }
135 }
136
137 // Token: 0x060033DC RID: 13276 RVA: 0x0011B414 File Offset: 0x00119614
138 public void OnChangeHour()
139 {
140 this.duration--;
141 if (this.duration < 0)
142 {
143 this.SetConditionFromForecast(false);
144 }
145 }
146
147 // Token: 0x060033DD RID: 13277 RVA: 0x0011B434 File Offset: 0x00119634
148 public Weather.Forecast GetForecast(Date date, Weather.Condition current)
149 {
150 Weather.Forecast forecast = new Weather.Forecast();
151 forecast.condition = ((EClass.rnd(4) != 0) ? Weather.Condition.Fine : this.season.GetRandomWeather(date, current));
152 forecast.duration = EClass.rnd(24) + 10;
153 date.AddHour(forecast.duration);
154 return forecast;
155 }
156
157 // Token: 0x060033DE RID: 13278 RVA: 0x0011B484 File Offset: 0x00119684
158 public List<Weather.WeatherForecast> GetWeatherForecast()
159 {
160 this.RefreshForecasts();
161 List<Weather.WeatherForecast> list = new List<Weather.WeatherForecast>();
162 Date date = EClass.world.date.Copy();
164 {
165 date = date.Copy()
166 };
167 list.Add(weatherForecast);
169 {
170 condition = this._currentCondition,
171 duration = this.duration
172 };
173 int num = forecast.duration;
174 int num2 = -1;
175 for (int i = 0; i < 10000; i++)
176 {
177 num--;
178 weatherForecast.Add(forecast.condition, 1);
179 if (num < 0)
180 {
181 num2++;
182 if (this.forecasts.Count <= num2)
183 {
184 list.Remove(weatherForecast);
185 break;
186 }
187 forecast = this.forecasts[num2];
188 num = forecast.duration;
189 }
190 date.AddHour(1);
191 if (date.day != weatherForecast.date.day)
192 {
193 weatherForecast.Finish();
194 weatherForecast = new Weather.WeatherForecast
195 {
196 date = date.Copy()
197 };
198 list.Add(weatherForecast);
199 }
200 }
201 return list;
202 }
203
204 // Token: 0x060033DF RID: 13279 RVA: 0x0011B594 File Offset: 0x00119794
205 public void RefreshForecasts()
206 {
207 if (this.forecasts.Count < 10)
208 {
209 Date date = EClass.world.date.Copy();
210 Weather.Condition current = Weather.Condition.Fine;
211 for (int i = 0; i < 10; i++)
212 {
213 if (this.forecasts.Count > i)
214 {
215 Weather.Forecast forecast = this.forecasts[i];
216 date.AddHour(forecast.duration);
217 current = forecast.condition;
218 }
219 else
220 {
221 Weather.Forecast forecast2 = this.GetForecast(date, current);
222 this.forecasts.Add(forecast2);
223 current = forecast2.condition;
224 }
225 }
226 }
227 }
228
229 // Token: 0x060033E0 RID: 13280 RVA: 0x0011B61E File Offset: 0x0011981E
230 public long GetTimeSinceLastRain()
231 {
232 if (this.CurrentCondition == Weather.Condition.Rain || this.CurrentCondition == Weather.Condition.RainHeavy)
233 {
234 return 0L;
235 }
236 return (long)EClass.world.date.GetElapsedMins(this.lastRain);
237 }
238
239 // Token: 0x060033E1 RID: 13281 RVA: 0x0011B64B File Offset: 0x0011984B
240 public void SetRandomCondition()
241 {
242 this.SetCondition(Util.RandomEnum<Weather.Condition>(), 20, false);
243 }
244
245 // Token: 0x060033E2 RID: 13282 RVA: 0x0011B65C File Offset: 0x0011985C
246 public void SetConditionFromForecast(bool silent = false)
247 {
248 this.RefreshForecasts();
249 Weather.Forecast forecast = this.forecasts[0];
250 this.SetCondition(forecast.condition, forecast.duration, silent);
251 this.forecasts.RemoveAt(0);
252 }
253
254 // Token: 0x060033E3 RID: 13283 RVA: 0x0011B69C File Offset: 0x0011989C
255 public void SetCondition(Weather.Condition condition, int _duration = 20, bool silent = false)
256 {
257 if (condition == Weather.Condition.Fine)
258 {
259 foreach (Chara chara in EClass.pc.party.members)
260 {
261 if (chara.HasElement(1558, 1) && EClass.rnd(4) == 0)
262 {
263 condition = Weather.Condition.Rain;
264 Msg.Say("drawRain", chara, null, null, null);
265 break;
266 }
267 }
268 }
269 if (EClass.world.season.isWinter)
270 {
271 if (condition == Weather.Condition.Rain)
272 {
273 condition = Weather.Condition.Snow;
274 }
275 else if (condition == Weather.Condition.RainHeavy)
276 {
277 condition = Weather.Condition.SnowHeavy;
278 }
279 }
280 else if (!EClass._zone.IsSnowZone && !EClass._map.IsIndoor)
281 {
282 if (condition == Weather.Condition.Snow)
283 {
284 condition = Weather.Condition.Rain;
285 }
286 else if (condition == Weather.Condition.SnowHeavy)
287 {
288 condition = Weather.Condition.RainHeavy;
289 }
290 }
291 if (this._currentCondition == Weather.Condition.Rain || this._currentCondition == Weather.Condition.RainHeavy)
292 {
293 this.lastRain = EClass.world.date.GetRaw(0);
294 }
295 this.duration = _duration;
296 if (condition == this._currentCondition)
297 {
298 return;
299 }
300 this._currentCondition = condition;
301 this.RefreshWeather();
302 Msg.Say("weather_" + condition.ToString());
303 if (this.IsRaining)
304 {
305 EClass._zone.RainWater();
306 }
307 EClass.core.screen.RefreshSky();
308 }
309
310 // Token: 0x04001C35 RID: 7221
311 private const int maxForecasts = 10;
312
313 // Token: 0x04001C36 RID: 7222
314 [JsonProperty]
315 public Weather.Condition _currentCondition;
316
317 // Token: 0x04001C37 RID: 7223
318 [JsonProperty]
319 public int duration = 8;
320
321 // Token: 0x04001C38 RID: 7224
322 [JsonProperty]
323 public int lastRain;
324
325 // Token: 0x04001C39 RID: 7225
326 [JsonProperty]
327 public List<Weather.Forecast> forecasts = new List<Weather.Forecast>();
328
329 // Token: 0x02000C13 RID: 3091
330 [JsonObject(MemberSerialization.OptOut)]
331 public class Forecast
332 {
333 // Token: 0x0400300A RID: 12298
334 public int duration;
335
336 // Token: 0x0400300B RID: 12299
337 public Weather.Condition condition;
338 }
339
340 // Token: 0x02000C14 RID: 3092
341 public enum Condition
342 {
343 // Token: 0x0400300D RID: 12301
344 Fine,
345 // Token: 0x0400300E RID: 12302
346 Cloudy,
347 // Token: 0x0400300F RID: 12303
348 Rain,
349 // Token: 0x04003010 RID: 12304
350 RainHeavy,
351 // Token: 0x04003011 RID: 12305
352 Snow,
353 // Token: 0x04003012 RID: 12306
354 SnowHeavy,
355 // Token: 0x04003013 RID: 12307
356 Ether,
357 // Token: 0x04003014 RID: 12308
358 Blossom,
359 // Token: 0x04003015 RID: 12309
360 None
361 }
362
363 // Token: 0x02000C15 RID: 3093
364 public class WeatherForecast
365 {
366 // Token: 0x06004629 RID: 17961 RVA: 0x00160D04 File Offset: 0x0015EF04
367 public void Add(Weather.Condition con, int h)
368 {
369 if (this.cons.ContainsKey(con))
370 {
371 Dictionary<Weather.Condition, int> dictionary = this.cons;
372 dictionary[con] += h;
373 return;
374 }
375 this.cons[con] = h;
376 }
377
378 // Token: 0x0600462A RID: 17962 RVA: 0x00160D48 File Offset: 0x0015EF48
379 public void Finish()
380 {
381 if (this.cons.Count == 0)
382 {
383 return;
384 }
385 int num = this.cons.Sum((KeyValuePair<Weather.Condition, int> c) => c.Value);
386 if (num != 0)
387 {
388 foreach (Weather.Condition key in this.cons.Keys.ToList<Weather.Condition>())
389 {
390 this.cons[key] = this.cons[key] * 100 / num;
391 }
392 }
393 }
394
395 // Token: 0x04003016 RID: 12310
396 public Date date;
397
398 // Token: 0x04003017 RID: 12311
399 public Dictionary<Weather.Condition, int> cons = new Dictionary<Weather.Condition, int>();
400 }
401}
Definition Chara.cs:12
Definition Date.cs:6
Definition Msg.cs:7