private void Player_Warped(object sender, WarpedEventArgs e)
 {
     if (e.OldLocation.getCharacterFromName(BubbleGuyStatics.BubbleGuyName) != null)
     {
         NPC oOld = e.OldLocation.getCharacterFromName(BubbleGuyStatics.BubbleGuyName);
         e.OldLocation.characters.Remove(oOld);
         if (e.NewLocation.getCharacterFromName(BubbleGuyStatics.BubbleGuyName) == null)
         {
             e.NewLocation.characters.Add(oOld);
         }
     }
 }
        // Runs on each mine location update
        public static void UpdateLocation(WarpedEventArgs e)
        {

            if (!(e.NewLocation is MineShaft mine))
                return;

            foreach (NPC npc in Game1.player.currentLocation.characters)
            {
                if (!(npc is Monster)) continue;
                Monster m = (Monster)npc;
                switch (CurrentAugment)
                {
                    case "health":
                        BoostHealth(m);
                        break;
                    case "harder":
                        Harden(m);
                        break;
                    case "exp":
                        BoostExp(m);
                        break;
                    case "crabs":
                        int cnt = Game1.random.Next(2) + 1;
                        for (int i = 0; i < cnt; i++) 
                            queue.Add(new RockCrab(Vector2.Zero));
                        break;
                    case "extra":
                        foreach (NPC n in Game1.currentLocation.characters)
                        {
                            if (!(n is Monster)) continue;
                            int flag = Game1.random.Next(1);
                            if (flag.Equals(1))
                            {
                                int type = Game1.random.Next(1);
                                switch (type)
                                {
                                    case 0:
                                        queue.Add(new GreenSlime(Vector2.Zero));
                                        break;
                                    case 1:
                                        queue.Add(new RockCrab(Vector2.Zero));
                                        break;
                                    default:
                                        break;
                                }
                            }
                        }
                        break;
                    default:
                        break;
                }
            }
        }
Example #3
0
        /// <summary>The method invoked after the player warps to a new location.</summary>
        /// <param name="sender">The event sender.</param>
        /// <param name="e">The event arguments.</param>
        private void OnWarped(object sender, WarpedEventArgs e)
        {
            if (!Context.IsWorldReady || Game1.eventUp || !this.Handlers.Any() || !e.IsLocalPlayer)
            {
                return;
            }

            foreach (IAnimationHandler handler in this.Handlers)
            {
                handler.OnNewLocation(e.NewLocation);
            }
        }
Example #4
0
 public bool shouldUpdateAugment(WarpedEventArgs e)
 {
     if (e.NewLocation is MineShaft mine)
     {
         if (lastAugment() && (mine.mineLevel % BNC_Core.config.Mine_Augment_Every_x_Levels == 0 || CurrentAugment == null || mine.mineLevel == 1))
         {
             startTime = DateTime.Now;
             return(true);
         }
     }
     return(false);
 }
        public override ActionResponse UpdateMonster(WarpedEventArgs e, Monster m)
        {
            GameLocation loc = Game1.player.currentLocation;
            int          cnt = Game1.random.Next(8) + 1;

            for (int i = 0; i < cnt; i++)
            {
                Spawner.addMonsterToSpawn(new RockCrab(Vector2.Zero), "");
            }

            return(ActionResponse.Done);
        }
 /// <summary>Raised after a player warps to a new location. NOTE: this event is currently only raised for the current player.</summary>
 /// <param name="sender">The event sender.</param>
 /// <param name="e">The event arguments.</param>
 private void OnWarped(object sender, WarpedEventArgs e)
 {
     if (e.NewLocation.Name == locationOfPostbox)
     {
         // Only watch for mouse events while at the location of the postbox, for performance
         _events.Input.ButtonPressed += OnButtonPressed;
     }
     else
     {
         _events.Input.ButtonPressed -= OnButtonPressed;
     }
 }
        /*********
        ** Private methods
        *********/
        /// <summary>The method called after the player enters a new location.</summary>
        /// <param name="sender">The event sender.</param>
        /// <param name="e">The event arguments.</param>
        private void WarpedEventArgs(object sender, WarpedEventArgs e)
        {
            if (!e.IsLocalPlayer)
            {
                return;
            }

            if (e.NewLocation is FarmHouse && Game1.player.isMarried() && Game1.player.spouse == "Wizard" && (Game1.player.HouseUpgradeLevel == 1 || Game1.player.HouseUpgradeLevel == 2))
            {
                this.LoadSpouseRoom();
            }
        }
Example #8
0
 /// <summary>Raised after a player warps to a new location.</summary>
 /// <param name="sender">The event sender.</param>
 /// <param name="e">The event arguments.</param>
 private void OnWarped(object sender, WarpedEventArgs e)
 {
     if (e.IsLocalPlayer)
     {
         // update the last list of terrain features
         if (Config.EnableGettingHayFromGrassAnytime)
         {
             this.lastTerrainFeatures = e.NewLocation?.terrainFeatures?.FieldDict.ToDictionary(item => item.Key, item => item.Value.Value);
             this.CurrentLocation     = e.NewLocation;
         }
     }
 }
        /// <inheritdoc/>
        public override void OnWarped(object sender, WarpedEventArgs e)
        {
            if (e.NewLocation is not MineShaft && e.NewLocation is not VolcanoDungeon)
            {
                return;
            }

            var count = Game1.getFarm().buildings.Where(b => (b.owner.Value == e.Player.UniqueMultiplayerID || !Game1.IsMultiplayer) && b.indoors.Value is SlimeHutch && !b.isUnderConstruction() && b.indoors.Value.characters.Any()).Sum(b => b.indoors.Value.characters.Count(npc => npc is GreenSlime)) + Game1.getFarm().characters.Count(npc => npc is GreenSlime);
            var r     = new Random(Guid.NewGuid().GetHashCode());

            while (count-- > 0)
            {
                var x             = r.Next(e.NewLocation.Map.GetLayer("Back").LayerWidth);
                var y             = r.Next(e.NewLocation.Map.GetLayer("Back").LayerHeight);
                var spawnPosition = new Vector2(x, y);

                GreenSlime slime;
                switch (e.NewLocation)
                {
                case MineShaft shaft when e.NewLocation is MineShaft:
                {
                    shaft.checkForMapAlterations(x, y);
                    if (!shaft.isTileClearForMineObjects(spawnPosition) || shaft.isTileOccupied(spawnPosition))
                    {
                        continue;
                    }

                    slime = new GreenSlime(Vector2.Zero, shaft.mineLevel);
                    if (shaft.GetAdditionalDifficulty() > 0 && r.NextDouble() < Math.Min(shaft.GetAdditionalDifficulty() * 0.1f, 0.5f))
                    {
                        slime.stackedSlimes.Value = r.NextDouble() < 0.0099999997764825821 ? 4 : 2;
                    }

                    slime.setTilePosition(x, y);
                    shaft.characters.Add(shaft.BuffMonsterIfNecessary(slime));
                    break;
                }

                case VolcanoDungeon dungeon when e.NewLocation is VolcanoDungeon:
                {
                    if (!e.NewLocation.isTileLocationTotallyClearAndPlaceable(spawnPosition))
                    {
                        continue;
                    }

                    slime = new GreenSlime(spawnPosition, 1);
                    slime.makeTigerSlime();
                    dungeon.characters.Add(slime);
                    break;
                }
                }
            }
        }
Example #10
0
        private void PlayerEvents_Warped(object sender, WarpedEventArgs e)
        {
            isMovingAutomaticaly = false;

            if (e.OldLocation is StardewValley.Locations.Town && e.NewLocation is StardewValley.Locations.Mountain)
            {
                Game1.player.Position += new Vector2(0f, -10f);
            }
            if (e.OldLocation is StardewValley.Farm && e.NewLocation.Name == "Backwoods")
            {
                Game1.player.Position += new Vector2(0f, -10f);
            }
        }
Example #11
0
 private void OnWarped(object sender, WarpedEventArgs e)
 {
     if (e.OldLocation.NameOrUniqueName == "Greenhouse")
     {
         for (int i = e.OldLocation.characters.Count - 1; i >= 0; i--)
         {
             if (e.OldLocation.characters[i] is Junimo)
             {
                 e.OldLocation.characters.RemoveAt(i);
             }
         }
     }
 }
