Exemplo n.º 1
0
 private static void GameLoop_UpdateTicked(object sender, StardewModdingAPI.Events.UpdateTickedEventArgs e)
 {
     if (!Context.IsWorldReady)
     {
         return;
     }
 }
Exemplo n.º 2
0
        private void GameLoop_UpdateTicked(object sender, StardewModdingAPI.Events.UpdateTickedEventArgs e)
        {
            // check for followup dialogue

            if (Game1.activeClickableMenu == null && responseData != null)
            {
                DialogueTree p = responseData.nextTopic;

                Monitor.Log($"Asking about followup topic {loadedTopicNames[p.topicID]}");

                Dictionary <string, string> npcDic = Helper.Content.Load <Dictionary <string, string> >($"Characters/Dialogue/{responseData.npc.name}", ContentSource.GameContent);
                List <string> npcKeys = npcDic.Keys.ToList();

                List <Response> responses = new List <Response>();
                foreach (var r in p.responseIDs)
                {
                    Monitor.Log(r);
                    responses.Add(new Response($"DialogueTrees_Response#{responseData.npc.Name}#{p.topicID}#{r}", string.Format(loadedResponseStrings[r], loadedTopicNames[p.topicID])));
                }
                string        qid = p.questionIDs[myRand.Next(p.questionIDs.Count)];
                List <string> possibleQuestionStrings = npcDic.Keys.ToList().FindAll(k => k.StartsWith("DialogueTrees_question_" + qid + "_"));
                string        questionString          = possibleQuestionStrings.Any() ? npcDic[possibleQuestionStrings[myRand.Next(possibleQuestionStrings.Count)]] : loadedQuestionStrings[qid];

                Game1.player.currentLocation.createQuestionDialogue(string.Format(questionString, loadedTopicNames[p.topicID]), responses.ToArray(), "DialogueTrees_NPC_Question");
                Game1.objectDialoguePortraitPerson = responseData.npc;
            }
        }
Exemplo n.º 3
0
        void GameLoop_UpdateTicked(object sender, StardewModdingAPI.Events.UpdateTickedEventArgs e)
        {
            if (Game1.currentLocation == null || !Game1.player.hasPet() || GetPet() == null)
            {
                return;
            }

            switch (petState)
            {
            case PetState.Vanilla:
                break;

            case PetState.CatchingUp:
            case PetState.Chasing:
            case PetState.Fetching:
            case PetState.Retrieve:

                CatchUp();

                if (petState == PetState.Fetching && CurrentPath.Count == 4 && GetPet() is Cat cat)
                {
                    cat.leap(null);
                }

                if (CurrentPath.Count == 0)
                {
                    if (petState == PetState.Retrieve)
                    {
                        DropItem();
                    }
                    else if (petState == PetState.Fetching)
                    {
                        PickUpItem();
                    }
                    else
                    {
                        if (petState == PetState.Chasing)
                        {
                            Jump();
                        }
                        SetState(PetState.Waiting);
                    }
                }

                else if (PetCurrentCatchUpGoalDistance() <= 4)
                {
                    Vector2 pos = CurrentPath.Dequeue();
                    SetPetPositionFromTile(pos);
                }
                break;

            case PetState.Waiting:
                break;
            }

            if (petState != PetState.Vanilla)
            {
                GetPet().CurrentBehavior = PetBehaviour;
            }
        }
Exemplo n.º 4
0
 private static void GameLoop_UpdateTicked_LoadImage(object sender, StardewModdingAPI.Events.UpdateTickedEventArgs e)
 {
     //
     //  Get request image in UI thread
     //
     lock (lImagesToLoad)
     {
         foreach (string sImagePath in lImagesToLoad)
         {
             try
             {
                 Texture2D txImage = oHelper.Content.Load <Texture2D>(sImagePath, ContentSource.GameContent);
                 lock (dcImages)
                 {
                     dcImages.Add(sImagePath, new StardewBitmap(txImage));
                 }
             }
             catch
             {
                 dcImages.Add(sImagePath, null);
             }
         }
         //
         //  clear requesst list
         //
         lImagesToLoad.Clear();
         //
         //  unhook event
         //
         oHelper.Events.GameLoop.UpdateTicked -= GameLoop_UpdateTicked_LoadImage;
     }
 }
Exemplo n.º 5
0
 private void GameLoop_UpdateTicked(object sender, StardewModdingAPI.Events.UpdateTickedEventArgs e)
 {
     if (Context.IsWorldReady)
     {
         PlacedAugmentorsManager.Instance?.Update();
     }
 }
