private static void GetIslandFarmHouseSpouseRooms(IslandFarmHouse fh, List <string> orderableSpouses, out List <string> customSpouses)
 {
     SMonitor.Log($"Getting {orderableSpouses.Count} island spouse rooms");
     customSpouses = new List <string>();
     for (int i = orderableSpouses.Count - 1; i >= 0; i--)
     {
         if (ModEntry.customRoomData.TryGetValue(orderableSpouses[i], out SpouseRoomData srd) && srd.islandFarmHouse && srd.startPos.X > -1)
         {
             SMonitor.Log($"{orderableSpouses[i]} has custom island spouse room at {srd.startPos}");
             customSpouses.Add(orderableSpouses[i]);
         }
     }
 }
Example #2
0
        /// <summary>Get all items owned by the player.</summary>
        /// <remarks>
        /// This is derived from <see cref="Utility.iterateAllItems"/> with some improvements:
        ///   * removed items held by other players, items floating on the ground, spawned forage, and output in a non-ready machine (except casks which can be emptied anytime);
        ///   * added hay in silos;
        ///   * added tool attachments;
        ///   * added recursive scanning (e.g. inside held chests) to support mods like Item Bag.
        /// </remarks>
        public IEnumerable <FoundItem> GetAllOwnedItems()
        {
            List <FoundItem> items     = new List <FoundItem>();
            ISet <Item>      itemsSeen = new HashSet <Item>(new ObjectReferenceComparer <Item>());

            // in locations
            foreach (GameLocation location in CommonHelper.GetLocations())
            {
                // furniture
                foreach (Furniture furniture in location.furniture)
                {
                    this.ScanAndTrack(items, itemsSeen, furniture, isRootInWorld: true);
                }

                // farmhouse fridge
                Chest fridge = location switch
                {
                    FarmHouse house => house.fridge.Value,
                    IslandFarmHouse house => house.fridge.Value,
                      _ => null
                };
                this.ScanAndTrack(items, itemsSeen, fridge, includeRoot: false);

                // character hats
                foreach (NPC npc in location.characters)
                {
                    Hat hat =
                        (npc as Child)?.hat.Value
                        ?? (npc as Horse)?.hat.Value;
                    this.ScanAndTrack(items, itemsSeen, hat);
                }

                // building output
                if (location is BuildableGameLocation buildableLocation)
                {
                    foreach (var building in buildableLocation.buildings)
                    {
                        switch (building)
                        {
                        case Mill mill:
                            this.ScanAndTrack(items, itemsSeen, mill.output.Value, includeRoot: false);
                            break;

                        case JunimoHut hut:
                            this.ScanAndTrack(items, itemsSeen, hut.output.Value, includeRoot: false);
                            break;
                        }
                    }
                }

                // map objects
                foreach (SObject item in location.objects.Values)
                {
                    if (item is Chest || !this.IsSpawnedWorldItem(item))
                    {
                        this.ScanAndTrack(items, itemsSeen, item, isRootInWorld: true);
                    }
                }
            }

            // inventory
            this.ScanAndTrack(items, itemsSeen, Game1.player.Items, isInInventory: true);
            this.ScanAndTrack(
                items,
                itemsSeen,
                new Item[]
            {
                Game1.player.shirtItem.Value,
                Game1.player.pantsItem.Value,
                Game1.player.boots.Value,
                Game1.player.hat.Value,
                Game1.player.leftRing.Value,
                Game1.player.rightRing.Value
            },
                isInInventory: true
                );

            // hay in silos
            int hayCount = Game1.getFarm()?.piecesOfHay.Value ?? 0;

            while (hayCount > 0)
            {
                SObject hay = new SObject(178, 1);
                hay.Stack = Math.Min(hayCount, hay.maximumStackSize());
                hayCount -= hay.Stack;
                this.ScanAndTrack(items, itemsSeen, hay);
            }

            return(items);
        }