Esempio n. 1
0
        public static void PlaceSpousesInFarmhouse(FarmHouse farmHouse)
        {
            Farmer farmer = farmHouse.owner;

            if (farmer == null)
            {
                return;
            }

            List <NPC> allSpouses = GetSpouses(farmer, 1).Values.ToList();

            if (allSpouses.Count == 0)
            {
                Monitor.Log("no spouses");
                return;
            }

            ShuffleList(ref allSpouses);

            List <string> bedSpouses    = new List <string>();
            string        kitchenSpouse = null;

            foreach (NPC spouse in allSpouses)
            {
                int type = ModEntry.myRand.Next(0, 100);

                Monitor.Log($"spouse rand {type}, bed: {ModEntry.config.PercentChanceForSpouseInBed} kitchen {ModEntry.config.PercentChanceForSpouseInKitchen}");

                if (type < ModEntry.config.PercentChanceForSpouseInBed)
                {
                    if (bedSpouses.Count < GetBedWidth(farmHouse) && (ModEntry.config.RoommateRomance || !farmer.friendshipData[spouse.Name].IsRoommate()) && HasSleepingAnimation(spouse.Name))
                    {
                        Monitor.Log("made bed spouse: " + spouse.Name);
                        bedSpouses.Add(spouse.Name);
                    }
                }
                else if (type < ModEntry.config.PercentChanceForSpouseInBed + ModEntry.config.PercentChanceForSpouseInKitchen)
                {
                    if (kitchenSpouse == null)
                    {
                        Monitor.Log("made kitchen spouse: " + spouse.Name);
                        kitchenSpouse = spouse.Name;
                    }
                }
            }

            List <string> allBedSpouses = new List <string>(GetSpouses(farmer, 1).Keys.ToList());

            List <NPC> roomSpouses = GetSpouses(farmer, -1).Values.ToList().FindAll((s) => (Maps.roomIndexes.ContainsKey(s.Name) || Maps.tmxSpouseRooms.ContainsKey(s.Name)) && !farmer.friendshipData[s.Name].IsEngaged());

            foreach (NPC j in allSpouses)
            {
                Monitor.Log("placing " + j.Name);

                Point   kitchenSpot    = farmHouse.getKitchenStandingSpot();
                Vector2 spouseRoomSpot = (farmHouse.upgradeLevel == 1) ? new Vector2(32f, 5f) : new Vector2(38f, 14f);

                if (farmer.Equals(Game1.MasterPlayer))
                {
                    if (ModEntry.outdoorAreaData.areas.ContainsKey(j.Name))
                    {
                        SetupSpouseArea(ModEntry.outdoorAreaData.areas[j.Name], j.Name);
                        if (!Game1.isRaining && !Game1.IsWinter && Game1.shortDayNameFromDayOfSeason(Game1.dayOfMonth).Equals("Sat") && !j.Name.Equals("Krobus"))
                        {
                            Monitor.Log("going to outdoor patio");
                            j.setUpForOutdoorPatioActivity();
                            continue;
                        }
                    }
                    else if (farmer.spouse.Equals(j.Name))
                    {
                        OutdoorArea area = new OutdoorArea()
                        {
                            startX = 69,
                            startY = 6,
                        };
                        SetupSpouseArea(area, j.Name);
                        if (!Game1.isRaining && !Game1.IsWinter && Game1.shortDayNameFromDayOfSeason(Game1.dayOfMonth).Equals("Sat") && !j.Name.Equals("Krobus"))
                        {
                            Monitor.Log("going to outdoor patio");
                            j.setUpForOutdoorPatioActivity();
                            continue;
                        }
                    }
                }

                if (!farmHouse.Equals(j.currentLocation))
                {
                    continue;
                }

                Monitor.Log("in farm house");
                j.shouldPlaySpousePatioAnimation.Value = false;

                Vector2 spot = (farmHouse.upgradeLevel == 1) ? new Vector2(32f, 5f) : new Vector2(38f, 14f);


                if (bedSpouses.Count > 0 && (IsInBed(farmHouse, j.GetBoundingBox()) || bedSpouses.Contains(j.Name)))
                {
                    Monitor.Log($"putting {j.Name} in bed");
                    j.position.Value = GetSpouseBedPosition(farmHouse, allBedSpouses, j.Name);

                    if (HasSleepingAnimation(j.Name) && Game1.timeOfDay >= 2000)
                    {
                        j.playSleepingAnimation();
                    }
                }
                else if (kitchenSpouse == j.Name)
                {
                    Monitor.Log($"{j.Name} is in kitchen");
                    j.setTilePosition(farmHouse.getKitchenStandingSpot());
                }
                else if (!ModEntry.config.BuildAllSpousesRooms && farmer.spouse != j.Name)
                {
                    j.setTilePosition(farmHouse.getRandomOpenPointInHouse(ModEntry.myRand));
                }
                else
                {
                    if (!roomSpouses.Contains(j))
                    {
                        j.setTilePosition(farmHouse.getRandomOpenPointInHouse(ModEntry.myRand));
                        j.faceDirection(ModEntry.myRand.Next(0, 4));
                        Monitor.Log($"{j.Name} spouse random loc");
                        continue;
                    }
                    else
                    {
                        int offset = roomSpouses.IndexOf(j) * 7;
                        j.setTilePosition((int)spot.X + offset, (int)spot.Y);
                        j.faceDirection(ModEntry.myRand.Next(0, 4));
                        j.setSpouseRoomMarriageDialogue();
                        Monitor.Log($"{j.Name} loc: {(spot.X + offset)},{spot.Y}");
                    }
                }
            }
        }
