Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private InventorySlot FindSlot(string itemName, SlotSearchOptions searchOptions)
- {
- List<InventorySlot> InventorySlots = this.InventorySlots;
- if(searchOptions.SlotSearchLocation == SlotSearchLocation.Last)
- {
- List<InventorySlot> TempSlots = new List<InventorySlot>();
- for (int i = InventorySlots.Count - 1; i > 0; i--)
- {
- TempSlots.Add(InventorySlots[i]);
- }
- InventorySlots = TempSlots;
- }
- InventorySlot foundSlot = null;
- foreach (InventorySlot inventorySlot in InventorySlots)
- {
- bool rule = false;
- if (searchOptions.SlotSearchType == SlotSearchType.Similar)
- {
- rule = inventorySlot.ItemName == itemName && !inventorySlot.Maxed;
- }else if(searchOptions.SlotSearchType == SlotSearchType.Open)
- {
- rule = inventorySlot.Initialized == false;
- }
- if (rule)
- {
- foundSlot = inventorySlot;
- break;
- }
- }
- if (foundSlot != null)
- return foundSlot;
- else
- {
- if (searchOptions.SlotSearchFlexibility == SlotSearchFlexibility.Comfortable)
- {
- SlotSearchOptions options = searchOptions;
- options.SlotSearchType = SlotSearchType.Open;
- return FindSlot(itemName, options);
- }
- }
- return null;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement