예제 #1
0
        /// <summary>
        /// Event that runs once a second
        /// </summary>
        /// <param name="sender">The sender</param>
        /// <param name="e">One Second Update Ticked event args.</param>
        public void OnOneSecondUpdateTicked(object sender, OneSecondUpdateTickedEventArgs e)
        {
            var str = SafeToRun();

            if (!str)
            {
                return;
            }

            if (_highlightArtifactSpots || _isDebugging)
            {
                ShowSpots();
            }

            if (_autoScan)
            {
                DoScan();

                if (_bushShaker)
                {
                    ShakeBushes();
                }

                if (_treeShaker)
                {
                    ShakeTrees();
                }
            }
        }
예제 #2
0
        /*
         * private void OnSaveLoaded(object sender, SaveLoadedEventArgs args)
         * {
         *  // get the internal asset key for the map file
         *  string mapAssetKey = this.Helper.Content.GetActualAssetKey("assets/10.tbin", ContentSource.ModFolder);
         *
         *  // add the location
         *  GameLocation mine10 = new GameLocation(mapAssetKey, "RevisedMineshaftTen") { IsOutdoors = false, IsFarm = false };
         *  Game1.locations.Add(mine10);
         * }
         */

        private void SecondUpdate(object sender, OneSecondUpdateTickedEventArgs e)
        {
            int xTile = Game1.player.getTileX();
            int yTile = Game1.player.getTileY();

            Warp w = new Warp(9, 10, "UndergroundMine10", 9, 10, false);

            if (monster != null && monster.health > 0)
            {
                this.Monitor.Log("There's a monster alive somewhere!", LogLevel.Debug);
                this.Monitor.Log($"Its health is {monster.health}", LogLevel.Debug);
            }

            if (monster != null && monster.health <= 0 && chestPop == 1)
            {
                chestPop = 0;
                this.Monitor.Log("The monster is dead!", LogLevel.Debug);
                Game1.player.chestConsumedMineLevels.Remove(10);
                Game1.player.warpFarmer(w);
            }

            bool isAltPressed = this.Helper.Input.IsDown(SButton.LeftAlt);

            if (isAltPressed)
            {
                this.Monitor.Log("You are pressing left alt", LogLevel.Debug);
            }
            else
            {
                this.Monitor.Log("Alt is not being pressed", LogLevel.Debug);
            }
        }
예제 #3
0
 public static void GameLoop_OneSecondUpdateTicked(object sender, OneSecondUpdateTickedEventArgs e)
 {
     if (ModEntry.callingNPC != null && Game1.activeClickableMenu == null)
     {
         if (ModEntry.currentCallRings < ModEntry.currentCallMaxRings && !ModEntry.inCall)
         {
             if (ModEntry.ringToggle == Config.PhoneRingInterval)
             {
                 Monitor.Log($"Phone ringing, {ModEntry.callingNPC.displayName} calling", LogLevel.Debug);
                 PhoneUtils.PlayRingTone();
                 ModEntry.currentCallRings++;
                 ModEntry.ringToggle = 0;
             }
             else
             {
                 ModEntry.ringToggle++;
             }
         }
         else
         {
             if (!ModEntry.inCall)
             {
                 ModEntry.callingNPC = null;
             }
             ModEntry.currentCallRings = 0;
         }
     }
 }
예제 #4
0
        internal static void OnOneSecondUpdateTicked(object sender, OneSecondUpdateTickedEventArgs e)
        {
            if (Game1.mine == null)
            {
                return;
            }

            if (Game1.player.CurrentTool is StardewValley.Tools.Pickaxe && LadderStones.Count == 0)
            {
                FindLadders();
            }
            else if (Reflection.GetField <bool>(Game1.mine, "ladderHasSpawned").GetValue())
            {
                LadderStones.Clear();
            }

            if (EasyPlay.Config.ForceLadder && Game1.mine.getMineArea(-1) == 121 && // Skull Mine area
                !NextIsLadder && LadderStones.Count > 0)
            {
                Random mineRandom = Reflection.GetField <Random>(Game1.mine, "mineRandom").GetValue();
                Random rng        = Clone(mineRandom);

                double nr = rng.NextDouble();
                while (nr >= 0.2)
                {
                    nr = rng.NextDouble();
                    mineRandom.NextDouble();
                }
                NextIsLadder = true;
            }
        }
