Esempio n. 1
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);
            }
        }
Esempio n. 2
0
 private void Display_RenderedWorld(object sender, StardewModdingAPI.Events.RenderedWorldEventArgs e)
 {
     if (FarmHouseStates.getState(StardewValley.Utility.getHomeOfFarmer(Game1.player)) != null)
     {
         //FarmHouseStates.drawRender(e.SpriteBatch);
         //e.SpriteBatch.Draw(Image.Renderer.testRender, Vector2.Zero, new Rectangle(0, 0, Image.Renderer.testRender.Width, Image.Renderer.testRender.Height), Color.White, 0.0f, Vector2.Zero, 4f, Microsoft.Xna.Framework.Graphics.SpriteEffects.None, 1);
     }
 }
Esempio n. 3
0
        internal void fixSpousePosition(FarmHouse house)
        {
            if (!Game1.player.isMarried() || Game1.player.getSpouse().currentLocation != house)
            {
                return;
            }
            NPC spouse = Game1.player.getSpouse();

            if (spouse.getTileLocationPoint() == house.getKitchenStandingSpot())
            {
                //Spouse was placed at the kitchen standing spot, move them to modded one.
                Logger.Log("Spouse was in kitchen standing spot...");
                Point kitchenLocation = FarmHouseStates.getKitchenSpot(house);
                spouse.setTilePosition(kitchenLocation);
                Logger.Log(spouse.name + " was moved to " + kitchenLocation.ToString());
            }
            else if (isSpouseInSpouseRoom(spouse, house))
            {
                Logger.Log(spouse.name + " began the day in the spouse room...");
                FarmHouseState state = FarmHouseStates.getState(house);
                if (state.spouseRoomData == null)
                {
                    FarmHouseStates.updateFromMapPath(house, house.mapPath);
                }
                if (state.spouseRoomData != "")
                {
                    Logger.Log("Map defined spouse room location...");
                    string[] spouseRoomPoint    = state.spouseRoomData.Split(' ');
                    Vector2  spouseRoomLocation = new Vector2(Convert.ToInt32(spouseRoomPoint[0]) + 3, Convert.ToInt32(spouseRoomPoint[1]) + 4);
                    spouse.setTileLocation(spouseRoomLocation);
                    Logger.Log(spouse.name + " was moved to " + spouseRoomLocation.ToString());
                }
                else
                {
                    Logger.Log("Map did not define spouse room location.");
                }
            }
            else if (!house.isTileLocationOpen(new xTile.Dimensions.Location(spouse.getTileX(), spouse.getTileY())))
            {
                Logger.Log(spouse.name + " was in the void or was stuck, relocating...");
                spouse.setTilePosition(house.getRandomOpenPointInHouse(Game1.random));
            }
        }