Example #12
0
 /// <summary>
 /// Check a parts of introduction event/quest when player warped.
 /// When player reach 10 floor of mines, then we got letter tomorrow
 /// When player got letter and go to Adventurer's guild, play Marlon event
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void Player_Warped(object sender, WarpedEventArgs e)
 {
     if (e.NewLocation.Name.Equals("AdventureGuild") && e.Player.mailReceived.Contains(LETTER_KEY) && !this.GameMaster.Data.GetPlayerState(e.Player).isEligible)
     {
         if (this.contentLoader.LoadStrings("Data/Events").TryGetValue("adventureBegins", out string eventData))
         {
             e.NewLocation.startEvent(new Event(eventData));
             this.GameMaster.Data.GetPlayerState().isEligible = true;
             this.GameMaster.SyncData();
             this.monitor.Log($"Player {e.Player.Name} is now eligible to recruit companions!", LogLevel.Info);
         }
     }
 }
Example #13
0
 private void Warped(object sender, WarpedEventArgs e)
 {
     if (!Context.IsMainPlayer && e.NewLocation.Name.Equals("Greenhouse") && e.OldLocation.Name.Equals("Farm"))
     {
         foreach (Building building in Game1.getFarm().buildings)
         {
             if (building.buildingType.Value.Equals("Greenhouse") && building.owner.Value == Game1.player.UniqueMultiplayerID)
             {
                 Game1.warpFarmer(building.nameOfIndoors, 10, 23, false);
             }
         }
     }
 }
        private void OnPlayerWarped(object sender, WarpedEventArgs e)
        {
            if (e.NewLocation.Name.Equals("Town"))
            {
                Game1.changeMusicTrack("WizardSong");

                if (Game1.player.IsMainPlayer)
                {
                    // Unhook itself
                    helper.Events.Player.Warped -= OnPlayerWarped;
                }
            }
        }
Example #15
0
 /// <summary>
 /// Raised after the player enters a new location.
 ///
 /// Use with caution, locks on this
 /// </summary>
 /// <param name="sender">The event sender.</param>
 /// <param name="e">The event data.</param>
 private void OnWarped(object sender, WarpedEventArgs e)
 {
     // if we enqueued a screen shot and warped before
     // the timeout, reset the timeout
     lock (this)
     {
         if (m_ssActions.Count > 0)
         {
             m_ssCntDwnTicks = MAX_COUNTDOWN_IN_TICKS;
         }
     }
     RunTriggers(WarpRules);
 }
Example #16
0
 private void CheckBirthdays(object sender, WarpedEventArgs e)
 {
     Log("Checking for birthdays: ");
     foreach (var npc in e.NewLocation.getCharacters())
     {
         Log($"Checking {npc.displayName} for a birthday today");
         if (npc.isBirthday(Game1.Date.Season, Game1.Date.DayOfMonth))
         {
             var message = Helper.Translation.Get("news-feed.birthday-notice", new { npcName = npc.getName() });
             Game1.addHUDMessage(new HUDMessage(message, 2));
         }
     }
 }
Example #17
0
        private void Player_Warped(object sender, WarpedEventArgs e)
        {
            if (!e.IsLocalPlayer)
            {
                return;
            }

            // Hide minimap in blacklisted locations with special case for Mines as usual
            shouldShowMinimap = !IsLocationBlacklisted(e.NewLocation.Name);

            // Check if map does not fill screen and adjust for black bars (ex. BusStop)
            Minimap?.CheckOffsetForMap();
        }
Example #18
0
 /*********
 ** Private methods
 *********/
 /// <summary>Raised after a player warps to a new location.</summary>
 /// <param name="sender">The event sender.</param>
 /// <param name="e">The event data.</param>
 private void OnWarped(object sender, WarpedEventArgs e)
 {
     // move player if they warp into the ocean (e.g. from Marnie's ranch)
     // note: getTileLocation() seems to be unreliable when mounted.
     if (e.IsLocalPlayer && this.IsSmallBeachFarm(e.NewLocation, out Farm farm))
     {
         Vector2 tile = e.Player.Position / Game1.tileSize;
         if (this.IsInvalidPosition(farm, (int)tile.X, (int)tile.Y))
         {
             Game1.player.Position = this.MarnieWarpArrivalPixelPos;
         }
     }
 }
Example #19
0
 private void OnWarped(object sender, WarpedEventArgs e)
 {
     if (e.IsLocalPlayer && this.Helper.ModRegistry.IsLoaded("cantorsdust.AllProfessions"))
     {
         if (e.Player.professions.Contains(Mod.ProfessionTime) && !e.Player.professions.Contains(Mod.ProfessionProfit))
         {
             e.Player.professions.Add(Mod.ProfessionProfit);
         }
         if (!e.Player.professions.Contains(Mod.ProfessionTime) && e.Player.professions.Contains(Mod.ProfessionProfit))
         {
             e.Player.professions.Add(Mod.ProfessionTime);
         }
     }
 }
