/// <summary> /// Get a list of all pickups that are on the ground /// </summary> /// <returns></returns> private static IEnumerable <PickupObject> GetPickups() { List <PickupObject> output = new List <PickupObject>(); //itterate through all loaded pickups foreach (var pickup in TypeTracker.GetTrackedObjects <PickupObject>()) { //this check is used to help keep TypeTracker clean //this helps prevent leaks //Ideally this code would be in TypeTracker instead, but for some reason, the null check works unexpectidly on generics if (pickup == null) { TypeTracker.Remove <PickupObject>(pickup); } else { //determine if this pickup is a debris object bool debris = pickup.GetComponentInParent <DebrisObject>() != null || pickup.GetComponentInChildren <DebrisObject>() != null; if (debris) { output.Add(pickup); } } } return(output); }
/// <summary> /// Gets a list of all items currently on a pedestal /// </summary> /// <returns></returns> private static IEnumerable <RewardPedestal> GetPedestalItems() { List <RewardPedestal> output = new List <RewardPedestal>(); //itterate through all pedestal items foreach (var ped in TypeTracker.GetTrackedObjects <RewardPedestal>()) { //this check is used to help keep TypeTracker clean //this helps prevent leaks //Ideally this code would be in TypeTracker instead, but for some reason, the null check works unexpectidly on generics if (ped == null) { TypeTracker.Remove <RewardPedestal>(ped); } else { output.Add(ped); } } return(output); }
/// <summary> /// Get a list of all items in the shop /// </summary> /// <returns></returns> private static IEnumerable <ShopItemController> GetShopItems() { List <ShopItemController> output = new List <ShopItemController>(); //itterate through all loaded shop items foreach (var shopItem in TypeTracker.GetTrackedObjects <ShopItemController>()) { //this check is used to help keep TypeTracker clean //this helps prevent leaks //Ideally this code would be in TypeTracker instead, but for some reason, the null check works unexpectidly on generics if (shopItem == null) { TypeTracker.Remove <ShopItemController>(shopItem); } else { output.Add(shopItem); } } return(output); }
/// <summary> /// Load ETGItemCards hooks initialize classes /// </summary> public override void Start() { //Command to load the debug functions used for development. //Debug function are undocumented, use at your own risk Commands.AddGroup("loadDebugFunctions", DebugFunctions.LoadDebugFunctions); //command to set desired format for item cards Commands.AddGroup("SetCardFormat", SetCardFormat); //Create a hook for the GameUIRoot class for running this mods update loop MethodBase gameUIUpdate = typeof(TimeInvariantMonoBehaviour).GetMethod("Update", (BindingFlags)(-1)); MethodInfo gameUIUpdateHook = typeof(PickupTracker).GetMethod("UpdateHook", (BindingFlags)(-1)); new Hook(gameUIUpdate, gameUIUpdateHook); //Track intantiation and deletion of the objects that are needed for tracking TypeTracker.TrackType(typeof(PickupObject)); TypeTracker.TrackType(typeof(ShopItemController)); TypeTracker.TrackType(typeof(RewardPedestal)); //Log that the mod loaded, for players Log("Item Cards Loaded"); }