Ejemplo n.º 1
0
 internal void fixFarmWarp(StardewModdingAPI.Events.WarpedEventArgs e)
 {
     if (!(e.NewLocation is Farm))
     {
         return;
     }
 }
Ejemplo n.º 2
0
        internal void fixPlayerHouseWarp(StardewModdingAPI.Events.WarpedEventArgs e)
        {
            Farmer    farmer = e.Player;
            FarmHouse house  = (e.NewLocation as FarmHouse);

            //if(e.OldLocation is Farm)
            //{
            //    if (farmer.getTileLocationPoint() == house.getEntryLocation() || new Point(farmer.getTileLocationPoint().X, farmer.getTileLocationPoint().Y - 1) == house.getEntryLocation())
            //    {
            //        Logger.Log("Player warped to the farmhouse, and was in the entry location.  Setting player to modded entry (if any)...");
            //        Point entryPoint = FarmHouseStates.getEntryLocation(house);
            //        farmer.setTileLocation(new Vector2(entryPoint.X, entryPoint.Y));
            //    }
            //}
            if (e.OldLocation is Cellar)
            {
                if (farmer.getTileLocationPoint() == new Point(4, 25) || farmer.getTileLocationPoint() == new Point(5, 24))
                {
                    Logger.Log("Player warped to the farmhouse from the cellar, and was in the cellar return location.  Setting player to modded cellar return (if any)...");
                    Point cellarPoint = FarmHouseStates.getCellarLocation(house);
                    if (cellarPoint != new Point(-1, -1))
                    {
                        //farmer.setTileLocation(new Vector2(cellarPoint.X, cellarPoint.Y));
                        farmer.position.Value = new Vector2(cellarPoint.X * 64f, cellarPoint.Y * 64f);
                        Logger.Log("Set player to " + cellarPoint.X + ", " + cellarPoint.Y);
                    }
                }
                else
                {
                    Logger.Log("Player warped to the farmhouse from the cellar, but was not in the cellar return location.  Player was at " + farmer.getTileLocationPoint().X + ", " + farmer.getTileLocationPoint().Y);
                }
            }
            if (farmer.getTileLocationPoint() == house.getEntryLocation())
            {
                Logger.Log("Player warped to the farmhouse, and was in the entry location.  Setting player to modded entry (if any)...");
                Point entryPoint = FarmHouseStates.getEntryLocation(house);
                farmer.position.Value = new Vector2(entryPoint.X * 64f, entryPoint.Y * 64f);
                //farmer.setTileLocation(new Vector2());
            }
            else
            {
                Logger.Log("Player warped to the farmhouse, but was not at the entry location!  Player is at " + farmer.getTileLocationPoint().ToString() + " as a point, and " + farmer.getTileLocation().ToString() + " as a Vector2" + ", not the entry location " + house.getEntryLocation().ToString());
                Logger.Log("Player warped from " + e.OldLocation.name + ".");
                Logger.Log("House upgrade level is " + house.upgradeLevel + ".");
                if (FarmHouseStates.getState(house).entryData != null)
                {
                    Logger.Log("House entry data is " + FarmHouseStates.getState(house).entryData);
                }
                else
                {
                    Logger.Log("House entry data not initialized!");
                }
                Logger.Log("Player physical centerpoint is (" + farmer.GetBoundingBox().Center.X + ", " + farmer.GetBoundingBox().Bottom + "), with a bounding box of " + farmer.GetBoundingBox().ToString());
            }

            if (house is Cabin)
            {
                fixWarps(house as Cabin);
            }
        }
Ejemplo n.º 3
0
 private static void Warped_UpdateWaterColor(object sender, StardewModdingAPI.Events.WarpedEventArgs e)
 {
     if (e.NewLocation != null)
     {
         UpdateWaterColor(e.NewLocation); //update for the warping player's new location
     }
 }
Ejemplo n.º 4
0
 private void Player_Warped(object sender, StardewModdingAPI.Events.WarpedEventArgs e)
 {
     if (e?.NewLocation is MermaidHouse)
     {
         Helper.Content.InvalidateCache("Maps/mermaid_house_tiles");
     }
 }
Ejemplo n.º 5
0
 private void Player_Warped(object sender, StardewModdingAPI.Events.WarpedEventArgs e)
 {
     if (Game1.currentLocation != null)
     {
         _validFishLocations.Clear();
         PopulateValidFishLocations();
     }
 }
