コード例 #1
0
        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);
            }
        }