Advertisement
Guest User

Untitled

a guest
Sep 19th, 2017
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.53 KB | None | 0 0
  1. private InventorySlot FindSlot(string itemName, SlotSearchOptions searchOptions)
  2. {
  3. List<InventorySlot> InventorySlots = this.InventorySlots;
  4.  
  5. if(searchOptions.SlotSearchLocation == SlotSearchLocation.Last)
  6. {
  7. List<InventorySlot> TempSlots = new List<InventorySlot>();
  8.  
  9. for (int i = InventorySlots.Count - 1; i > 0; i--)
  10. {
  11. TempSlots.Add(InventorySlots[i]);
  12. }
  13.  
  14. InventorySlots = TempSlots;
  15. }
  16.  
  17. InventorySlot foundSlot = null;
  18.  
  19. foreach (InventorySlot inventorySlot in InventorySlots)
  20. {
  21. bool rule = false;
  22.  
  23. if (searchOptions.SlotSearchType == SlotSearchType.Similar)
  24. {
  25. rule = inventorySlot.ItemName == itemName && !inventorySlot.Maxed;
  26. }else if(searchOptions.SlotSearchType == SlotSearchType.Open)
  27. {
  28. rule = inventorySlot.Initialized == false;
  29. }
  30.  
  31. if (rule)
  32. {
  33. foundSlot = inventorySlot;
  34. break;
  35. }
  36. }
  37.  
  38. if (foundSlot != null)
  39. return foundSlot;
  40. else
  41. {
  42. if (searchOptions.SlotSearchFlexibility == SlotSearchFlexibility.Comfortable)
  43. {
  44. SlotSearchOptions options = searchOptions;
  45. options.SlotSearchType = SlotSearchType.Open;
  46.  
  47. return FindSlot(itemName, options);
  48. }
  49. }
  50.  
  51. return null;
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement