//Means OnDrop while drag and dropping an Item. OnDrop is the UISlot that the mouse pointer is over when the user drops the item public void OnDrop(PointerEventData data) { if (UIManager.DragAndDrop.ItemSlotCache != null && UIManager.DragAndDrop.ItemCache != null) { if (itemSlot.Item == null && itemSlot.CheckItemFit(UIManager.DragAndDrop.ItemCache)) { if (PlayerManager.LocalPlayerScript != null) { if (!PlayerManager.LocalPlayerScript.playerMove.allowInput || PlayerManager.LocalPlayerScript.playerMove.isGhost) { return; } } UIManager.TryUpdateSlot(new UISlotObject(itemSlot.inventorySlot.UUID, UIManager.DragAndDrop.ItemCache, UIManager.DragAndDrop.ItemSlotCache?.inventorySlot.UUID)); } // else if (itemSlot.Item != null) // { // //Check if it is a storage obj: // var storageObj = itemSlot.Item.GetComponent<StorageObject>(); // if (storageObj != null) // { // if(storageObj.NextSpareSlot() != null){ // UIManager.TryUpdateSlot(new UISlotObject(storageObj.NextSpareSlot().UUID, UIManager.DragAndDrop.ItemCache, // UIManager.DragAndDrop.ItemSlotCache?.inventorySlot.UUID)); // } // } // } } }
public static bool CanPutItemToSlot(UISlotObject proposedSlotInfo) { if (proposedSlotInfo.IsEmpty() || !SendUpdateAllowed(proposedSlotInfo.SlotContents)) { return(false); } UI_ItemSlot uiItemSlot = InventorySlots[proposedSlotInfo.Slot]; PlayerScript lps = PlayerManager.LocalPlayerScript; if (!lps || lps.canNotInteract() || uiItemSlot == null || uiItemSlot.IsFull || !uiItemSlot.CheckItemFit(proposedSlotInfo.SlotContents)) { return(false); } return(true); }
//Means OnDrop while drag and dropping an Item. OnDrop is the UISlot that the mouse pointer is over when the user drops the item public void OnDrop(PointerEventData data) { if (UIManager.DragAndDrop.ItemSlotCache != null && UIManager.DragAndDrop.ItemCache != null) { if (itemSlot.inventorySlot.IsUISlot) { if (itemSlot.Item == null) { if (itemSlot.CheckItemFit(UIManager.DragAndDrop.ItemCache)) { if (PlayerManager.LocalPlayerScript != null) { if (!PlayerManager.LocalPlayerScript.playerMove.allowInput || PlayerManager.LocalPlayerScript.IsGhost) { return; } } if (UIManager.DragAndDrop.ItemSlotCache.inventorySlot.IsUISlot) { PlayerManager.LocalPlayerScript.playerNetworkActions.CmdUpdateSlot(itemSlot.equipSlot, UIManager.DragAndDrop.ItemSlotCache.equipSlot); } else { var storage = UIManager.DragAndDrop.ItemSlotCache.inventorySlot; StoreItemMessage.Send(storage.Owner, PlayerManager.LocalPlayerScript.gameObject, itemSlot.equipSlot, false, storage.equipSlot); } } } else { var storage = itemSlot.Item.GetComponent <InteractableStorage>(); if (storage) { storage.StoreItem(PlayerManager.LocalPlayerScript.gameObject, UIManager.DragAndDrop.ItemSlotCache.equipSlot, UIManager.DragAndDrop.ItemCache); } } } else { var storage = itemSlot.inventorySlot.Owner.GetComponent <InteractableStorage>(); storage.StoreItem(PlayerManager.LocalPlayerScript.gameObject, UIManager.DragAndDrop.ItemSlotCache.equipSlot, UIManager.DragAndDrop.ItemCache); } } }
public static bool CanPutItemToSlot(UISlotObject proposedSlotInfo) { if (proposedSlotInfo.IsEmpty() || !SendUpdateAllowed(proposedSlotInfo.SlotContents)) { return(false); } InventorySlot invSlot = InventoryManager.GetSlotFromUUID(proposedSlotInfo.SlotUUID, false); PlayerScript lps = PlayerManager.LocalPlayerScript; if (!lps || lps.canNotInteract() || invSlot.Item != null) { return(false); } UI_ItemSlot uiItemSlot = InventorySlotCache.GetSlotByUUID(invSlot.UUID); if (uiItemSlot == null) { //Could it be a storage obj that is closed? ItemSize checkMaxSizeOfStorage; if (SlotIsFromClosedBag(invSlot, out checkMaxSizeOfStorage)) { var itemAtts = proposedSlotInfo.SlotContents.GetComponent <ItemAttributes>(); if (itemAtts != null) { if (itemAtts.size <= checkMaxSizeOfStorage) { return(true); } } } return(false); } if (!uiItemSlot.CheckItemFit(proposedSlotInfo.SlotContents)) { return(false); } return(true); }