private string GenSyncMessageString(WeatherSync ws) { string s = $"WeatherType: {ws.weatherType}, with today temps ({ws.todayLow},{ws.todayHigh}), tomorrow temps ({ws.tommorowLow},{ws.tommorowHigh})."; s += $"{Environment.NewLine}Variable Rain: {ws.isVariableRain}, overcast: {ws.isOvercast}, rainAmt: {ws.rainAmt}"; s += $"{Environment.NewLine}Blizzard: {ws.isBlizzard}, time: ({ws.blizzWeatherBeginTime},{ws.blizzWeatherEndTime})."; s += $"{Environment.NewLine}Fog: {ws.isFoggy}, time: ({ws.fogWeatherBeginTime},{ws.fogWeatherEndTime})."; s += $"{Environment.NewLine}WhiteOut: {ws.isWhiteOut}, time: ({ws.whiteWeatherBeginTime},{ws.whiteWeatherEndTime})."; s += $"{Environment.NewLine}Thunder: {ws.isThunderFrenzy}, time: ({ws.thunWeatherBeginTime},{ws.thunWeatherEndTime})."; s += $"{Environment.NewLine}Sandstorm: {ws.isSandstorm}, time: ({ws.sandstormWeatherBeginTime},{ws.sandstormWeatherEndTime})."; return(s); }
/// <summary>Raised after the game begins a new day (including when the player loads a save).</summary> /// <param name="sender">The event sender.</param> /// <param name="e">The event arguments.</param> private void OnDayStarted(object sender, DayStartedEventArgs e) { Conditions.OnNewDay(); IsBloodMoon = false; if (!Context.IsMainPlayer) { return; } WeatherProcessing.OnNewDay(); UpdateWeatherOnNewDay(); SetTomorrowWeather(); WeatherSync message = Conditions.GenerateWeatherSyncMessage(); MPHandler.SendMessage(message, "WeatherSync", modIDs: new[] { ModManifest.UniqueID }); }
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); } }