Esempio n. 2
0
        private static void SetupSpouseArea(OutdoorArea area, string name)
        {
            Farm farm = Game1.getFarm();

            int x = area.startX;
            int y = area.startY;

            if (farm.map.Layers[0].LayerWidth <= x + 3 || farm.map.Layers[0].LayerHeight <= y + 3)
            {
                Monitor.Log($"Invalid spouse area coordinates {x},{y} for {name}", LogLevel.Error);
                return;
            }

            farm.removeTile(x + 1, y + 3, "Buildings");
            farm.removeTile(x + 2, y + 3, "Buildings");
            farm.removeTile(x + 3, y + 3, "Buildings");
            farm.removeTile(x, y + 3, "Buildings");
            farm.removeTile(x + 1, y + 2, "Buildings");
            farm.removeTile(x + 2, y + 2, "Buildings");
            farm.removeTile(x + 3, y + 2, "Buildings");
            farm.removeTile(x, y + 2, "Buildings");
            farm.removeTile(x + 1, y + 1, "Front");
            farm.removeTile(x + 2, y + 1, "Front");
            farm.removeTile(x + 3, y + 1, "Front");
            farm.removeTile(x, y + 1, "Front");
            farm.removeTile(x + 1, y, "AlwaysFront");
            farm.removeTile(x + 2, y, "AlwaysFront");
            farm.removeTile(x + 3, y, "AlwaysFront");
            farm.removeTile(x, y, "AlwaysFront");

            switch (name)
            {
            case "Sam":
                farm.setMapTileIndex(x, y + 2, 1173, "Buildings", 1);
                farm.setMapTileIndex(x + 3, y + 2, 1174, "Buildings", 1);
                farm.setMapTileIndex(x + 1, y + 2, 1198, "Buildings", 1);
                farm.setMapTileIndex(x + 2, y + 2, 1199, "Buildings", 1);
                farm.setMapTileIndex(x, y + 1, 1148, "Front", 1);
                farm.setMapTileIndex(x + 3, y + 1, 1149, "Front", 1);
                return;

            case "Penny":
                farm.setMapTileIndex(x, y + 2, 1098, "Buildings", 1);
                farm.setMapTileIndex(x + 1, y + 2, 1123, "Buildings", 1);
                farm.setMapTileIndex(x + 3, y + 2, 1098, "Buildings", 1);
                return;

            case "Sebastian":
                farm.setMapTileIndex(x + 1, y + 2, 1927, "Buildings", 1);
                farm.setMapTileIndex(x + 2, y + 2, 1928, "Buildings", 1);
                farm.setMapTileIndex(x + 3, y + 2, 1929, "Buildings", 1);
                farm.setMapTileIndex(x + 1, y + 1, 1902, "Front", 1);
                farm.setMapTileIndex(x + 2, y + 1, 1903, "Front", 1);
                return;

            case "Shane":
                farm.setMapTileIndex(x + 1, y + 3, 1940, "Buildings", 1);
                farm.setMapTileIndex(x + 2, y + 3, 1941, "Buildings", 1);
                farm.setMapTileIndex(x + 3, y + 3, 1942, "Buildings", 1);
                farm.setMapTileIndex(x + 1, y + 2, 1915, "Buildings", 1);
                farm.setMapTileIndex(x + 2, y + 2, 1916, "Buildings", 1);
                farm.setMapTileIndex(x + 3, y + 2, 1917, "Buildings", 1);
                farm.setMapTileIndex(x + 1, y + 1, 1772, "Front", 1);
                farm.setMapTileIndex(x + 2, y + 1, 1773, "Front", 1);
                farm.setMapTileIndex(x + 3, y + 1, 1774, "Front", 1);
                farm.setMapTileIndex(x + 1, y, 1747, "AlwaysFront", 1);
                farm.setMapTileIndex(x + 2, y, 1748, "AlwaysFront", 1);
                farm.setMapTileIndex(x + 3, y, 1749, "AlwaysFront", 1);
                return;

            case "Alex":
                farm.setMapTileIndex(x, y + 2, 1099, "Buildings", 1);
                return;

            case "Maru":
                farm.setMapTileIndex(x + 2, y + 2, 1124, "Buildings", 1);
                return;

            case "Emily":
                farm.setMapTileIndex(x, y + 2, 1867, "Buildings", 1);
                farm.setMapTileIndex(x + 3, y + 2, 1867, "Buildings", 1);
                farm.setMapTileIndex(x, y + 1, 1842, "Front", 1);
                farm.setMapTileIndex(x + 3, y + 1, 1842, "Front", 1);
                farm.setMapTileIndex(x, y + 3, 1866, "Buildings", 1);
                farm.setMapTileIndex(x + 2, y + 2, 1866, "Buildings", 1);
                farm.setMapTileIndex(x + 3, y + 3, 1967, "Buildings", 1);
                farm.setMapTileIndex(x + 1, y + 2, 1967, "Buildings", 1);
                return;

            case "Haley":
                farm.setMapTileIndex(x, y + 2, 1074, "Buildings", 1);
                farm.setMapTileIndex(x, y + 1, 1049, "Front", 1);
                farm.setMapTileIndex(x, y, 1024, "AlwaysFront", 1);
                farm.setMapTileIndex(x + 3, y + 2, 1074, "Buildings", 1);
                farm.setMapTileIndex(x + 3, y + 1, 1049, "Front", 1);
                farm.setMapTileIndex(x + 3, y, 1024, "AlwaysFront", 1);
                return;

            case "Harvey":
                farm.setMapTileIndex(x, y + 2, 1098, "Buildings", 1);
                farm.setMapTileIndex(x + 1, y + 2, 1123, "Buildings", 1);
                farm.setMapTileIndex(x + 3, y + 2, 1098, "Buildings", 1);
                return;

            case "Elliott":
                farm.setMapTileIndex(x, y + 2, 1098, "Buildings", 1);
                farm.setMapTileIndex(x + 1, y + 2, 1123, "Buildings", 1);
                farm.setMapTileIndex(x + 3, y + 2, 1098, "Buildings", 1);
                return;

            case "Leah":
                farm.setMapTileIndex(x + 1, y + 2, 1122, "Buildings", 1);
                farm.setMapTileIndex(x + 1, y + 1, 1097, "Front", 1);
                return;

            case "Abigail":
                farm.setMapTileIndex(x, y + 2, 1098, "Buildings", 1);
                farm.setMapTileIndex(x + 1, y + 2, 1123, "Buildings", 1);
                farm.setMapTileIndex(x + 3, y + 2, 1098, "Buildings", 1);
                return;
            }
            foreach (SpecialTile tile in area.specialTiles)
            {
                farm.setMapTileIndex(tile.x, tile.y, tile.tileIndex, tile.layer, tile.tilesheet);
            }
        }