Example #20
0
        private void Player_Warped(object sender, WarpedEventArgs e)
        {
            GameLocation location = e.NewLocation;

            hasPanningSpot               = false;
            playerPannedSpot             = false;
            updatedNumberOfTimesGathered = false;

            if (!modCreatedPanningSpot.ContainsKey(location))
            {
                modCreatedPanningSpot.Add(location, false);
            }

            if (Game1.MasterPlayer.mailReceived.Contains("ccFishTank")) //Original code excludes beach... not this code!
            {
                if (numberOfPanningSpotsGathered <= config.maxNumberOfOrePointsGathered)
                {
                    UpdatePossibleTiles(location);

                    Point orePoint = location.orePanPoint.Value;
                    if (!orePoint.Equals(Point.Zero) && !modCreatedPanningSpot[location])
                    {
                        if ((config.sp_alwaysCreatePanningSpots && Game1.getOnlineFarmers().Count == 1) ||
                            (config.mp_alwaysCreatePanningSpots && Context.IsMultiplayer && Game1.getOnlineFarmers().Count > 1))
                        {
                            if (Game1.random.NextDouble() <= config.chanceOfCreatingPanningSpot)
                            {
                                CreatePanningSpot(location);
                            }
                        }
                        else
                        {
                            hasPanningSpot   = true;
                            playerPannedSpot = false;
                        }
                    }
                    else if (orePoint.Equals(Point.Zero))
                    {
                        if (Game1.random.NextDouble() <= config.chanceOfCreatingPanningSpot)
                        {
                            CreatePanningSpot(location);
                        }
                    }
                }
                else
                {
                    this.Monitor.Log($"Ores Gathered {numberOfPanningSpotsGathered} : max {config.maxNumberOfOrePointsGathered}");
                }
            }
        }
Example #21
0
 private void PlayerEvents_Warped(object sender, WarpedEventArgs e)
 {
     isMovingAutomaticaly = false;
     // There are location that player's new position (after warp) is too close to new warp
     // This prevent warp back to back
     if (e.OldLocation is StardewValley.Locations.Town && e.NewLocation is StardewValley.Locations.Mountain)
     {
         Game1.player.Position += new Vector2(0f, -10f);
     }
     if (e.OldLocation is StardewValley.Farm && e.NewLocation.Name == "Backwoods")
     {
         Game1.player.Position += new Vector2(0f, -10f);
     }
 }
Example #22
0
        /// <summary>Raised after a player warps to a new location.</summary>
        /// <param name="sender">The event sender.</param>
        /// <param name="e">The event arguments.</param>
        private void OnWarped(object sender, WarpedEventArgs e)
        {
            if (e.IsLocalPlayer)
            {
                _timer.Stop();
                StopDrawingPetNeeds();

                if (e.NewLocation is AnimalHouse || e.NewLocation is Farm)
                {
                    _timer.Interval = 1000;
                    _timer.Start();
                }
            }
        }
Example #23
0
 private void OnWarped(object sender, WarpedEventArgs e)
 {
     if (e.IsLocalPlayer && Helper.ModRegistry.IsLoaded("cantorsdust.AllProfessions"))
     {
         if (e.Player.professions.Contains(PROFESSION_TIME) && !e.Player.professions.Contains(PROFESSION_PROFIT))
         {
             e.Player.professions.Add(PROFESSION_PROFIT);
         }
         if (!e.Player.professions.Contains(PROFESSION_TIME) && e.Player.professions.Contains(PROFESSION_PROFIT))
         {
             e.Player.professions.Add(PROFESSION_TIME);
         }
     }
 }
