private void TimeEvents_TimeOfDayChanged(object sender, EventArgsIntChanged e)
 {
     if (e.NewInt == 700 || e.NewInt == 1200 || e.NewInt == 18)
     {
         Delivery.checkMail();
     }
 }
Example #2
0
 private void ReceiveTimeOfDayChanged(object sender, EventArgsIntChanged e)
 {
     if (Util.Config.notifyBirthdayReminder && e.NewInt == Util.Config.birthdayReminderTime)
     {
         generalNotification.DoBirthdayReminder();
     }
 }
Example #3
0
 private void TimeEvents_TimeOfDayChanged(object sender, EventArgsIntChanged eventArgsIntChanged)
 {
     if (_gameLoaded && _config.EnableMod)
     {
         ProcessIfTimeAndWeatherFits();
     }
 }
Example #4
0
        private void TimeEvents_TimeOfDayChanged(object sender, EventArgsIntChanged e)
        {
            if (!Game1.hasLoadedGame)
            {
                return;
            }

            Cheats.onTimeOfDayChanged();
        }
 private void OnTimeOfDayChanged(object sender, EventArgsIntChanged inTime)
 {
     ModLogging.Log("Time of day has changed!");
     if (_outside && !IsDarkness())
     {
         ModLogging.Log("Vulnerable To Damage!");
         _underlyingCharacter.Stamina -= SunDamagePerCycle;
     }
 }
Example #6
0
        private void TimeEvents_TimeOfDayChanged(object sender, EventArgsIntChanged e)
        {
            if (!this.IsLoaded)
            {
                return;
            }

            this.Cheats.OnTimeOfDayChanged();
        }
 private void TimeEvents_DayOfMonthChanged(object sender, EventArgsIntChanged e)
 {
     if (_config.EnableMod)
     {
         Monitor.Log("It's a new day. Resetting the Item Collector mod");
         _machinesProcessor.ValidateGameLocations();
         _buildingProcessor.DailyReset();
         _machinesProcessor.DailyReset();
     }
 }
Example #8
0
        private void TimeOfDayChanged(object sender, EventArgsIntChanged e)
        {
            // Deliver mail every 30 mins
            var timeString  = e.NewInt.ToString();
            var correctTime = timeString.EndsWith("30") || timeString.EndsWith("00");

            if (_configService.InDebugMode() && e.NewInt != 600 && correctTime)
            {
                ModEvents.RaiseOnMailCleanup(this, EventArgs.Empty);
            }
        }
Example #9
0
        /// <summary>The method invoked when <see cref="Game1.timeOfDay"/> changes.</summary>
        /// <param name="sender">The event sender.</param>
        /// <param name="e">The event data.</param>
        private void TimeEvents_TimeOfDayChanged(object sender, EventArgsIntChanged e)
        {
            if (!Context.IsWorldReady)
            {
                return;
            }

            try
            {
                // transition morning light more realistically
                if (this.Config.MorningLightTransition && Game1.timeOfDay > 400 && Game1.timeOfDay < 600)
                {
                    float colorMod = (1300 - Game1.timeOfDay) / 1000f;
                    Game1.outdoorLight = Game1.ambientLight * colorMod;
                }

                // transition to next morning
                if (this.Config.StayUp && Game1.timeOfDay == 2550)
                {
                    Game1.isRaining = false; // remove rain, otherwise lighting gets screwy
                    Game1.updateWeatherIcon();
                    Game1.timeOfDay = 150;   //change it from 1:50 am late, to 1:50 am early
                }

                // collapse player at 6am to save & reset
                if (Game1.timeOfDay == 550)
                {
                    this.IsUpLate = true;
                }
                if (this.IsUpLate && Game1.timeOfDay == 600 && !this.JustCollapsed)
                {
                    this.JustCollapsed = true;

                    this.ShouldResetPlayerAfterCollapseNow = true;
                    this.PreCollapseTile    = new Point(Game1.player.getTileX(), Game1.player.getTileY());
                    this.PreCollapseMap     = Game1.player.currentLocation.name;
                    this.PreCollapseStamina = Game1.player.stamina;
                    this.PreCollapseHealth  = Game1.player.health;
                    this.PreCollapseMoney   = Game1.player.money;

                    if (Game1.currentMinigame != null)
                    {
                        Game1.currentMinigame = null;
                    }
                    Game1.farmerShouldPassOut = true;
                }
            }
            catch (Exception ex)
            {
                this.Monitor.Log(ex.ToString(), LogLevel.Error);
                this.WriteErrorLog();
            }
        }
Example #10
0
 private void TimeOfDayChanged(object sender, EventArgsIntChanged e)
 {
     if (isIdle)
     {
         Game1.pauseThenMessage(200, "You are now idle", false);
         this.Monitor.Log($"{Game1.player.name} idle at {Game1.timeOfDay}");
     }
     if (Game1.timeOfDay > lastPressedTime + idleTimer)
     {
         isIdle = true;
     }
 }
        private void TimeEvents_TimeOfDayChanged(object sender, EventArgsIntChanged e)
        {
            if (!this.IsReady)
            {
                return;
            }

            foreach (MachineMetadata[] machines in this.Machines.Values)
            {
                this.ProcessMachines(machines);
            }
        }
 private void TimeEvents_TimeOfDayChanged(object sender, EventArgsIntChanged e)
 {
     //~ if (Game1.timeOfDay == 630) {
     //~ Game1.timeOfDay=2000;
     //~ }
     if (!Context.IsWorldReady)
     {
         return;
     }
     this.lastToD    = this.currentToD;
     this.currentToD = Game1.timeOfDay;
 }
Example #13
0
 private void TimeEvents_DayOfMonthChanged(object sender, EventArgsIntChanged e)
 {
     //new_day = true;
     // Log.Info("Day of Month Changed");
     npc_key_value_pair.Clear();
     foreach (var loc in Game1.locations)
     {
         foreach (var character in loc.characters)
         {
             npc_key_value_pair.Add(character.name, get_key_value(character));
         }
     }
 }
Example #14
0
        public static void ResetAllDailyBooleans(object sender, EventArgsIntChanged e)
        {
            SetUp.createDirectories();
            hasWateredAllCropsToday = false;
            if (Lists.trackedTerrainFeatures != null)
            {
                if (Class1.hasLoadedTerrainList == true)
                {
                    Serialize.serializeTrackedTerrainDataNodeList(Lists.trackedTerrainFeatures);
                }
            }

            Util.WaterAllCropsInAllLocations();
        }
Example #15
0
        private void TimeEvents_TimeOfDayChanged(object sender, EventArgsIntChanged e)
        {
            int time = e.PriorInt;

            if (time % 100 == 0 && !Game1.isDarkOut())
            {
                for (int i = 0; i < LoadData.objectlist.Count(); i++)
                {
                    if (LoadData.objectlist[i] is JunimoHelper)
                    {
                        (LoadData.objectlist[i] as JunimoHelper).helperAction();
                    }
                }
            }
        }
        public void Update(object sender = null, EventArgsIntChanged e = null)
        {
            Multiplayer multiplayer = (Multiplayer)typeof(Game1).GetField("multiplayer", BindingFlags.NonPublic | BindingFlags.Static).GetValue(null);

            MaxPlayers     = multiplayer.MaxPlayers;
            CurrentPlayers = Game1.otherFarmers.Where(f => f.Value != Game1.player && f.Value.isActive()).Count();
            LastUpdate     = (Int32)(DateTime.UtcNow.Subtract(new DateTime(2018, 1, 1))).TotalSeconds;
            if (CurrentPlayers >= MaxPlayers)
            {
                Dispose();
            }
            else
            {
                Task.Run(() => farms.Child(Id).PutAsync(this));
            }
        }
Example #17
0
        private void TimeEvents_TimeOfDayChanged(object sender, EventArgsIntChanged e)
        {
            bool left  = Game1.player.leftRing.Value is GiantRing;
            bool right = Game1.player.rightRing.Value is GiantRing;

            if (left && right)
            {
                this.numberOfTimeTicksWearingOneRing++;
                this.numberOfTimeTicksWearingTwoRings++;
            }
            else if (left || right)
            {
                this.numberOfTimeTicksWearingOneRing++;
            }

            this.totalNumberOfSeenTimeTicks++;
        }
 private void TimeEvents_TimeOfDayChanged(object sender, EventArgsIntChanged e)
 {
     if (_gameLoaded && _config.EnableMod)
     {
         try
         {
             _buildingProcessor.ProcessAnimalBuildings();
             _buildingProcessor.ProcessMachineBuildings(_machineBuildingConfigs);
             _machinesProcessor.ProcessMachines();
         }
         catch (Exception ex)
         {
             Monitor.Log($"an error occured with the automation mod: {ex}", LogLevel.Error);
             _machinesProcessor.DailyReset();
         }
     }
 }
