using System.Collections.Generic; using System.Linq; using StardewValley; using Object = StardewValley.Object; namespace Omegasis.HappyBirthday.Framework { /// Provides utility methods for managing in-game objects. internal class ObjectUtility { /********* ** Properties *********/ /// The cached object data. private static readonly Object[] ObjectList = ObjectUtility.GetAllObjects().ToArray(); /********* ** Public methods *********/ /// Get objects with the given category. /// The category for which to find objects. public static IEnumerable GetObjectsInCategory(int category) { if (category > 0) yield break; foreach (Object obj in ObjectUtility.ObjectList) { if (obj.Category == category) yield return obj; } } /********* ** Private methods *********/ /// Get all objects defined by the game. private static IEnumerable GetAllObjects() { foreach (int key in Game1.content.Load>("Data\\ObjectInformation").Keys) yield return new Object(key, 1); } } }