예제 #5
0
        private static void OnOneSecondUpdateTicked(object sender,
                                                    OneSecondUpdateTickedEventArgs e)
        {
            lock (Context.QuestItems)
            {
                Context.QuestItems.Clear();
                using (var enumerator =
                           Game1.player.questLog.GetEnumerator())
                {
                    while (enumerator.MoveNext())
                    {
                        var current = enumerator.Current;
                        switch (current)
                        {
                        case ItemDeliveryQuest itemDeliveryQuest:
                            Context.QuestItems.Add(itemDeliveryQuest.item.Value);
                            break;

                        case ResourceCollectionQuest resourceCollectionQuest:
                            Context.QuestItems.Add(
                                resourceCollectionQuest.resource.Value);
                            break;

                        case FishingQuest fishingQuest:
                            Context.QuestItems.Add(fishingQuest.whichFish.Value);
                            break;
                        }
                    }
                }
            }
        }
예제 #6
0
 private void OneSecond(object sender, OneSecondUpdateTickedEventArgs e)
 {
     if (playerSprinting && !Game1.paused && Game1.player.isMoving())
     {
         Game1.player.Stamina = Math.Min(Game1.player.MaxStamina, Game1.player.Stamina - 0.5f);
     }
 }
예제 #7
0
        public static void GameLoop_OneSecondUpdateTicked(object sender, OneSecondUpdateTickedEventArgs e)
        {
            if (ModEntry.callingNPC != null && Game1.activeClickableMenu == null)
            {
                if (ModEntry.currentCallRings < ModEntry.currentCallMaxRings && !ModEntry.inCall)
                {
                    if (ModEntry.currentCallRings == 0 && Config.NotifyOnRing)
                    {
                        Game1.addHUDMessage(new HUDMessage(Helper.Translation.Get("phone-ringing"), 2));
                    }

                    if (ModEntry.ringToggle == Config.PhoneRingInterval)
                    {
                        Monitor.Log($"Phone ringing, {ModEntry.callingNPC.displayName} calling", LogLevel.Debug);
                        PhoneUtils.PlayRingTone();
                        ModEntry.currentCallRings++;
                        ModEntry.ringToggle = 0;
                    }
                    else
                    {
                        ModEntry.ringToggle++;
                    }
                }
                else
                {
                    PhoneUtils.StopRingTone();
                    if (!ModEntry.inCall)
                    {
                        ModEntry.callingNPC = null;
                    }
                    ModEntry.currentCallRings = 0;
                }
            }
        }
예제 #8
0
 private void OnOneSecondUpdateTicked(object sender, OneSecondUpdateTickedEventArgs e)
 {
     if (RingManager.HasCosmeticRingEquipped(Game1.player))
     {
         RingManager.UpdateRingEffects(Game1.player, Game1.currentLocation);
     }
 }
        /// <summary>When the "check crops" timer is set and matches the current time, check crop layers and clear the timer.</summary>
        private static void GameLoop_OneSecondUpdateTicked_CheckCrops(object sender, OneSecondUpdateTickedEventArgs e)
        {
            if (!Context.IsWorldReady || !Context.IsMainPlayer || CheckCropsAtThisTime == null || CheckCropsAtThisTime < Game1.currentGameTime.TotalGameTime.TotalSeconds) //if not ready yet, not the host player, or it's not time to check yet
            {
                return;                                                                                                                                                    //do nothing
            }
            CheckCropsAtThisTime = null;                                                                                                                                   //clear the timer

            Monitor.VerboseLog("Cleaning up crops from obsolete TMXL crop layers...");
            foreach (string name in LocationsToCheck)
            {
                GameLocation location = Game1.getLocationFromName(name);
                if (location == null)
                {
                    Monitor.LogOnce($"Failed to find location while cleaning up obsolete TMXL crop layers: \"{name}\"", LogLevel.Trace);
                    continue; //skip this location
                }

                if (location.modData.TryGetValue(ModDataKey, out string data) && !string.IsNullOrWhiteSpace(data))
                {
                    Monitor.VerboseLog($"Already cleaned location \"{name}\". Skipping cleanup.");
                    continue;
                }

                RemoveCrops(location);
                location.modData[ModDataKey] = "true"; //mark this location as clean for future checks
            }
            Monitor.VerboseLog($"Crop layer cleanup complete.");
        }
예제 #10
0
        private void OnOneSecondUpdateTicked(object sender, OneSecondUpdateTickedEventArgs e)
        {
            if (debugMode && e.IsMultipleOf(120))
            {
                VerifyAllSongs();
            }

            GameLocation location = Game1.player.currentLocation;

            if (location is null)
            {
                return;
            }

            if (location.currentEvent != null && !String.IsNullOrEmpty(location.miniJukeboxTrack.Value))
            {
                cachedRequestedSong = location.miniJukeboxTrack.Value;
                waitingForEventToFinishToResumeCachedSong = true;
            }
            else if (waitingForEventToFinishToResumeCachedSong)
            {
                location.miniJukeboxTrack.Value = cachedRequestedSong;

                cachedRequestedSong = null;
                waitingForEventToFinishToResumeCachedSong = false;
            }
        }