Ejemplo n.º 6
0
 private void Player_Warped(object sender, StardewModdingAPI.Events.WarpedEventArgs e)
 {
     Debug.WriteLine($"New Location with {e.NewLocation.characters.Count(c => c.IsMonster)} monsters");
     foreach (var monster in e.NewLocation.characters.Where(c => c.IsMonster).Cast <Monster>())
     {
         this.AffectiveFluids.GetEffectApi().ApplyEffect <Burning>(monster);
     }
 }
        /// <summary>Updates the exclamation point list whenever the local player warps to a new location.</summary>
        private static void Warped_UpdateTileList(object sender, StardewModdingAPI.Events.WarpedEventArgs e)
        {
            if (!e.IsLocalPlayer) //if the warping player is NOT the current local player
            {
                return;
            }

            UpdateTileList(e.NewLocation); //update for the current player's new location
        }
        private static void Player_Warped(object sender, StardewModdingAPI.Events.WarpedEventArgs e)
        {
            if (!e.IsLocalPlayer) //if the player who warped is NOT the current local player
            {
                return;
            }

            DisableShadowsHere(e.NewLocation); //disable shadow attacks at the new location if necessary
        }
Ejemplo n.º 9
0
        private void Player_Warped(object sender, StardewModdingAPI.Events.WarpedEventArgs e)
        {
            if (!config.EnableMod)
            {
                return;
            }

            WarpDict = new Dictionary <string, string>(config.WarpDict);

            Monitor.Log($"{WarpDict.Count} warp entries in mod");

            foreach (var kvp in Helper.Content.Load <Dictionary <string, string> >(config.AdditionalWarpDictFilePath, ContentSource.GameContent) ?? new Dictionary <string, string>())
            {
                try
                {
                    WarpDict.Add(kvp.Key, kvp.Value);
                }
                catch
                {
                    Monitor.Log($"External warp entry {kvp.Key}: {kvp.Value} syntax error", LogLevel.Error);
                }
            }
            Monitor.Log($"{WarpDict.Count} total warp entries");

            Vector2 oldDest       = e.Player.getTileLocation();
            string  newDestString = null;

            if (WarpDict.ContainsKey($"{e.OldLocation.name},{e.NewLocation.name},{oldDest.X},{oldDest.Y}"))
            {
                newDestString = WarpDict[$"{e.OldLocation.name},{e.NewLocation.name},{oldDest.X},{oldDest.Y}"];
            }
            else if (WarpDict.ContainsKey($"{e.NewLocation.name},{oldDest.X},{oldDest.Y}"))
            {
                newDestString = WarpDict[$"{e.NewLocation.name},{oldDest.X},{oldDest.Y}"];
            }
            else if (WarpDict.ContainsKey(e.OldLocation.name + "," + e.NewLocation.name))
            {
                newDestString = WarpDict[e.OldLocation.name + "," + e.NewLocation.name];
            }
            if (newDestString == null)
            {
                return;
            }
            try
            {
                var     parts   = newDestString.Split(',');
                Vector2 newDest = new Vector2(int.Parse(parts[0]), int.Parse(parts[1]));
                Monitor.Log($"Moving warp destination for {e.Player.name} from {oldDest} to {newDest} on warp from {e.OldLocation.name} to {e.NewLocation.name}");

                e.Player.position.Value = newDest * 64;
            }
            catch (Exception ex)
            {
                Monitor.Log($"Error setting destination:\n\n{ex}");
            }
        }
Ejemplo n.º 10
0
 internal void fixPlayerWarps(object sender, StardewModdingAPI.Events.WarpedEventArgs e)
 {
     if (e.NewLocation is FarmHouse)
     {
         fixPlayerHouseWarp(e);
     }
     else if (e.NewLocation is Farm)
     {
         fixFarmWarp(e);
     }
 }
Ejemplo n.º 11
0
 private void Player_Warped(object sender, StardewModdingAPI.Events.WarpedEventArgs e)
 {
     if (justWarped)
     {
         return;
     }
     SerializationManager.cleanUpInventory();
     //SerializationManager.cleanUpWorld();
     //SerializationManager.cleanUpStorageContainers();
     justWarped = true;
 }