Exemplo n.º 6
0
        /*********
        ** Private methods
        *********/

        /// <summary>Raised after the game state is updated (≈60 times per second).</summary>
        /// <param name="sender">The event sender.</param>
        /// <param name="e">The event arguments.</param>
        private void GameLoop_UpdateTicked(object sender, StardewModdingAPI.Events.UpdateTickedEventArgs e)
        {
            if (Context.IsWorldReady && e.IsMultipleOf(10))
            {
                this.ToggleGates(Game1.currentLocation);
            }
        }
Exemplo n.º 7
0
 public void performTickUpdate(object sender, StardewModdingAPI.Events.UpdateTickedEventArgs e)
 {
     ParticleHandler.update(Game1.currentGameTime, Game1.currentLocation);
     Contact.PainTileHandler.tickUpdate();
     Contact.TileContactMorphHandler.update();
     ForegroundHandler.update();
 }
Exemplo n.º 8
0
        private static void GameLoop_Update_LoadTexture(object sender, StardewModdingAPI.Events.UpdateTickedEventArgs e)
        {
            lock (lSpriteSheetToLoad)
            {
                foreach (string sTextureId in lTexturesToLoad.Keys)
                {
                    lock (dcTexturesLoaded)
                    {
                        MemoryStream ms = new MemoryStream();
                        lTexturesToLoad[sTextureId].SaveAsPng(ms, lTexturesToLoad[sTextureId].Width, lTexturesToLoad[sTextureId].Height);
                        //Go To the  beginning of the stream.
                        ms.Seek(0, SeekOrigin.Begin);
                        //Create the image based on the stream.

                        dcTexturesLoaded.Add(sTextureId, ms);
                    }
                }
                //
                //  clear request list
                //
                lTexturesToLoad.Clear();
                //
                //  unhook event
                //
                oHelper.Events.GameLoop.UpdateTicked -= GameLoop_Update_LoadTexture;
            }
        }
 private void GameLoop_UpdateTicked(object sender, StardewModdingAPI.Events.UpdateTickedEventArgs e)
 {
     if (Game1.player.CurrentTool is FishingRod rod && (rod.isFishing || rod.isNibbling))
     {
         this.dist  = this.Helper.Reflection.GetField <int>(rod, "clearWaterDistance").GetValue();
         this.dist2 = Math.Round(Math.Sqrt(Math.Pow(Game1.player.Position.X - rod.bobber.X, 2) + Math.Pow(Game1.player.Position.Y - rod.bobber.Y, 2)), 1);
     }
Exemplo n.º 10
0
 private void GameLoop_UpdateTicked(object sender, StardewModdingAPI.Events.UpdateTickedEventArgs e)
 {
     if (frame > 0 && e.IsMultipleOf(rate))
     {
         frame = Math.Min(frame + (closing ? -1 : 1), max);
     }
 }
Exemplo n.º 11
0
        private void GameLoop_UpdateTicked(object sender, StardewModdingAPI.Events.UpdateTickedEventArgs e)
        {
            // ignore in cutscenes
            if (Game1.eventUp)
            {
                return;
            }

            // ignore if walking
            bool running    = Game1.player.running;
            bool runEnabled = running || Game1.options.autoRun != Game1.isOneOfTheseKeysDown(Game1.GetKeyboardState(), Game1.options.runButton); // auto-run enabled and not holding walk button, or disabled and holding run button

            if (!runEnabled)
            {
                return;
            }

            Buff buff = Game1.buffsDisplay.otherBuffs.FirstOrDefault(p => p.which == BuffId);

            if (buff == null)
            {
                Game1.buffsDisplay.addOtherBuff(
                    buff = new Buff(0, 0, 0, 0, 0, 0, 0, 0, 0, speed: Parameters.Amount, 0, 0, minutesDuration: 1, source: currentSourceItem?.Name ?? "", displaySource: currentSourceItem?.DisplayName ?? "")
                {
                    which = BuffId
                }
                    );
            }
            buff.millisecondsDuration = 50;
        }
Exemplo n.º 12
0
        private void GameLoop_UpdateTicked(object sender, StardewModdingAPI.Events.UpdateTickedEventArgs e)
        {
            if (!floorsList.Any() || Game1.player == null || Utility.getHomeOfFarmer(Game1.player) == null)
            {
                return;
            }

            var warps = Utility.getHomeOfFarmer(Game1.player).warps;

            if (warps.Where(w => w.TargetName == "MultipleFloors0").Any())
            {
                return;
            }
            Monitor.Log("Doesn't have warp");

            Vector2 stairs = floorsList[GetPossibleFloors()[0]].stairsStart;
            int     x      = (int)stairs.X;
            int     y      = (int)stairs.Y;

            Warp warp = new Warp(config.MainFloorStairsX + 1, config.MainFloorStairsY + 3, "MultipleFloors0", x + 1, y + 2, true, false);

            Utility.getHomeOfFarmer(Game1.player).warps.Add(warp);

            Warp warp2 = new Warp(config.MainFloorStairsX + 2, config.MainFloorStairsY + 3, "MultipleFloors0", x + 2, y + 2, true, false);

            Utility.getHomeOfFarmer(Game1.player).warps.Add(warp2);
        }
Exemplo n.º 13
0
        private void GameLoop_UpdateTicked(object sender, StardewModdingAPI.Events.UpdateTickedEventArgs e)
        {
            foreach (KeyValuePair <Object, Object> pair in SeedMakers)
            {
                Object seedMaker  = pair.Key;
                Object heldItem   = pair.Value;
                bool   wasHolding = heldItem != null;
                if (HasHeldItem(seedMaker) && (!wasHolding || heldItem != GetHeldItem(seedMaker)))
                {
                    if (HeldItemAdded != null)
                    {
                        HeldItemAdded.Invoke(null, new SeedMakerEventArgs(seedMaker, GetHeldItem(seedMaker)));
                    }
                }
                if (wasHolding && (!HasHeldItem(seedMaker) || GetHeldItem(seedMaker) != heldItem))
                {
                    if (HeldItemRemoved != null)
                    {
                        HeldItemRemoved.Invoke(null, new SeedMakerEventArgs(seedMaker, heldItem));
                    }
                }
            }

            foreach (Object seedMaker in new List <Object>(SeedMakers.Keys))
            {
                SeedMakers[seedMaker] = GetHeldItem(seedMaker);
            }
        }
Exemplo n.º 14
0
        static void GameLoop_UpdateTicked(object sender, StardewModdingAPI.Events.UpdateTickedEventArgs e)
        {
            if (!StardewModdingAPI.Context.CanPlayerMove)
            {
                return;
            }

            bool oldblocked = blocked;

            blocked = (Game1.currentLocation != null && Game1.player.isMoving() && Game1.player.Position.Equals(oldPlayerPos));

            SetFacingDir();

            if (blocked)
            {
                if (!oldblocked || Game1.player.getDirection() != FacingDir)//reset if wasn't blocked before or direction changed
                {
                    blockTimer = 0;
                }
                else
                {
                    blockTimer += 1;
                }

                if (blockTimer % 60 == 0)
                {
                    PlaySoundForBarrier(FindBarrierType());
                }
            }

            oldPlayerPos = Game1.player.Position;
        }
Exemplo n.º 15
0
        private void GameLoop_UpdateTicked(object sender, StardewModdingAPI.Events.UpdateTickedEventArgs e)
        {
            if (GameTick < 2)
            {
                GameTick++;
            }
            else if (GameTick == 2)
            {
                InitializeEditors();
                GameTick++;
            }

            if (Game1.currentLocation?.Name != Data.ExteriorMapName)
            {
                return;
            }
            if (Game1.isTimePaused)
            {
                return;
            }

            //This code was borrowed from East Scarpe

            // Very rarely show the Sea Monster.
            if (Game1.eventUp || !(Game1.random.NextDouble() < Data.DolphinChance))
            {
                return;
            }

            // Randomly find a starting position within the range.
            Vector2 position = 64f * new Vector2
                                   (Game1.random.Next(Data.DolphinRange.Left,
                                                      Data.DolphinRange.Right + 1),
                                   Game1.random.Next(Data.DolphinRange.Top,
                                                     Data.DolphinRange.Bottom + 1));

            var loc = Game1.currentLocation;

            bool foundPosition = true;

            // Confirm there is water tiles in the 3x2 area the dolphin spawns in
            Vector2[] tiles = new[] { new Vector2(0, 0), new Vector2(1, 0), new Vector2(2, 0),
                                      new Vector2(0, 1), new Vector2(1, 1), new Vector2(2, 1) };
            foreach (var tile in tiles)
            {
                if (loc.doesTileHaveProperty((int)((position.X / 64) + tile.X), (int)((position.Y / 64) + tile.Y), "Water", "Back") == null)
                {
                    foundPosition = false;
                    break;
                }
            }

            // Spawn if possible.
            if (foundPosition)
            {
                loc.temporarySprites.Add(new DolphinAnimatedSprite(position, Helper.Content.Load <Texture2D>("data\\dolphin.png")));
            }
        }
Exemplo n.º 16
0
 private void GameLoop_UpdateTicked(object sender, StardewModdingAPI.Events.UpdateTickedEventArgs e)
 {
     if (this.CurrentSong != null && this.CurrentSong.State == SoundState.Playing &&
         Game1.currentSong != null && !Game1.currentSong.Name.ToLower().Contains("ambient"))
     {
         Game1.currentSong.Stop(AudioStopOptions.Immediate);
         Game1.currentSong.Stop(AudioStopOptions.AsAuthored);
     }
 }
Exemplo n.º 17
0
 private void GameLoop_UpdateTicked(object sender, StardewModdingAPI.Events.UpdateTickedEventArgs e)
 {
     if (playerInfo.justPlacedACustomObject == true)
     {
         playerInfo.justPlacedACustomObject = false;
     }
     DarkerNight.SetDarkerColor();
     playerInfo.update();
 }
Exemplo n.º 18
0
 private void GameLoop_UpdateTicked(object sender, StardewModdingAPI.Events.UpdateTickedEventArgs e)
 {
     for (int i = sparklingTexts.Count - 1; i >= 0; i--)
     {
         if (sparklingTexts[i].Item1.update(Game1.currentGameTime))
         {
             sparklingTexts.RemoveAt(i);
         }
     }
 }
Exemplo n.º 19
0
        private void GameLoop_UpdateTicked(object sender, StardewModdingAPI.Events.UpdateTickedEventArgs e)
        {
#if ANDROID
#else
            if (!(Game1.activeClickableMenu is PlatoUIMenu))
            {
                Game1.options.desiredUIScale = lastUIZoom;
                PyTK.PyTKMod._helper.Events.GameLoop.UpdateTicked -= GameLoop_UpdateTicked;
            }
#endif
        }
Exemplo n.º 20
0
        private void ResetZoom(object sender, StardewModdingAPI.Events.UpdateTickedEventArgs e)
        {
            if (!(Game1.activeClickableMenu is UIMenu))
            {
#if ANDROID
#else
                Game1.options.desiredUIScale = LastUIZoom;
#endif
                Helper.ModHelper.Events.GameLoop.UpdateTicked -= ResetZoom;
            }
        }
Exemplo n.º 21
0
        private void GameLoop_UpdateTicked(object sender, StardewModdingAPI.Events.UpdateTickedEventArgs e)
        {
            if (!Context.IsPlayerFree)
            {
                return;
            }

            if (Game1.currentLocation is IAnimalLocation loc)
            {
                CheckPetAnimal(loc, Game1.player);
            }
        }
Exemplo n.º 22
0
 private void GameLoop_UpdateTicked(object sender, StardewModdingAPI.Events.UpdateTickedEventArgs e)
 {
     if (Game1.player.yJumpVelocity == 0f && lastYJumpVelocity < 0f)
     {
         Game1.player.canMove = true;
         Helper.Events.GameLoop.UpdateTicked -= GameLoop_UpdateTicked;
         return;
     }
     Game1.player.position.X += velX;
     Game1.player.position.Y += velY;
     lastYJumpVelocity        = Game1.player.yJumpVelocity;
 }
Exemplo n.º 23
0
 private void GameLoop_UpdateTicked(object sender, StardewModdingAPI.Events.UpdateTickedEventArgs e)
 {
     lightDataDict = SHelper.Content.Load <Dictionary <string, LightData> >(dictPath, ContentSource.GameContent) ?? new Dictionary <string, LightData>();
     lightTextureList.Clear();
     foreach (var kvp in lightDataDict)
     {
         if (kvp.Value.texturePath != null && kvp.Value.texturePath.Length > 0)
         {
             lightTextureList.Add(kvp.Value.texturePath);
             kvp.Value.textureIndex = 8 + lightTextureList.Count;
         }
     }
     SMonitor.Log($"Loaded {lightDataDict.Count} custom light sources");
     SHelper.Events.GameLoop.UpdateTicked -= GameLoop_UpdateTicked;
 }
Exemplo n.º 24
0
        private void GameLoop_UpdateTicked(object sender, StardewModdingAPI.Events.UpdateTickedEventArgs e)
        {
            if (Config.randomly_enable)
            {
                randomly_enable_time_left--;
                if (randomly_enable_time_left <= 0)
                {
                    randomly_enabled          = !randomly_enabled;
                    randomly_enable_time_left = RandomlyEnableTime();

                    string state_name = randomly_enabled ? "enabled" : "disabled";
                    Monitor.Log($"OwO-ifying now {state_name} for {StringTime(randomly_enable_time_left)}");
                }
            }
        }
Exemplo n.º 25
0
        private void OnGameUpdateTicked(object sender, StardewModdingAPI.Events.UpdateTickedEventArgs e)
        {
            if (!Context.IsWorldReady)
            {
                return;
            }

            if (this._taskRegistrationDirty)
            {
                this._taskRegistrationDirty = false;
                this.UpdateTaskRegistration();
            }

            if (Context.CanPlayerMove && this.State.complete && this.IsInQuestLogAndActive())
            {
                this.Complete();
            }
        }
Exemplo n.º 26
0
        private void GameLoop_UpdateTicked(object sender, StardewModdingAPI.Events.UpdateTickedEventArgs e)
        {
            if (e.Ticks > 1)
            {
                japi = Helper.ModRegistry.GetApi <JsonAssets.IApi>("spacechase0.JsonAssets");

                if (Helper.ModRegistry.IsLoaded("FlashShifter.MarlonSVE"))
                {
                    japi.LoadAssets(Path.Combine(Helper.DirectoryPath, "assets", "SVE"));
                }
                else
                {
                    japi.LoadAssets(Path.Combine(Helper.DirectoryPath, "assets", "NSVE"));
                }

                Helper.Events.GameLoop.UpdateTicked -= GameLoop_UpdateTicked;
            }
        }
Exemplo n.º 27
0
 private void GameLoop_UpdateTicked(object sender, StardewModdingAPI.Events.UpdateTickedEventArgs e)
 {
     if (!Config.EnableMod || !Context.IsWorldReady)
     {
         return;
     }
     if (Helper.Input.IsDown(Config.RedButton) || Helper.Input.IsSuppressed(Config.RedButton))
     {
         AdjustColor(1, 0, 0, Config.RedButton);
     }
     else if (Helper.Input.IsDown(Config.GreenButton) || Helper.Input.IsSuppressed(Config.GreenButton))
     {
         AdjustColor(0, 1, 0, Config.GreenButton);
     }
     else if (Helper.Input.IsDown(Config.BlueButton) || Helper.Input.IsSuppressed(Config.BlueButton))
     {
         AdjustColor(0, 0, 1, Config.BlueButton);
     }
 }
Exemplo n.º 28
0
        private void GameLoop_UpdateTicked(object sender, StardewModdingAPI.Events.UpdateTickedEventArgs e)
        {
            if (!Context.IsWorldReady)
            {
                return;
            }

            for (int index = 0; index < this._jumpingFish.Count; ++index)
            {
                JumpFish jumpingFish     = this._jumpingFish[index];
                var      elapsedGameTime = Game1.currentGameTime.ElapsedGameTime;
                double   totalSeconds    = elapsedGameTime.TotalSeconds;
                if (jumpingFish.Update((float)totalSeconds))
                {
                    this._jumpingFish.RemoveAt(index);
                    --index;
                }
            }
        }
Exemplo n.º 29
0
        private static void GameLoop_UpdateTicked(object sender, StardewModdingAPI.Events.UpdateTickedEventArgs e)
        {
            if (skippingTime)
            {
                return;
            }

            for (int i = 0; i < 30; i++)
            {
                try
                {
                    if (Game1.timeOfDay >= targetTime || cycles > 2000)
                    {
                        skippingTime = false;
                        Program.gamePtr.IsFixedTimeStep = true;
                        cycles = 0;
                        Callback?.Invoke();
                        Callback = null;
                        Helper.Events.GameLoop.UpdateTicked -= GameLoop_UpdateTicked;
                        return;
                    }
                    if (Game1.timeOfDay != lastTime)
                    {
                        lastTime = Game1.timeOfDay;
                        Game1.playSound("smallSelect");
                    }
                    skippingTime                    = true;
                    Game1.player.freezePause        = 100;
                    Game1.player.forceTimePass      = true;
                    Program.gamePtr.IsFixedTimeStep = false;
                    update.Invoke(Game1.game1, new[] { new AltGameTime(Game1.currentGameTime.TotalGameTime, Game1.currentGameTime.ElapsedGameTime) });
                    Program.gamePtr.IsFixedTimeStep = true;
                    skippingTime = false;
                }
                catch
                {
                    skippingTime = false;
                    Program.gamePtr.IsFixedTimeStep = true;
                }
            }
            cycles++;
        }
Exemplo n.º 30
0
        private void GameLoop_UpdateTicked(object sender, StardewModdingAPI.Events.UpdateTickedEventArgs e)
        {
            if (!Context.IsWorldReady)
            {
                return;
            }

            if (Game1.currentLocation?.Name != ModEntry.Data.ExteriorMapName)
            {
                return;
            }

            if (Game1.player.Position.Y > 32)
            {
                return;
            }

            Game1.player.position.Y += 32;
            TSApi.OpenTrainMenu();
        }