Example #1
0
        private void UpdateWeatherOnNewDay()
        {
            if (!(Context.IsMainPlayer))
            {
                return;
            }

            if (Game1.dayOfMonth == 0) //do not run on day 0.
            {
                return;
            }

            //Set Temperature for today and tommorow. Get today's conditions.
            //   If tomorrow is set, move it to today, and autoregen tomorrow.
            //   *201711 Due to changes in the object, it auto attempts to update today from tomorrow.

            if (!Conditions.IsTomorrowTempSet)
            {
                Conditions.SetTodayTemps(GameClimate.GetTemperatures(SDate.Now(), Dice));
            }

            Conditions.SetTomorrowTemps(GameClimate.GetTemperatures(SDate.Now().AddDays(1), Dice));

            if (WeatherOpt.Verbose)
            {
                Monitor.Log($"Updated the temperature for tommorow and today. Setting weather for today... ", LogLevel.Trace);
            }

            //if today is a festival or wedding, do not go further.
            if (Conditions.GetCurrentConditions().HasAnyFlags(CurrentWeather.Festival | CurrentWeather.Wedding))
            {
                if (WeatherOpt.Verbose)
                {
                    Monitor.Log("It is a wedding or festival today. Not attempting to run special weather or fog.");
                }

                return;
            }

            //TODO: Fix this once SMAPI supports mod broadcast data
            if (Context.IsMultiplayer)
            {
                return;
            }

            if (Conditions.TestForSpecialWeather(GameClimate.GetClimateForDate(SDate.Now())))
            {
                if (WeatherOpt.Verbose)
                {
                    Monitor.Log("Special weather created!");
                }
            }
        }
Example #2
0
        private void UpdateWeatherOnNewDay()
        {
            if (Game1.dayOfMonth == 0) //do not run on day 0.
            {
                return;
            }

            //Set Temperature for today and tommorow. Get today's conditions.
            //   If tomorrow is set, move it to today, and autoregen tomorrow.
            //   *201711 Due to changes in the object, it auto attempts to update today from tomorrow.
            Conditions.SetTodayWeather();

            if (!Conditions.IsTomorrowTempSet)
            {
                Conditions.SetTodayTemps(GameClimate.GetTemperatures(SDate.Now(), Dice, DebugOutput));
            }

            Conditions.SetTomorrowTemps(GameClimate.GetTemperatures(SDate.Now().AddDays(1), Dice, DebugOutput));

            if (WeatherOpt.Verbose)
            {
                Monitor.Log($"Updated the temperature for tommorow and today. Setting weather for today... ", LogLevel.Trace);
            }

            //if today is a festival or wedding, do not go further.
            if (Conditions.GetCurrentConditions().HasAnyFlags(CurrentWeather.Festival | CurrentWeather.Wedding))
            {
                if (WeatherOpt.Verbose)
                {
                    Monitor.Log("It is a wedding or festival today. Not attempting to run special weather or fog.");
                }

                //if (WeatherOpt.Verbose) Monitor.Log(DebugOutput.ToString());
                return;
            }

            if (Conditions.TestForSpecialWeather(GameClimate.GetClimateForDate(SDate.Now()).RetrieveOdds(Dice, "fog", SDate.Now().Day, DebugOutput)))
            {
                Monitor.Log("Special weather created!");
            }
        }
        private void OnModMessageRecieved(object sender, ModMessageReceivedEventArgs e)
        {
            if (e.FromModID == "KoihimeNakamura.ClimatesOfFerngill" && e.Type == "NewFarmHandJoin" && Context.IsMainPlayer && !HasGottenSync)
            {
                if (!Conditions.IsTodayTempSet)
                {
                    Conditions.SetTodayTemps(GameClimate.GetTemperatures(SDate.Now(), Dice));
                }

                WeatherSync message = Conditions.GenerateWeatherSyncMessage();
                MPHandler.SendMessage <WeatherSync>(message, "WeatherSync", new[] { "KoihimeNakamura.ClimatesOfFerngill" }, new[] { e.FromPlayerID });
                HasGottenSync = true;
            }

            if (e.FromModID == "KoihimeNakamura.ClimatesOfFerngill" && e.Type == "WeatherSync")
            {
                WeatherSync message = e.ReadAs <WeatherSync>();
                if (WeatherOpt.Verbose)
                {
                    Monitor.Log($"Message contents at {Game1.timeOfDay} : {GenSyncMessageString(message)}");
                }
                Conditions.SetSync(message);
            }
        }