Example #24
0
        /// <inheritdoc/>
        public override void OnWarped(object sender, WarpedEventArgs e)
        {
            if (!e.IsLocalPlayer || e.NewLocation is not MineShaft shaft)
            {
                return;
            }

            var currentMineLevel = (uint)(shaft).mineLevel;

            if (currentMineLevel > AwesomeProfessions.Data.ReadField($"{AwesomeProfessions.UniqueID}/LowestMineLevelReached", uint.Parse))
            {
                AwesomeProfessions.Data.WriteField($"{AwesomeProfessions.UniqueID}/LowestMineLevelReached", currentMineLevel.ToString());
            }
        }
 private void OnWarped(object sender, WarpedEventArgs e)
 {
     if (e.IsLocalPlayer)
     {
         if (e.NewLocation is AnimalHouse || e.NewLocation is Farm)
         {
             StartDrawingPetNeeds();
         }
         else
         {
             StopDrawingPetNeeds();
         }
     }
 }
 private void Player_Warped(object sender, WarpedEventArgs e)
 {
     if (e.IsLocalPlayer)
     {
         if (e.NewLocation.Name == "GreendaleTest")
         {
             MusicManager.Play("daybreak");
         }
         else
         {
             MusicManager.Stop();
         }
     }
 }
Example #27
0
        private void Player_Warped(object sender, WarpedEventArgs e)
        {
            if (!Context.IsWorldReady)
            {
                return;
            }

            QuestApi.CheckForQuestComplete <AdventureQuest>(
                new PlayerMovedMessage(
                    location: e.NewLocation,
                    position: e.Player.Position,
                    tilePosition: e.Player.getTileLocationPoint(),
                    trigger: "PlayerWarped"));
        }
Example #28
0
        private void Player_Warped(object sender, WarpedEventArgs e)
        {
            if (e.NewLocation.Map.Properties.ContainsKey("@WaterColor") && TMXColor.FromString(e.NewLocation.Map.Properties["@WaterColor"]) is TMXColor color)
            {
                e.NewLocation.waterColor.Value = new Color(color.R, color.G, color.B, color.A);
            }

            if (!e.IsLocalPlayer)
            {
                return;
            }

            e.NewLocation?.Map.enableMoreMapLayers();

            if (e.NewLocation is GameLocation g && g.map is Map m)
            {
                int forceX = Game1.player.getTileX();
                int forceY = Game1.player.getTileY();
                int forceF = Game1.player.FacingDirection;
                if (e.OldLocation is GameLocation og && m.Properties.ContainsKey("ForceEntry_" + og.Name))
                {
                    string[] pos = m.Properties["ForceEntry_" + og.Name].ToString().Split(' ');
                    if (pos.Length > 0 && pos[1] != "X")
                    {
                        int.TryParse(pos[0], out forceX);
                    }

                    if (pos.Length > 1 && pos[1] != "Y")
                    {
                        int.TryParse(pos[1], out forceY);
                    }

                    if (pos.Length > 2 && pos[2] != "F")
                    {
                        int.TryParse(pos[2], out forceF);
                    }

                    Game1.player.Position        = new Vector2(forceX, forceY);
                    Game1.player.FacingDirection = forceF;
                }

                if (m.Properties.ContainsKey("EntryAction"))
                {
                    TileAction.invokeCustomTileActions("EntryAction", g, Vector2.Zero, "Map");
                }

                PyUtils.checkDrawConditions(m);
            }
        }
Example #29
0
 private void PlayerWarped(object sender, WarpedEventArgs e)
 {
     if (e.NewLocation is VolcanoDungeon dungeon)
     {
         var level = dungeon.level;
         var num_farmers_currently_in_dungeon = dungeon.farmers.Count;
         var entering_player_has_musk_buff    = e.Player.hasBuff(ModEntry.MonsterMuskBuffInteger);
         // Only add monsters if musk is active, there is no other player in the level and level's monsters haven't been cloned yet today
         if (entering_player_has_musk_buff && !ModEntry.MuskedVolcanoDungeonsToday.Contains(level) && num_farmers_currently_in_dungeon <= 1)
         {
             ModEntry.MuskedVolcanoDungeonsToday.Add(level);
             this.DoubleMonstersInVolcanoDungeon(dungeon);
         }
     }
 }
Example #30
0
        private void SetExtraLayersOnWarp(object sender, WarpedEventArgs e)
        {
            DrawBeforeCache.Clear();
            DrawAfterCache.Clear();
            ScrollModifier.Clear();

            e.NewLocation?.Map.Layers
            .ToList()
            .ForEach((l) =>
            {
                ScrollModifier.Add(l, Vector2.Zero);
                AttachLayerDrawHandlers(l);
            });

            LastViewport = Game1.viewportCenter;
        }