Make Inventory remove item from hotbar as well
Inventory.Remove(ItemMetadata) removes the item from both the inventory and the hotbarmaster
							parent
							
								
									df82248670
								
							
						
					
					
						commit
						a8e4aca91e
					
				|  | @ -239,6 +239,21 @@ public partial class Inventory : Node2D, IItemCollection<ItemMetadata> | |||
| 
 | ||||
|     public bool Remove(ItemMetadata item) | ||||
|     { | ||||
|         int indexInInventory = Items.IndexOf(item); | ||||
|         if (indexInInventory < 0) | ||||
|         { | ||||
|             return false; | ||||
|         } | ||||
| 
 | ||||
|         // remove instances of item from hotbar | ||||
|         int indexInHotbar = HotbarToItemIndexMap.IndexOf(indexInInventory); | ||||
|         if (indexInHotbar >= 0) | ||||
|         { | ||||
|             HotbarToItemIndexMap[indexInHotbar] = -1; | ||||
|             Hotbar[indexInHotbar].QueueFree(); | ||||
|         } | ||||
| 
 | ||||
|         Items[indexInInventory] = null; | ||||
|         return Items.Remove(item); | ||||
|     } | ||||
| 
 | ||||
|  |  | |||
|  | @ -65,4 +65,15 @@ public abstract partial class Item : Node2D | |||
|     { | ||||
| 
 | ||||
|     } | ||||
| 
 | ||||
|     public virtual void Remove() | ||||
|     { | ||||
|         if (IsUsing) | ||||
|         { | ||||
|             Deuse(); | ||||
|         } | ||||
| 
 | ||||
|         Unequip(CharacterOwner); | ||||
|         QueueFree(); | ||||
|     } | ||||
| } | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue