Esempio n. 1
0
        public static Point getBedSpot(FarmHouse house, bool spouse = false)
        {
            FarmHouseState state = getState(house);

            Logger.Log("Getting bed location...");
            if (state.bedData == null)
            {
                updateFromMapPath(house, house.mapPath);
            }
            if (state.bedData != "")
            {
                Logger.Log("Map defined bed location...");
                string[] bedPoint    = state.bedData.Split(' ');
                Point    bedLocation = new Point(Convert.ToInt32(bedPoint[0]) + (spouse ? 2 : 0), Convert.ToInt32(bedPoint[1]));

                Logger.Log("Defined bed location as " + bedLocation.ToString());

                return(bedLocation);
            }
            else
            {
                Logger.Log("Map did not define a bed location, using vanilla.");
                if (spouse && house.owner.isMarried())
                {
                    return(house.getSpouseBedSpot(house.owner.spouse));
                }
                return(house.getBedSpot());
            }
        }
Esempio n. 2
0
 public static void clear(FarmHouse house)
 {
     if (!states.ContainsKey(house))
     {
         states[house] = new FarmHouseState();
     }
     states[house].clear();
 }
Esempio n. 3
0
 public static FarmHouseState getState(FarmHouse house)
 {
     if (!states.ContainsKey(house))
     {
         Logger.Log("No state found for " + house.name + "!  (" + house.uniqueName + ")");
         states[house] = new FarmHouseState();
     }
     return(states[house]);
 }
Esempio n. 4
0
 public static void init()
 {
     states = new Dictionary <FarmHouse, FarmHouseState>();
     foreach (GameLocation location in Game1.locations)
     {
         if (location is FarmHouse)
         {
             states[location as FarmHouse] = new FarmHouseState();
         }
     }
     loadVanillaSpouses();
     //upgrades = new List<LevelNUpgrade>();
     //loadAllUpgrades();
 }
Esempio n. 5
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));
            }
        }
Esempio n. 6
0
        public static Point getKitchenSpot(FarmHouse house)
        {
            FarmHouseState state = getState(house);

            if (state.kitchenData == null)
            {
                updateFromMapPath(house, house.mapPath);
            }
            if (state.kitchenData != "")
            {
                Logger.Log("Map defined kitchen location...");
                string[] kitchenPoint = state.kitchenData.Split(' ');
                return(new Point(Convert.ToInt32(kitchenPoint[0]), Convert.ToInt32(kitchenPoint[1])));
            }
            else
            {
                Logger.Log("Map did not define kitchen location.");
                return(house.getKitchenStandingSpot());
            }
        }
Esempio n. 7
0
        public static Point getCellarLocation(FarmHouse house)
        {
            FarmHouseState state = getState(house);

            if (state.cellarData == null)
            {
                updateFromMapPath(house, house.mapPath);
            }
            if (state.cellarData != "")
            {
                Logger.Log("Map defined entry location...");
                string[] cellarPoint = state.cellarData.Split(' ');
                return(new Point(Convert.ToInt32(cellarPoint[0]), Convert.ToInt32(cellarPoint[1])));
            }
            else
            {
                Logger.Log("Map did not define cellar return location.");
                return(new Point(-1, -1));
            }
        }
Esempio n. 8
0
        public static void updateFromMapPath(FarmHouse house, string mapPath)
        {
            clear(house);
            FarmHouseState state = getState(house);
            //Map map = makeMapCopy(house, mapPath);
            Map           map = loader.Load <Map>(mapPath, ContentSource.GameContent);
            PropertyValue bed;

            map.Properties.TryGetValue("Bed", out bed);
            if (bed != null)
            {
                state.bedData = Utility.cleanup(bed.ToString());
            }
            else
            {
                state.bedData = "";
            }
            PropertyValue spouseRoom;

            map.Properties.TryGetValue("Spouse", out spouseRoom);
            if (spouseRoom != null)
            {
                state.spouseRoomData = Utility.cleanup(spouseRoom.ToString());
            }
            else
            {
                state.spouseRoomData = "";
            }
            PropertyValue kitchen;

            map.Properties.TryGetValue("Kitchen", out kitchen);
            if (kitchen != null)
            {
                state.kitchenData = Utility.cleanup(kitchen.ToString());
            }
            else
            {
                state.kitchenData = "";
            }

            PropertyValue entry;

            map.Properties.TryGetValue("Entry", out entry);
            if (entry != null)
            {
                state.entryData = Utility.cleanup(entry.ToString());
            }
            else
            {
                state.entryData = "";
            }

            PropertyValue cellar;

            map.Properties.TryGetValue("Cellar", out cellar);
            if (cellar != null)
            {
                state.cellarData = Utility.cleanup(cellar.ToString());
            }
            else
            {
                state.cellarData = "";
            }

            PropertyValue levelThree;

            map.Properties.TryGetValue("Level3", out levelThree);
            if (levelThree != null)
            {
                state.levelThreeData = Utility.cleanup(levelThree.ToString());
            }
            else
            {
                state.levelThreeData = "";
            }

            if (mapPath.Contains("_marriage"))
            {
                state.isMarriage = true;
            }

            Logger.Log("Getting tilesheets for map " + map.Id + " (" + mapPath + ")...");

            foreach (xTile.Tiles.TileSheet sheet in map.TileSheets)
            {
                Logger.Log("Sheet source is " + sheet.ImageSource);
                if (sheet.ImageSource.Contains("walls_and_floors"))
                {
                    state.wallsAndFloorsSheet = map.TileSheets.IndexOf(sheet);
                }
                else if (sheet.ImageSource.Contains("townInterior"))
                {
                    state.interiorSheet = map.TileSheets.IndexOf(sheet);
                }
                else if (sheet.ImageSource.Contains("farmhouse_tiles"))
                {
                    state.farmSheet = map.TileSheets.IndexOf(sheet);
                }
                else if (sheet.ImageSource.Contains("SewerTiles"))
                {
                    Logger.Log("Sewer tiles found!");
                    state.sewerSheet = map.TileSheets.IndexOf(sheet);
                    Logger.Log("Sewer sheet index: " + state.sewerSheet);
                }
            }
        }