Ejemplo n.º 12
0
 public void performLocationSetup(object sender, StardewModdingAPI.Events.WarpedEventArgs e)
 {
     Contact.TileContactMorphHandler.cleanup();
     BackgroundHandler.updateBackground(e.NewLocation);
     ForegroundHandler.updateForeground();
     ParticleHandler.updateParticleSystems(e.NewLocation);
     Time.TimeHandler.applyAllLayersToNow(e.NewLocation);
     Critters.CritterTileHandler.spawnCitters(e.NewLocation);
     //TreeHandler.createAllTrees(e.NewLocation);
     //Perspective.PerspectiveRenderer.makeMinimap(e.NewLocation);
 }
Ejemplo n.º 13
0
        private void OnLocationChanged(object sender, StardewModdingAPI.Events.WarpedEventArgs e)
        {
            if (!e.IsLocalPlayer)
            {
                return;
            }

            this.newLocation = e.NewLocation.Name;
            this.oldLocation = e.OldLocation.Name;

            this.Observe(new CompletionArgs(str: this.newLocation));
        }
Ejemplo n.º 14
0
        private void Player_Warped(object sender, StardewModdingAPI.Events.WarpedEventArgs e)
        {
            if (Game1.currentLocation.Name == "JojaMart")
            {
                Game1.currentLocation.setTileProperty((int)Main.Config.JojaMartUpgradeCoordinates.X,
                                                      (int)Main.Config.JojaMartUpgradeCoordinates.Y, "Buildings", "Action", "");
            }

            if (Game1.currentLocation.Name == "CommunityCenter")
            {
                Game1.currentLocation.setTileProperty((int)Main.Config.CommunityCenterUpgradeCoordinates.X,
                                                      (int)Main.Config.CommunityCenterUpgradeCoordinates.Y, "Buildings", "Action", "");
            }
        }
Ejemplo n.º 15
0
        private void Player_Warped(object sender, StardewModdingAPI.Events.WarpedEventArgs e)
        {
            if (e?.NewLocation is SlimeHutch hutch)
            {
                if (config.HutchInterior == 1)
                {
                    int slimes    = 0;
                    int mushrooms = 0;
                    int magmaCaps = 0;

                    foreach (var monster in hutch.characters)
                    {
                        if (monster is GreenSlime)
                        {
                            slimes++;
                        }
                        else if (monster is DustSpirit)
                        {
                            mushrooms++;
                        }
                        else if (monster is RockCrab crab && monster.Name.Equals("False Magma Cap"))
                        {
                            magmaCaps++;
                        }
                    }

                    if (slimes >= mushrooms && slimes >= magmaCaps)
                    {
                        currentHutchType = HutchType.slimy;
                    }
                    else if (magmaCaps > slimes && magmaCaps >= mushrooms)
                    {
                        currentHutchType = HutchType.volcano;
                    }
                    else if (mushrooms > slimes && mushrooms > magmaCaps)
                    {
                        currentHutchType = HutchType.mine;
                    }

                    if (mushrooms + slimes + magmaCaps == 0)
                    {
                        currentHutchType = HutchType.normal;
                    }
                }

                Helper.Content.InvalidateCache("Maps/SlimeHutch");
                Helper.Content.InvalidateCache("Maps/townInterior");
            }
        }
Ejemplo n.º 16
0
        private void Player_Warped(object sender, StardewModdingAPI.Events.WarpedEventArgs e)
        {
            if (e.NewLocation.Name != "Railroad")
            {
                return;
            }

            string property = e.NewLocation.doesTileHaveProperty(Config.TicketStationX, Config.TicketStationY,
                                                                 "Action", "Buildings");

            if (property != "TrainStation")
            {
                DrawInTicketStation();
            }
        }
Ejemplo n.º 17
0
        static void Player_Warped(object sender, StardewModdingAPI.Events.WarpedEventArgs e)
        {
            if (!e.OldLocation.IsOutdoors && e.NewLocation.IsOutdoors || e.OldLocation is FarmHouse && e.NewLocation.isFarm)
            {
                Game1.playSound("doorOpen"); //"doorClose" "doorCreakReverse"
            }
            else// if (e.OldLocation.IsOutdoors && e.NewLocation.IsOutdoors)
            {
                Game1.playSound("dwop");
            }

            if (e.NewLocation.Name.Length > 0)
            {
                TextToSpeech.Speak("entering " + e.NewLocation.Name);
            }
        }
Ejemplo n.º 18
0
 private void Player_Warped(object sender, StardewModdingAPI.Events.WarpedEventArgs e)
 {
     CheckForAchievements();
 }