Example #19
0
        private void TimeEvents_TimeOfDayChanged(object sender, EventArgsIntChanged e)
        {
            if (!Context.IsWorldReady)
            {
                return;
            }

            int change = e.PriorInt - e.NewInt;

            if (Math.Abs(change) > 100)
            {
                //if (change >= 0)
                //sanity = Math.Max(sanity - 15.0, 0);
                //else
                //sanity = Math.Min(sanity + 5.0, 100.0);
            }
        }
Example #20
0
        private void TimeEvents_TimeOfDayChanged(object sender, EventArgsIntChanged e)
        {
            SFarmer who = Game1.player;

            if (who != null && who.currentLocation != null && Game1.isDarkOut())
            {
                List <Critter> currentCritters = Helper.Reflection.GetField <List <Critter> >(who.currentLocation, "critters").GetValue();
                if (currentCritters != null)
                {
                    for (int i = 0; i < currentCritters.Count; i++)
                    {
                        if (currentCritters[i] is Cloud)
                        {
                            currentCritters.Remove(currentCritters[i]);
                        }
                    }
                }
            }
        }
Example #21
0
 private void TimeEvents_DayOfMonthChanged(object sender, EventArgsIntChanged e)
 {
     try
     {
         //new_day = true;
         // Log.Info("Day of Month Changed");
         npc_key_value_pair.Clear();
         foreach (var loc in Game1.locations)
         {
             location_name = loc.name;
             foreach (var character in loc.characters)
             {
                 npc_name = character.name;
                 npc_key_value_pair.Add(character.name, get_key_value(character));
             }
         }
     }
     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(Save_Anywhere_V2.Mod_Core));
                 }
             }
         }
         catch (Exception exc)
         {
             Log.Info(exc);
         }
         Stardew_Omegasis_Utilities.Mod.Error_Handling.Log_Error(new List <string>(), ex);
     }
 }
Example #22
0
        /*
         * END SAVE AND LOADING
         *
         */



        /*
         * SPEED UP KEG INSIDE WINERY
         *
         */
        public void TimeEvents_TimeOfDayChanged(object sender, EventArgsIntChanged e)
        {
            if (this.DistillerProfessionActive)
            {
                SetItemCategory(-77);
            }
            //monitor.Log($"Time is " + Game1.timeOfDay + " and it is " + Game1.dayOrNight());
            foreach (Building b in Game1.getFarm().buildings)
            {
                if (b.indoors.Value != null && b.buildingType.Value.Equals("Winery"))
                {
                    foreach (SObject o in b.indoors.Value.Objects.Values)
                    {
                        if (o.Name.Equals("Keg"))
                        {
                            o.MinutesUntilReady -= 3;
                        }
                    }
                }
            }
        }
Example #23
0
        private void TimeEvents_TimeOfDayChanged(object sender, EventArgsIntChanged e)
        {
            if (IsEclipse)
            {
                Game1.globalOutdoorLighting = .5f;
                Game1.ambientLight          = nightColor;
                Game1.currentLocation.switchOutNightTiles();
                ResetTicker = 1;

                if (!Game1.currentLocation.isOutdoors && Game1.currentLocation is DecoratableLocation)
                {
                    var loc = Game1.currentLocation as DecoratableLocation;
                    foreach (Furniture f in loc.furniture)
                    {
                        if (f.furniture_type == Furniture.window)
                        {
                            Helper.Reflection.GetMethod(f, "addLights").Invoke(new object[] { Game1.currentLocation });
                        }
                    }
                }

                if ((Game1.farmEvent == null && Game1.random.NextDouble() < (0.25 - Game1.dailyLuck / 2.0)) &&
                    ((Config.SpawnMonsters && Game1.spawnMonstersAtNight) || (Config.SpawnMonstersAllFarms)))
                {
                    Monitor.Log("Spawning a monster, or attempting to.", LogLevel.Debug);
                    if (Game1.random.NextDouble() < 0.25)
                    {
                        if (this.Equals(Game1.currentLocation))
                        {
                            Game1.getFarm().spawnFlyingMonstersOffScreen();
                            return;
                        }
                    }
                    else
                    {
                        Game1.getFarm().spawnGroundMonsterOffScreen();
                    }
                }
            }
        }