예제 #11
0
파일: ModEntry.cs 프로젝트: rfht/MOTDMod
        private void OnOneSecondUpdateTicked(object sender, OneSecondUpdateTickedEventArgs e)
        {
            List <long> toRemove = new List <long>();

            foreach (KeyValuePair <long, DateTime> kvp in newPlayerConnectTime)
            {
                TimeSpan elapsed = (DateTime.Now - kvp.Value);

                if (elapsed.Seconds > this.Config.Motd_delay)
                {
                    // send MOTD to player
                    Game1.server?.sendMessage(kvp.Key,
                                              new OutgoingMessage(10, Game1.player, LocalizedContentManager.LanguageCode.en,
                                                                  this.Config.Motd_text));
                    // alternatively (see github.com/funny-snek/anticheat-and-servercode):
                    // Game1.server.sendMessage(kvp.Key, Multiplayer.chatMessage, Game1.player,
                    //      this.Helper.Content.CurrentLocaleConstant, Motd_message);

                    // mark player for removal from the newPlayerConnectTime dictionary
                    toRemove.Add(kvp.Key);
                }
            }

            // remove all marked player entries from the dictionary
            foreach (long p in toRemove)
            {
                newPlayerConnectTime.Remove(p);
                this.Monitor.Log($"removed player {p.ToString()} from the list of new players");
            }
            // empty the toRemove list now that we're done with cleanup
            toRemove.Clear(); // may not be needed - the list may disappear at the end of the method anyway
        }
예제 #12
0
        private void GameLoop_OneSecondUpdateTicked(object sender, OneSecondUpdateTickedEventArgs e)
        {
            if (!Context.IsPlayerFree)
            {
                return;
            }

            bool wearing = JsonAssets.GetClothingId("Sixty-Nine Shirt") != -1 && Game1.player.shirtItem?.Value?.parentSheetIndex?.Value == JsonAssets.GetClothingId("Sixty-Nine Shirt");

            if (!wearing)
            {
                return;
            }

            //Monitor.Log("Wearing shirt... nice.");

            foreach (NPC npc in Game1.player.currentLocation.characters.Where(n => n.isVillager()))
            {
                if (Vector2.Distance(Game1.player.position, npc.position) < Config.MaxDistanceNice)
                {
                    if (!niceNPCs.Contains(npc.name))
                    {
                        npc.showTextAboveHead(Helper.Translation.Get("nice"));
                        niceNPCs.Add(npc.name);
                    }
                }
                else
                {
                    if (niceNPCs.Contains(npc.name))
                    {
                        niceNPCs.Remove(npc.name);
                    }
                }
            }
        }
예제 #13
0
        private void GameLoop_OneSecondUpdateTicked(object sender, OneSecondUpdateTickedEventArgs e)
        {
            var now = DateTime.Now;

            // Save check if new hour and reset without check if seconds==0 because of process change it could be already 1
            // Event comes every ~ 1 second
            if (now.Minute == 0 && lock_minute == 0 || lock_minute <= now.Minute)
            {
                istriggered = false;
                lock_minute = 0;
            }

            if (this.istriggered == false && Config.AlertOnFullHour && now.Minute == 0)
            {
                Notify(nameof(Models.TimeConfig.AlertOnFullHour));
            }
            else if (this.istriggered == false && Config.AlertSpecificMinute != 0 && DateTime.Now.Minute == Config.AlertSpecificMinute)
            {
                Notify(nameof(Models.TimeConfig.AlertSpecificMinute));
            }
            else if (this.istriggered == false && Config.AlertEveryXMinute != 0 && LastNotification.Add(new TimeSpan(0, Config.AlertEveryXMinute, 0)) < now)
            {
                Notify(nameof(Models.TimeConfig.AlertEveryXMinute));
            }
        }
예제 #14
0
        private void OnSecondUpdateTicked(object sender, OneSecondUpdateTickedEventArgs e)
        {
            // ignore if player hasn't loaded a save yet
            if (!Context.IsWorldReady)
            {
                return;
            }

            this.Monitor.Log("Calculating COVID transmission");

            Point playerLocation = Game1.player.getTileLocationPoint();

            this.Monitor.Log($"found player at ({playerLocation.X},{playerLocation.Y})");

            // Find all character positions
            using (DisposableList <NPC> .Enumerator enumerator = Utility.getAllCharacters().GetEnumerator())
            {
                while (enumerator.MoveNext())
                {
                    NPC   current           = enumerator.Current;
                    Point characterLocation = current.getTileLocationPoint();
                    this.Monitor.Log($"found character {current.getName()} at position ({characterLocation.X},{characterLocation.Y})");
                }
            }
        }