Ejemplo n.º 19
0
 private void Player_Warped(object sender, StardewModdingAPI.Events.WarpedEventArgs e)
 {
     speakingAnimals = null;
 }
Ejemplo n.º 20
0
        private void Player_Warped(object sender, StardewModdingAPI.Events.WarpedEventArgs e)
        {
            _RemoveGoblinNose();
            _gettingKickedOut = false;

            // If we registered the weird light update, just remove it if we warp.
            if (e.IsLocalPlayer && _registeredUpdate)
            {
                Helper.Events.GameLoop.UpdateTicking -= UpdateWeirdLights;
                setGoblinNosePosition = null;
                _registeredUpdate     = false;
            }

            if (e.IsLocalPlayer &&
                e.NewLocation != null &&
                e.NewLocation.Name.Equals("Sewer") &&
                IsShadowFestivalToday()
                )
            {
                setGoblinNosePosition += SetGoblinNosePosition;
                // Setup the Sewer Map for us
                if (e.Player.mailReceived.Contains("ShadowFestivalVisited"))
                {
                    e.Player.mailReceived.Add("ShadowFestivalVisited");
                }
                Helper.Reflection.GetField <Color>(e.NewLocation, "steamColor").SetValue(new Color(240, 180, 240));
                // Repatch the two tiles that Sewers.resetLocalState() changes on us.
                // Beware if that part of our map is edited, we need to manually change these here too.
                e.NewLocation.setMapTileIndex(31, 16, 77, "Front", 1);
                e.NewLocation.setMapTileIndex(31, 17, 85, "Buildings", 1);
                e.NewLocation.setTileProperty(31, 17, "Buildings", "Action", "FestivalDialogue BigShadow");
                // Check for Krobus and make him scarce
                if (e.NewLocation.characters != null)
                {
                    foreach (NPC npc in e.NewLocation.characters)
                    {
                        if (npc.Name == "Krobus")
                        {
                            npc.setTilePosition(3, 20);
                            break;
                        }
                    }
                }
                // Let's add critters. Start with a frog along the entry hall
                List <Critter> critters = Helper.Reflection.GetField <List <Critter> >(e.NewLocation, "critters").GetValue();
                if (critters == null)
                {
                    Helper.Reflection.GetField <List <Critter> >(e.NewLocation, "critters").SetValue(new List <Critter>());
                }
                e.NewLocation.addCritter(new Frog(new Vector2(4, ModEntry.Random.Next(26, 31)), true, false));
                e.NewLocation.addCritter(new Frog(new Vector2(15, 26), true, true));
                e.NewLocation.addCritter(new Frog(new Vector2(18, 27), true, false));

                // Add a bunch of fireflies.
                for (int i = 0; i < 60; i++)
                {
                    Firefly firefly = new Firefly(new Vector2(ModEntry.Random.Next(3, 34), ModEntry.Random.Next(10, 44)));

                    // These fireflies have weird colors.

                    var light_source = Helper.Reflection.GetField <LightSource>(firefly, "light");

                    int color = ModEntry.Random.Next(0, 3);

                    if (color == 0)
                    {
                        light_source.GetValue().color.Value = new Color(0, 0, 255);
                    }
                    else if (color == 1)
                    {
                        light_source.GetValue().color.Value = new Color(0, 255, 0);
                    }
                    else if (color == 2)
                    {
                        light_source.GetValue().color.Value = new Color(255, 0, 0);
                    }

                    light_source.GetValue().radius.Value = 0.75F;

                    e.NewLocation.addCritter(firefly);
                }

                _weirdLights.Clear();

                // Set up the lights in the scene.

                for (int x = 0; x < e.NewLocation.Map.Layers[0].LayerWidth; x++)
                {
                    for (int y = 0; y < e.NewLocation.Map.Layers[0].LayerHeight; y++)
                    {
                        xTile.Tiles.Tile tile   = e.NewLocation.Map.GetLayer("Front").Tiles[x, y];
                        xTile.Tiles.Tile tile_2 = e.NewLocation.Map.GetLayer("AlwaysFront").Tiles[x, y];

                        // Weird lamp things.

                        if ((tile != null && tile.TileIndex == 122 && tile.TileSheet.Id == "Spirit_Sewer") ||
                            (tile_2 != null && tile_2.TileIndex == 122 && tile_2.TileSheet.Id == "Spirit_Sewer"))
                        {
                            AddWeirdLight(e.NewLocation, x, y);
                        }

                        // Weird hanging lights (Left)

                        if ((tile != null && tile.TileIndex == 65 && tile.TileSheet.Id == "Spirit_Sewer") ||
                            (tile_2 != null && tile_2.TileIndex == 65 && tile_2.TileSheet.Id == "Spirit_Sewer"))
                        {
                            Game1.currentLightSources.Add(new LightSource(1, new Vector2((x + 0.5F) * Game1.tileSize, (y + 0.5F) * Game1.tileSize), 0.25F, new Color(255, 255, 255)));
                        }

                        // Middle

                        if ((tile != null && tile.TileIndex == 66 && tile.TileSheet.Id == "Spirit_Sewer") ||
                            (tile_2 != null && tile_2.TileIndex == 66 && tile_2.TileSheet.Id == "Spirit_Sewer"))
                        {
                            Game1.currentLightSources.Add(new LightSource(6, new Vector2((x + 0.5F) * Game1.tileSize, (y + 0.75F) * Game1.tileSize), 0.5F, new Color(255, 10, 255)));
                        }

                        // Right

                        if ((tile != null && tile.TileIndex == 67 && tile.TileSheet.Id == "Spirit_Sewer") ||
                            (tile_2 != null && tile_2.TileIndex == 67 && tile_2.TileSheet.Id == "Spirit_Sewer"))
                        {
                            Game1.currentLightSources.Add(new LightSource(1, new Vector2((x + 0.5F) * Game1.tileSize, (y + 0.5F) * Game1.tileSize), 0.25F, new Color(255, 10, 10)));
                        }
                    }
                }

                Game1.changeMusicTrack("WizardSong");

                // The Sewers class overrides the lighting, so override it again.
                Game1.ambientLight = new Color(190, 190, 150);

                // Register the weird light update. This causes those weird lights to kind of pulse.
                Helper.Events.GameLoop.UpdateTicking += UpdateWeirdLights;
                _registeredUpdate = true;
            }
        }