Example #24
0
        private void TimeEvents_TimeOfDayChanged(object sender, EventArgsIntChanged e)
        {
            List <GameLocation> locations = new List <GameLocation>();

            foreach (GameLocation gLoc in Game1.locations)
            {
                if (!gLoc.name.Contains("Farm") && !gLoc.name.Contains("GreenHouse"))
                {
                    continue;
                }

                locations.Add(gLoc);

                if (gLoc is BuildableGameLocation)
                {
                    BuildableGameLocation bLoc = (BuildableGameLocation)gLoc;
                    foreach (Building build in bLoc.buildings)
                    {
                        if (build.indoors != null)
                        {
                            locations.Add(build.indoors);
                        }
                    }
                }
            }

            foreach (GameLocation loc in locations)
            {
                foreach (KeyValuePair <Vector2, StardewValley.Object> kp in loc.objects)
                {
                    if (kp.Value == null)
                    {
                        continue;
                    }
                    ProcessObject(loc, kp.Key, kp.Value);
                }
            }
            locations.Clear();
        }
Example #25
0
 private void OnTimeChange(object sender, EventArgsIntChanged eventArgs)
 {
     if (TimeOfDay != config.TimeToStore)
     {
         // Do nothing, unless time of day is TimeToStore
         return;
     }
     if (justLoaded)
     {
         // Don't back up old save if this is the first day since loading
         // Caveat: Going to sleep before TimeToStore keeps this as true
         justLoaded = false;
         return;
     }
     if (GameDay % config.NoverwriteEveryXDays != config.NoverwriteDayOffset)
     {
         // Only back up every X days
         return;
     }
     // All criteria have been met, store the save
     StoreOldSave();
 }
Example #26
0
        /*********
        ** Private methods
        *********/
        private void TimeEvents_TimeOfDayChanged(object sender, EventArgsIntChanged e)
        {
            List <GameLocation> locations = new List <GameLocation>();

            foreach (GameLocation location in Game1.locations)
            {
                if (!location.IsFarm && !location.name.Contains("GreenHouse") && location.name != "Cellar")
                {
                    continue;
                }

                locations.Add(location);

                if (location is BuildableGameLocation buildableLocation)
                {
                    foreach (Building build in buildableLocation.buildings)
                    {
                        if (build.indoors != null)
                        {
                            locations.Add(build.indoors);
                        }
                    }
                }
            }

            foreach (GameLocation location in locations)
            {
                foreach (KeyValuePair <Vector2, SObject> pair in location.objects)
                {
                    if (pair.Value == null)
                    {
                        continue;
                    }
                    ProcessObject(location, pair.Key, pair.Value);
                }
            }
            locations.Clear();
        }
Example #27
0
 private static void DelayedRebuild(object sender, EventArgsIntChanged e)
 {
     SaveHandler.Rebuild();
     TimeEvents.TimeOfDayChanged -= DelayedRebuild;
 }
