Exemple #1
0
        /// <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)
        {
            Helper.Content.InvalidateCache("LooseSprites/Cursors");
            if (OurMoon.GetMoonRiseTime() <= 0600 || OurMoon.GetMoonRiseTime() >= 2600 && ModConfig.ShowMoonPhase)
            {
                Game1.addHUDMessage(new TCHUDMessage(
                                        Helper.Translation.Get("moon-text.moonriseBefore6",
                                                               new { moonPhase = OurMoon.DescribeMoonPhase(), riseTime = OurMoon.GetMoonRiseDisplayTime() }),
                                        OurMoon.CurrentPhase()));
            }

            if (OurMoon == null)
            {
                Monitor.Log("OurMoon is null");
                return;
            }

            if (queuedMsg != null)
            {
                Game1.addHUDMessage(queuedMsg);
                queuedMsg = null;
            }

            if (Context.IsMainPlayer)
            {
                if (OurMoon.MoonTracker.CurrentSeason != Game1.currentSeason)
                {
                    OurMoon.MoonTracker.CurrentSeason      = Game1.currentSeason;
                    OurMoon.MoonTracker.FullMoonThisSeason = false;
                }
            }

            if (ModConfig.EclipseOn && OurMoon.MoonTracker.IsEclipseTomorrow)
            {
                OurMoon.IsEclipse = true;
                var n = new HUDMessage(Helper.Translation.Get("moon-text.solareclipse"))
                {
                    color    = Color.SeaGreen,
                    fadeIn   = true,
                    timeLeft = 4000,
                    noIcon   = true
                };
                Game1.addHUDMessage(n);
                MoonMessage message = GenerateLunarSync();
                MPHandler.SendMessage <MoonMessage>(message, "MoonMessage", new[] { "KoihimeNakamura.LunarDisturbances" });
                Monitor.Log("There's a solar eclipse today!", LogLevel.Info);
                OurMoon.MoonTracker.IsEclipseTomorrow = false;
            }


            OurMoon.UpdateForBloodMoon();
            OurMoon.OnNewDay();
            OurMoon.HandleMoonAfterWake();
        }
        private void OnModMessageRecieved(object sender, ModMessageReceivedEventArgs e)
        {
            if (e.FromModID == "KoihimeNakamura.LunarDisturbances" && e.Type == "NewFarmHandJoin" && Context.IsMainPlayer && !HasGottenSync)
            {
                MoonMessage message = GenerateLunarSync();
                MPHandler.SendMessage <MoonMessage>(message, "MoonMessage", new[] { "KoihimeNakamura.LunarDisturbances" }, new[] { e.FromPlayerID });
                HasGottenSync = true;
            }

            if (e.FromModID == "KoihimeNakamura.LunarDisturbances" && e.Type == "MoonMessage")
            {
                MoonMessage message = e.ReadAs <MoonMessage>();
                if (ModConfig.Verbose)
                {
                    Monitor.Log($"Message contents at {Game1.timeOfDay} : Eclipse Setting: {message.isEclipse})");
                }
                SetLunarSync(message);
            }
        }
 void SetLunarSync(MoonMessage m)
 {
     OurMoon.IsEclipse   = m.isEclipse;
     OurMoon.MoonTracker = new LunarInfo(m.currentMoonTracker);
     OurMoon.MoonTrackerUpdate();
 }