Ejemplo n.º 21
0
 private void Player_Warped(object sender, StardewModdingAPI.Events.WarpedEventArgs e)
 {
     ReloadOreData();
 }
Ejemplo n.º 22
0
 private void OnWarped(object sender, StardewModdingAPI.Events.WarpedEventArgs e)
 {
     session.GetLocationProfileSafe(e.NewLocation).ApplyAllTiles();
 }
Ejemplo n.º 23
0
 private void Player_Warped(object sender, StardewModdingAPI.Events.WarpedEventArgs e)
 {
     lastPlayerLevel = 1;
     ResetSwitchData();
 }
Ejemplo n.º 24
0
        void Player_Warped(object sender, StardewModdingAPI.Events.WarpedEventArgs e)
        {
            if (GetPet() == null)
            {
                return;
            }

            if (e.NewLocation is Farm)
            {
                RemoveTempPetFromFarm();
            }
            else
            {
                AddTempPetToFarm();
            }

            if (petState == PetState.Vanilla)
            {
                return;
            }

            if (debug())
            {
                Passables.Clear();
                NonPassables.Clear();
            }

            bool EnteredLeftRight()
            {
                //Log("Layerwidth " + e.NewLocation.map.GetLayer("Back").LayerWidth);
                return(Game1.player.getTileX() < 2 || Game1.player.getTileX() > e.NewLocation.map.GetLayer("Back").LayerWidth - 2);
            }

            bool EnteredTopBot()
            {
                return(Game1.player.getTileY() < 2 || Game1.player.getTileY() > e.NewLocation.map.GetLayer("Back").LayerHeight - 2);
            }

            if (e.NewLocation is Town ||
                e.NewLocation is Forest ||
                e.NewLocation is Desert ||
                e.NewLocation is BusStop ||
                e.NewLocation is Beach ||
                e.NewLocation is BeachNightMarket ||
                e.NewLocation is Mountain ||
                e.NewLocation is Summit
                //|| e.NewLocation is CommunityCenter
                || e.NewLocation is Railroad ||
                e.NewLocation.Name == "Backwoods")
            {
                List <Vector2> tryTiles = new List <Vector2>()
                {
                    Utility.recursiveFindOpenTileForCharacter(pet, e.NewLocation, Game1.player.getTileLocation(), 10)
                };

                if (e.NewLocation is CommunityCenter)
                {
                    tryTiles.Insert(0, Game1.player.getTileLocation() - new Vector2(0, 5));
                }
                else if ((e.NewLocation is Beach || e.NewLocation is BeachNightMarket) && e.OldLocation is Town)
                {
                    tryTiles.Insert(0, Game1.player.getTileLocation() + new Vector2(0, 5));
                }
                else if (e.NewLocation is Town && (e.OldLocation is Beach || e.OldLocation is BeachNightMarket))
                {
                    tryTiles.Insert(0, Game1.player.getTileLocation() - new Vector2(0, 5));
                    tryTiles.Insert(0, Game1.player.getTileLocation() - new Vector2(1, 5));
                    tryTiles.Insert(0, Game1.player.getTileLocation() - new Vector2(-1, 5));
                }

                if (EnteredLeftRight())
                {
                    tryTiles.Insert(0, Game1.player.getTileLocation() + new Vector2(0, 1));
                    tryTiles.Insert(0, Game1.player.getTileLocation() - new Vector2(0, 1));
                }

                if (EnteredTopBot())
                {
                    tryTiles.Insert(0, Game1.player.getTileLocation() + new Vector2(1, 0));
                    tryTiles.Insert(0, Game1.player.getTileLocation() - new Vector2(1, 0));
                }

                Vector2 petTile = tryTiles.Find(PathFinder.IsPassable);
                if (petTile != null)
                {
                    Game1.warpCharacter(GetPet(), e.NewLocation, petTile);
                    Log("Warped pet to " + petTile);
                }

                else
                {
                    Log("Could not find position for pet", LogLevel.Error);
                }
            }
            else if (e.NewLocation is Farm)
            {
                Game1.warpCharacter(GetPet(), "Farm", new Vector2(54f, 8f));
                pet.position.X -= 64f;
            }

            else if (e.NewLocation is FarmHouse farmHouse)
            {
                GetPet().warpToFarmHouse(farmHouse.owner);
            }
            else if (e.NewLocation is MineShaft && !(e.OldLocation is MineShaft) || e.NewLocation is Woods /*|| e.NewLocation is Sewer*/)
            {
                if (config.show_message_on_warp)
                {
                    Game1.showGlobalMessage(Helper.Translation.Get("warp.todangerous", new { petname = GetPet().displayName }));
                }
            }
            else if (!e.NewLocation.isOutdoors && e.OldLocation.isOutdoors)
            {
                if (config.show_message_on_warp)
                {
                    Game1.showGlobalMessage(Helper.Translation.Get("warp.waitingoutside", new { petname = GetPet().displayName }));
                }
            }
            else
            {
                Monitor.Log("warped to unknown location: " + Game1.currentLocation.Name, LogLevel.Trace);
            }
        }
