Exemple #1
0
        public void TimeEvents_DayOfMonthChanged(object sender, StardewModdingAPI.Events.EventArgsNewDay e)
        {
            if (game_loaded == false)
            {
                return;
            }
            if (first_check == false)
            {
                first_check = true;
                Log.Info("first");
                return;
            }
            else
            {
                first_check = false;
                Log.Info("Second");
            }
            if (Game1.farmerShouldPassOut == true)
            {
                Game1.farmerShouldPassOut = false;                                 //make the farmer collapse.
            }
            reset_check = false;
            //Game1.farmerShouldPassOut = false; //make the farmer collapse.
            DataLoader();
            MyWritter();
            //List<string> newmail = new List<string>();
            Queue <string> newmail = new Queue <string>();

            up_late = false;

            if (time_reset == true)
            {
                was_raining = false;
                if (persistant_stamina == true)
                {
                    Game1.player.stamina = pre_stam;                           //reset health and stam upon collapsing
                }
                if (persistant_health == true)
                {
                    Game1.player.health = pre_health;
                }
                //post_money = Game1.player.money;
                if (protect_money == true)
                {
                    Game1.player.money += post_money;
                    once = true;
                } //add the money back from colapsing.
                time_reset = false; //reset my bool.
                if (warp == true)
                {
                    Game1.warpFarmer(prior_map, player_x, player_y, false);
                }
                // very_old_money = (safety_cash - Game1.player.money);
                //Game1.player.money += very_old_money;
            }

            if (wipe_mail == true)
            {
                foreach (var i in Game1.mailbox) //delete those annoying charge messages. If only I could do this with mail IRL.
                {
                    Log.Info(i);

                    if (i.Contains("passedOut"))
                    {
                        Log.Info("Found bad mail");
                    }
                    else
                    {
                        newmail.Enqueue(i);
                    }
                }
                Game1.mailbox.Clear();
                foreach (string mail in newmail)
                {
                    Game1.mailbox.Enqueue(mail);
                }
            }
            warped_check = false;
            //prior_map==null; //prevents multiple warping when sleeping
        }
        public void TimeEvents_DayOfMonthChanged(object sender, StardewModdingAPI.Events.EventArgsNewDay e)
        {
            /*
             * IMPLEMENT TRY CATCH SYSTEM HERE
             *
             */
            try {
                if (game_loaded == false)
                {
                    return;
                }
                if (first_check == false)
                {
                    first_check = true;
                    Log.Info("first");
                    return;
                }
                else
                {
                    first_check = false;
                    Log.Info("Second");
                }
                if (Game1.farmerShouldPassOut == true)
                {
                    Game1.farmerShouldPassOut = false;                             //make the farmer collapse.
                }
                reset_check = false;
                //Game1.farmerShouldPassOut = false; //make the farmer collapse.
                DataLoader();
                MyWritter();
                //List<string> newmail = new List<string>();
                Queue <string> newmail = new Queue <string>();

                up_late = false;

                if (time_reset == true)
                {
                    was_raining = false;
                    if (persistant_stamina == true)
                    {
                        Game1.player.stamina = pre_stam;                       //reset health and stam upon collapsing
                    }
                    if (persistant_health == true)
                    {
                        Game1.player.health = pre_health;
                    }
                    //post_money = Game1.player.money;
                    if (protect_money == true)
                    {
                        Game1.player.money += post_money;
                        once = true;
                    } //add the money back from colapsing.
                    time_reset = false; //reset my bool.
                    if (warp == true)
                    {
                        Game1.warpFarmer(prior_map, player_x, player_y, false);
                    }
                    // very_old_money = (safety_cash - Game1.player.money);
                    //Game1.player.money += very_old_money;
                }

                if (wipe_mail == true)
                {
                    foreach (var i in Game1.mailbox) //delete those annoying charge messages. If only I could do this with mail IRL.
                    {
                        Log.Info(i);

                        if (i.Contains("passedOut"))
                        {
                            Log.Info("Found bad mail");
                        }
                        else
                        {
                            newmail.Enqueue(i);
                        }
                    }
                    Game1.mailbox.Clear();
                    foreach (string mail in newmail)
                    {
                        Game1.mailbox.Enqueue(mail);
                    }
                }
                warped_check = false;
                //prior_map==null; //prevents multiple warping when sleeping
            }
            catch (Exception ex)
            {
                try
                {
                    Newtonsoft.Json.JsonSerializer serializer = new Newtonsoft.Json.JsonSerializer();
                    serializer.NullValueHandling     = Newtonsoft.Json.NullValueHandling.Ignore;
                    serializer.TypeNameHandling      = Newtonsoft.Json.TypeNameHandling.All;
                    serializer.Formatting            = Newtonsoft.Json.Formatting.Indented;
                    serializer.ReferenceLoopHandling = ReferenceLoopHandling.Ignore;
                    using (StreamWriter sw = new StreamWriter(Path.Combine(Error_Path, "Mod_State.json")))
                    {
                        using (Newtonsoft.Json.JsonWriter writer2 = new Newtonsoft.Json.JsonTextWriter(sw))
                        {
                            serializer.Serialize(writer2, this, typeof(Stardew_NightOwl.Class1));
                        }
                    }
                }
                catch (Exception exc)
                {
                    Log.Info(exc);
                }
                Stardew_Omegasis_Utilities.Mod.Error_Handling.Log_Error(new List <string>(), ex);
            }
        }