예제 #15
0
 private void GameLoop_OneSecondUpdateTicked(object sender, OneSecondUpdateTickedEventArgs e)
 {
     //this.Log( "Ticked: " + e.Ticks );
     if (!Context.IsMainPlayer)
     {
         return;
     }
 }
예제 #16
0
 /*********
 ** Private methods
 *********/
 /// <summary>Raised after the player presses a button on the keyboard, controller, or mouse.</summary>
 /// <param name="sender">The event sender.</param>
 /// <param name="e">The event data.</param>
 private void OncePerSecond(object sender, OneSecondUpdateTickedEventArgs e)
 {
     // ignore if player hasn't loaded a save yet
     if (!Context.IsWorldReady)
     {
         return;
     }
 }
예제 #17
0
        private void Event_LoadLate(object sender, OneSecondUpdateTickedEventArgs e)
        {
            this.Helper.Events.GameLoop.OneSecondUpdateTicked -= this.Event_LoadLate;

            if (this.LoadAPIs())
            {
                this.Initialise();
            }
        }
예제 #18
0
        public static void GameLoop_OneSecondUpdateTicked(object sender, OneSecondUpdateTickedEventArgs e)
        {
            if (!Config.EnableMod)
            {
                return;
            }

            Kissing.TrySpousesKiss(Game1.player.currentLocation);
        }
예제 #19
0
 private void GameLoop_OneSecondUpdateTicked(object sender, OneSecondUpdateTickedEventArgs e)
 {
     if (SleepPrimed)
     {
         SleepPrimed = false;
         WarpBack    = new Warp(Game1.player.getTileX(), Game1.player.getTileY(), Game1.currentLocation.Name, Game1.player.getTileX(), Game1.player.getTileY(), false);
         Game1.player.warpFarmer(WarpThere);
         Game1.player.warpFarmer(WarpBack);
     }
 }
예제 #20
0
 private static void Event_RegisterLevelExtenderLate(object sender, OneSecondUpdateTickedEventArgs e)
 {
     // LevelExtender/LEModApi.cs:
     // Please [initialise skill] ONCE in the Save Loaded event (to be safe, PLEASE ADD A 5 SECOND DELAY BEFORE initialization)
     if (Game1.currentGameTime.TotalGameTime.TotalSeconds - TotalSecondsOnLoaded >= 5)
     {
         Helper.Events.GameLoop.OneSecondUpdateTicked -= Event_RegisterLevelExtenderLate;
         RegisterSkillsWithLevelExtender();
     }
 }
예제 #21
0
        private void GameLoop_OneSecondUpdateTicked(object sender, OneSecondUpdateTickedEventArgs e)
        {
            if (!Context.IsWorldReady)
            {
                return;
            }

            bundles.Update();
            todolist.Update();
        }
예제 #22
0
 /*********
 ** Private methods
 *********/
 /// <summary>Raised once per second after the game state is updated.</summary>
 /// <param name="sender">The event sender.</param>
 /// <param name="e">The event arguments.</param>
 private void OnOneSecondUpdateTicked(object sender, OneSecondUpdateTickedEventArgs e)
 {
     foreach (GameLocation location in Game1.locations)
     {
         foreach (Fence fence in location.Objects.Values.OfType <Fence>())
         {
             fence.health.Value = fence.maxHealth.Value;
         }
     }
 }
예제 #23
0
        /// <summary>
        /// Event for showing a loading error (based on StardewHack)
        /// </summary>
        /// <param name="sender">Event sender</param>
        /// <param name="e">Event details</param>
        private void LoadingErrorOnTick(object sender, OneSecondUpdateTickedEventArgs e)
        {
            if (e.Ticks < 60)
            {
                return;
            }

            // And only fire once.
            Helper.Events.GameLoop.OneSecondUpdateTicked -= LoadingErrorOnTick;
            ReportLoadingError();
        }
예제 #24
0
 private void OnUpdateTicked(object sender, OneSecondUpdateTickedEventArgs e)
 {
     if (Game1.mine == null)
     {
         return;
     }
     if (_ladderStones.Count > 0 || FindLadders(Game1.mine))
     {
         Helper.Events.GameLoop.OneSecondUpdateTicked -= OnUpdateTicked;
     }
 }