Ejemplo n.º 25
0
 /// <summary>Clears all cached assets when the local player changes location.</summary>
 private static void Warped_ClearCache(object sender, StardewModdingAPI.Events.WarpedEventArgs e)
 {
     Cache.Clear();
 }
Ejemplo n.º 26
0
 private static void Player_Warped_InvalidateCache(object sender, StardewModdingAPI.Events.WarpedEventArgs e)
 {
     exclusionData = null; //invalidate cache (e.g. to account for Content Patcher's OnLocationChange)
 }
Ejemplo n.º 27
0
        private void Player_Warped(object sender, StardewModdingAPI.Events.WarpedEventArgs e)
        {
            GameLocation location = e.NewLocation;

            AddButterflies(location);
        }
Ejemplo n.º 28
0
 private void Player_Warped(object sender, StardewModdingAPI.Events.WarpedEventArgs e)
 {
     isInCoop = e.IsLocalPlayer && e.NewLocation.Map.Id.ToLower() == "coop";
 }
Ejemplo n.º 29
0
        void Player_Warped(object sender, StardewModdingAPI.Events.WarpedEventArgs e)
        {
            if (GetPet() == null)
            {
                return;
            }

            if (e.NewLocation is Farm)
            {
                RemoveTempPetFromFarm();
            }
            else
            {
                AddTempPetToFarm();
            }

            if (petState == PetState.Vanilla)
            {
                return;
            }


            if (debug())
            {
                Passables.Clear();
                NonPassables.Clear();
            }

            Vector2 PlayerTile = new Vector2((int)(Game1.player.Position.X / Game1.tileSize), (int)(Game1.player.Position.Y / Game1.tileSize));


            bool EnteredLeftRight()
            {
                return(PlayerTile.X < 2 || PlayerTile.X > e.NewLocation.map.GetLayer("Back").LayerWidth - 2);
            }

            bool EnteredTopBot()
            {
                return(PlayerTile.Y < 2 || PlayerTile.Y > e.NewLocation.map.GetLayer("Back").LayerHeight - 2);
            }

            if (e.NewLocation.Name == "Temp")
            {
                Monitor.Log("Pet cannot follow on temporary map. Warping to Farm and unfollow.");
                WarpPet(Game1.getLocationFromName("Farm"), new Vector2(54f, 8f));
                SetState(PetState.Vanilla);
            }
            else if (e.NewLocation is Town ||
                     e.NewLocation is Forest ||
                     e.NewLocation is Desert ||
                     e.NewLocation is BusStop ||
                     e.NewLocation is Beach ||
                     e.NewLocation is BeachNightMarket ||
                     e.NewLocation is Mountain ||
                     e.NewLocation is Summit
                     //|| e.NewLocation is CommunityCenter
                     || e.NewLocation is Railroad ||
                     e.NewLocation.Name == "Backwoods")
            {
                List <Vector2> tryTiles = new List <Vector2>()
                {
                    Utility.recursiveFindOpenTileForCharacter(pet, e.NewLocation, PlayerTile, 10)
                };

                if (e.NewLocation is CommunityCenter)
                {
                    tryTiles.Insert(0, PlayerTile - new Vector2(0, 5));
                }
                else if ((e.NewLocation is Beach || e.NewLocation is BeachNightMarket) && e.OldLocation is Town)
                {
                    tryTiles.Insert(0, PlayerTile + new Vector2(0, 5));
                }
                else if (e.NewLocation is Town && (e.OldLocation is Beach || e.OldLocation is BeachNightMarket))
                {
                    tryTiles.Insert(0, PlayerTile - new Vector2(0, 5));
                    tryTiles.Insert(0, PlayerTile - new Vector2(1, 5));
                    tryTiles.Insert(0, PlayerTile - new Vector2(-1, 5));
                }

                if (EnteredLeftRight())
                {
                    tryTiles.Insert(0, PlayerTile + new Vector2(0, 1));
                    tryTiles.Insert(0, PlayerTile - new Vector2(0, 1));
                }

                if (EnteredTopBot())
                {
                    tryTiles.Insert(0, PlayerTile + new Vector2(1, 0));
                    tryTiles.Insert(0, PlayerTile - new Vector2(1, 0));
                }

                Vector2 petTile = tryTiles.Find(tile => PathFinder.IsPassable(tile, pet));
                //Log("Player loc: " + new Vector2(Game1.player.getTileX(), Game1.player.getTileY()) + ", horse: " + (Game1.player.isRidingHorse() ? new Vector2(Game1.player.mount.getTileX(), Game1.player.mount.getTileY()).ToString() : ""));
                if (petTile != null)
                {
                    WarpPet(e.NewLocation, petTile);
                    Log("Warped pet to " + petTile);
                }

                else
                {
                    Log("Could not find position for pet", LogLevel.Error);
                }
            }
            else if (e.NewLocation is Farm)
            {
                WarpPet(Game1.getLocationFromName("Farm"), new Vector2(54f, 8f));
                pet.position.X -= 64f;
            }

            else if (e.NewLocation is FarmHouse farmHouse)
            {
                WarpPetToFarmhouse(farmHouse.owner);
            }
            else if (e.NewLocation is MineShaft && !(e.OldLocation is MineShaft) || e.NewLocation is Woods /*|| e.NewLocation is Sewer*/)
            {
                if (config.show_message_on_warp)
                {
                    Game1.showGlobalMessage(Helper.Translation.Get("warp.todangerous", new { petname = GetPet().displayName }));
                }
            }
            else if (!e.NewLocation.isOutdoors && e.OldLocation.isOutdoors)
            {
                if (config.show_message_on_warp && !e.NewLocation.isFarmBuildingInterior() && !(e.NewLocation is FarmCave))
                {
                    Game1.showGlobalMessage(Helper.Translation.Get("warp.waitingoutside", new { petname = GetPet().displayName }));
                }
            }
            else
            {
                Monitor.Log("warped to unknown location: " + Game1.currentLocation.Name, LogLevel.Trace);
            }
        }
Ejemplo n.º 30
0
 private void Player_Warped(object sender, StardewModdingAPI.Events.WarpedEventArgs e)
 {
     currentConversations.Clear();
 }