/// <summary> /// Checks whether the player has an item. /// </summary> public static Func <int, bool> HasItem(int itemID, int quantity = 1) { return((b) => { int slot = InstanceTracker.GameScript.ItemExistsSlot(itemID); return slot != -1 && GadgetCoreAPI.GetInventory()[slot].q >= quantity; }); }
/// <summary> /// Takes an item from the player. /// </summary> public static Action TakeItem(int itemID, int quantity = 1) { return(() => { int slot = InstanceTracker.GameScript.ItemExistsSlot(itemID); if (slot != -1 && GadgetCoreAPI.GetInventory()[slot].q >= quantity) { GadgetCoreAPI.GetInventory()[slot].q -= quantity; InstanceTracker.GameScript.RefreshSlot(slot); } }); }