예제 #25
0
        private void OnOneSecondUpdateTicked(object sender, OneSecondUpdateTickedEventArgs e)
        {
            if (!screenshotTaken && takeShot && Game1.timeOfDay >= config.TakeScreenshotAfter)
            {
                takeShot = false;

                var filename = GetFarmName() + "_Year" + Game1.Date.Year + "_Season" + Game1.Date.SeasonIndex + "_Day" + Game1.Date.DayOfMonth + "_Time" + Game1.timeOfDay;

                Game1.game1.takeMapScreenshot(config.Resolution / 100f, filename);
                screenshotTaken = true;
            }
        }
예제 #26
0
        internal void OnOneSecondUpdateTicked(object sender, OneSecondUpdateTickedEventArgs e)
        {
            if (!Context.IsWorldReady || !Game1.player.IsMainPlayer)
            {
                return;
            }
            else if (StartedOpeningEvent)
            {
                return;
            }
            try
            {
                GameLocation location = Game1.getLocationFromName("Custom_Ridgeside_RidgeFalls");
                bool         all_done = true;
                foreach (var pedestal in PedestalTemplates)
                {
                    ItemPedestal itemPedestal = (ItemPedestal)location.Objects[pedestal.tilePosition];
                    if (!itemPedestal.match.Value)
                    {
                        all_done = false;
                        break;
                    }
                }
                if (all_done)
                {
                    //check if we can start the event
                    if (Game1.eventUp || Game1.currentLocation.currentEvent != null || Game1.farmEvent != null || !StardewModdingAPI.Context.CanPlayerMove || Game1.IsFading())
                    {
                        return;
                    }
                    foreach (var pedestal in PedestalTemplates)
                    {
                        ItemPedestal itemPedestal = (ItemPedestal)location.Objects[pedestal.tilePosition];
                        itemPedestal.locked.Value = true;
                    }
                    StartedOpeningEvent = true;
                    Helper.Events.GameLoop.OneSecondUpdateTicked -= OnOneSecondUpdateTicked;
                    var Events = location.GetLocationEvents();

                    var PortalEvent = new Event(Events["75160256/n InexistentMailFlag"], eventID: 75160256);
                    // Moved add special order command to UntimedSO
                    UtilFunctions.StartEvent(PortalEvent, "Custom_Ridgeside_RidgeFalls", 15, 43);
                }
            }
            catch (Exception exception) { Log.Warn("Issue with pedestals detected in OneSecondUpdate. Check Trace for Details");
                                          Log.Trace(exception.Message);
                                          Log.Trace(exception.StackTrace);
                                          Helper.Events.GameLoop.OneSecondUpdateTicked -= OnOneSecondUpdateTicked; }
        }
예제 #27
0
 private void OneSecondUpdateTicked(object sender, OneSecondUpdateTickedEventArgs e)
 {
     if (this.QuitGame)
     {
         if (this.QuitGameTimer > 0)
         {
             this.QuitGameTimer--;
             this.Monitor.Log($"Shutting down in {this.QuitGameTimer}...", LogLevel.Info);
         }
         if (this.QuitGameTimer <= 0)
         {
             Environment.Exit(0);
         }
     }
 }
예제 #28
0
        /* stamina drain */
        private void OneSecond(object sender, OneSecondUpdateTickedEventArgs e)
        {
            if (!Context.IsWorldReady)
            {
                return;
            }

            if (Config.StaminaDrain.DrainStamina)
            {
                if (playerSprinting && !Game1.paused && Game1.player.isMoving())
                {
                    Game1.player.Stamina = Math.Min(Game1.player.MaxStamina, Game1.player.Stamina - this.Config.StaminaDrain.StaminaDrainCost);
                }
            }
        }
예제 #29
0
 private void OnOneSecondUpdateTicked(object sender, OneSecondUpdateTickedEventArgs e)
 {
     if (firstTick)
     {
         try
         {
             foreach (Child child in Game1.player.getChildren())
             {
                 child.reloadSprite();
             }
             firstTick = false;
         }
         catch (Exception) { }
     }
 }
예제 #30
0
 private void GameLoop_OneSecondUpdateTicked(object sender, OneSecondUpdateTickedEventArgs e)
 {
     //check for new players and broadcast gate positions
     if (Game1.IsMultiplayer && StardewModdingAPI.Context.IsWorldReady)
     {
         int newPlayerCount = Enumerable.Count(Helper.Multiplayer.GetConnectedPlayers());
         if (newPlayerCount != PlayerCount)
         {
             if (newPlayerCount > PlayerCount)
             {
                 SendGates();
             }
             PlayerCount = newPlayerCount;
         }
     }
 }