Example #28
0
        /// <summary>The method invoked when <see cref="Game1.timeOfDay"/> changes.</summary>
        /// <param name="sender">The event sender.</param>
        /// <param name="e">The event data.</param>
        private void TimeEvents_TimeOfDayChanged(object sender, EventArgsIntChanged e)
        {
            if (!Context.IsWorldReady)
            {
                return;
            }

            try
            {
                // transition morning light more realistically
                if (this.Config.MorningLightTransition && Game1.timeOfDay > 400 && Game1.timeOfDay < 600)
                {
                    float colorMod = (1300 - Game1.timeOfDay) / 1000f;
                    Game1.outdoorLight = Game1.ambientLight * colorMod;
                }

                // transition to next morning
                if (this.Config.StayUp && Game1.timeOfDay == 2550)
                {
                    Game1.isRaining = false; // remove rain, otherwise lighting gets screwy
                    Game1.updateWeatherIcon();
                    Game1.timeOfDay = 150;   //change it from 1:50 am late, to 1:50 am early
                    foreach (FarmAnimal animal in Game1.getFarm().getAllFarmAnimals())
                    {
                        this.oldAnimalHappiness.Add(animal.happiness);
                    }
                }

                // collapse player at 6am to save & reset
                if (Game1.timeOfDay == 550)
                {
                    this.IsUpLate = true;
                }
                if (this.IsUpLate && Game1.timeOfDay == 600 && !this.JustCollapsed)
                {
                    if (Game1.player.isRidingHorse())
                    {
                        foreach (var character in Game1.player.currentLocation.characters)
                        {
                            try
                            {
                                if (character is Horse)
                                {
                                    (character as Horse).dismount();
                                    horse           = (character as Horse);
                                    shouldWarpHorse = true;
                                }
                            }
                            catch (Exception err)
                            {
                            }
                        }
                    }
                    this.JustCollapsed = true;

                    this.ShouldResetPlayerAfterCollapseNow = true;
                    this.PreCollapseTile    = new Point(Game1.player.getTileX(), Game1.player.getTileY());
                    this.PreCollapseMap     = Game1.player.currentLocation.Name;
                    this.PreCollapseStamina = Game1.player.stamina;
                    this.PreCollapseHealth  = Game1.player.health;
                    this.PreCollapseMoney   = Game1.player.money;
                    this.isInSwimSuit       = Game1.player.bathingClothes.Value;
                    this.isBathing          = Game1.player.swimming.Value;



                    if (Game1.currentMinigame != null)
                    {
                        Game1.currentMinigame = null;
                    }

                    if (Game1.activeClickableMenu != null)
                    {
                        Game1.activeClickableMenu.exitThisMenu(true); //Exit menus.
                    }
                    Game1.timeOfDay += 2400;                          //Recalculate for the sake of technically being up a whole day.

                    //Reset animal happiness since it drains over night.
                    for (int i = 0; i < oldAnimalHappiness.Count; i++)
                    {
                        Game1.getFarm().getAllFarmAnimals()[i].happiness.Value = oldAnimalHappiness[i].Value;
                    }

                    Game1.player.startToPassOut();
                }
            }
            catch (Exception ex)
            {
                this.Monitor.Log(ex.ToString(), LogLevel.Error);
                this.WriteErrorLog();
            }
        }
Example #29
0
 private void TimeEvents_TimeOfDayChanged(object sender, EventArgsIntChanged e)
 {
     if (nightFixMode == NightFixMode.Maximized)
     {
         foreach (FarmAnimal animal in Game1.getFarm().getAllFarmAnimals())
         {
             animal.happiness = (byte)255;
         }
     }
     else
     {
         // Happiness is calculated correctly in the winter, so only fix it if it's not winter
         if (!Game1.currentSeason.Equals("winter"))
         {
             // At 5:50pm, record animals' happiness
             if (e.NewInt == 1750)
             {
                 happinessMap = new Dictionary <long, byte>();
                 foreach (FarmAnimal animal in Game1.getFarm().getAllFarmAnimals())
                 {
                     happinessMap[animal.myID] = animal.happiness;
                 }
             }
             if (e.NewInt >= 1800)
             {
                 // Each time change after that, if the animal is inside, reset the happiness to the last known good value
                 foreach (Building building in Game1.getFarm().buildings)
                 {
                     if (building.indoors != null && building.indoors.GetType() == typeof(AnimalHouse))
                     {
                         foreach (KeyValuePair <long, FarmAnimal> animal in (Dictionary <long, FarmAnimal>)((AnimalHouse)building.indoors).animals)
                         {
                             if (!happinessMap.ContainsKey(animal.Key))
                             {
                                 // This should only happen if the user cheats to get a new animal after 6pm
                                 happinessMap[animal.Key] = animal.Value.happiness;
                                 continue;
                             }
                             var happiness    = (int)happinessMap[animal.Key];
                             int newHappiness = (int)animal.Value.happiness;
                             if (newHappiness >= happiness)
                             {
                                 // Not sure why this would happen, but just in case
                                 happiness = newHappiness;
                             }
                             if (nightFixMode == NightFixMode.Increased)
                             {
                                 // If the user config mode is Increased, add happiness for being safe in the stable after 6pm
                                 happiness = Math.Min(byte.MaxValue, (happiness + animal.Value.happinessDrain));
                             }
                             animal.Value.happiness   = (byte)happiness;
                             happinessMap[animal.Key] = (byte)happiness;
                         }
                     }
                 }
                 // If the animal is outside, record a new known good value
                 foreach (KeyValuePair <long, FarmAnimal> animal in (Dictionary <long, FarmAnimal>)Game1.getFarm().animals)
                 {
                     happinessMap[animal.Key] = animal.Value.happiness;
                 }
             }
         }
     }
 }
Example #30
0
 private void TimeEvents_DayOfMonthChanged(object sender, EventArgsIntChanged eventArgsIntChanged)
 {
     ResetDoorStatesOnNewDay();
 }