11 public Weather.Condition CurrentCondition
15 if (
EClass._map.config.fixedCondition ==
Weather.Condition.None)
17 return this._currentCondition;
19 return EClass._map.config.fixedCondition;
29 return EClass.world.season;
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;
45 public bool IsFineOrCloudy
49 return this.CurrentCondition == Weather.Condition.Fine || this.CurrentCondition ==
Weather.Condition.Cloudy;
59 return this.CurrentCondition == Weather.Condition.Rain || this.CurrentCondition ==
Weather.Condition.RainHeavy;
69 return this.CurrentCondition == Weather.Condition.Snow || this.CurrentCondition ==
Weather.Condition.SnowHeavy;
79 return this.CurrentCondition == Weather.Condition.Blossom || (this.IsFineOrCloudy &&
EClass._map.config.blossom);
89 return this.CurrentCondition ==
Weather.Condition.Ether;
94 public string GetName()
96 return this.GetName(this.CurrentCondition);
100 public string GetName(
Weather.Condition condition)
102 return (
"weather" + condition.ToString()).lang();
106 public void RefreshWeather()
112 bool flag =
EClass._zone.IsSnowCovered;
117 flag = (tileInfo !=
null && tileInfo.IsSnow);
118 if (
EClass.world.season.isWinter)
127 this._currentCondition = ((this._currentCondition ==
Weather.Condition.Snow) ? Weather.Condition.Rain :
Weather.Condition.RainHeavy);
131 else if (this.IsRaining && flag)
133 this._currentCondition = ((this._currentCondition ==
Weather.Condition.Rain) ? Weather.Condition.Snow :
Weather.Condition.SnowHeavy);
138 public void OnChangeHour()
141 if (this.duration < 0)
143 this.SetConditionFromForecast(
false);
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);
160 this.RefreshForecasts();
167 list.Add(weatherForecast);
170 condition = this._currentCondition,
171 duration = this.duration
173 int num = forecast.duration;
175 for (
int i = 0; i < 10000; i++)
178 weatherForecast.Add(forecast.condition, 1);
182 if (this.forecasts.Count <= num2)
184 list.Remove(weatherForecast);
187 forecast = this.forecasts[num2];
188 num = forecast.duration;
191 if (date.day != weatherForecast.date.day)
193 weatherForecast.Finish();
198 list.Add(weatherForecast);
205 public void RefreshForecasts()
207 if (this.forecasts.Count < 10)
210 Weather.Condition current =
Weather.Condition.Fine;
211 for (
int i = 0; i < 10; i++)
213 if (this.forecasts.Count > i)
216 date.AddHour(forecast.duration);
217 current = forecast.condition;
222 this.forecasts.Add(forecast2);
223 current = forecast2.condition;
230 public long GetTimeSinceLastRain()
232 if (this.CurrentCondition ==
Weather.Condition.Rain ||
this.CurrentCondition ==
Weather.Condition.RainHeavy)
236 return (
long)
EClass.world.date.GetElapsedMins(this.lastRain);
240 public void SetRandomCondition()
242 this.SetCondition(Util.RandomEnum<
Weather.Condition>(), 20,
false);
246 public void SetConditionFromForecast(
bool silent =
false)
248 this.RefreshForecasts();
250 this.SetCondition(forecast.condition, forecast.duration, silent);
251 this.forecasts.RemoveAt(0);
255 public void SetCondition(
Weather.Condition condition,
int _duration = 20,
bool silent =
false)
257 if (condition ==
Weather.Condition.Fine)
261 if (chara.HasElement(1558, 1) &&
EClass.rnd(4) == 0)
263 condition =
Weather.Condition.Rain;
264 Msg.Say(
"drawRain", chara,
null,
null,
null);
269 if (
EClass.world.season.isWinter)
271 if (condition ==
Weather.Condition.Rain)
273 condition =
Weather.Condition.Snow;
275 else if (condition ==
Weather.Condition.RainHeavy)
277 condition =
Weather.Condition.SnowHeavy;
280 else if (!
EClass._zone.IsSnowZone && !
EClass._map.IsIndoor)
282 if (condition ==
Weather.Condition.Snow)
284 condition =
Weather.Condition.Rain;
286 else if (condition ==
Weather.Condition.SnowHeavy)
288 condition =
Weather.Condition.RainHeavy;
291 if (this._currentCondition ==
Weather.Condition.Rain ||
this._currentCondition ==
Weather.Condition.RainHeavy)
293 this.lastRain =
EClass.world.date.GetRaw(0);
295 this.duration = _duration;
296 if (condition == this._currentCondition)
300 this._currentCondition = condition;
301 this.RefreshWeather();
302 Msg.Say(
"weather_" + condition.ToString());
307 EClass.core.screen.RefreshSky();
311 private const int maxForecasts = 10;
315 public Weather.Condition _currentCondition;
319 public int duration = 8;
330 [JsonObject(MemberSerialization.OptOut)]
337 public Weather.Condition condition;
367 public void Add(
Weather.Condition con,
int h)
369 if (this.cons.ContainsKey(con))
371 Dictionary<
Weather.Condition,
int> dictionary = this.cons;
372 dictionary[con] += h;
381 if (this.cons.Count == 0)
385 int num = this.cons.Sum((KeyValuePair<Weather.Condition, int> c) => c.Value);
388 foreach (
Weather.Condition key in
this.cons.Keys.ToList<
Weather.Condition>())
390 this.cons[key] = this.cons[key] * 100 / num;
399 public Dictionary<
Weather.Condition,
int> cons =
new Dictionary<
Weather.Condition,
int>();