protected override void OnSlotChanged(SyncDictionaryItemSlot.Operation op, int key, ItemSlotData itemSlotData) { base.OnSlotChanged(op, key, itemSlotData); if (itemSlotData.SlotType == ItemSlotType.Any) { return; } SlotReferences.TryGetValue(itemSlotData.SlotType, out var equipmentSlotReference); InventorySlots.TryGetValue(key, out var itemSlot); var equipableSlot = itemSlot as SlotEquipable; switch (op) { case SyncDictionaryItemSlot.Operation.OP_ADD: InventorySlots.Add(key, new SlotEquipable(equipmentSlotReference.SlotTransform, itemSlotData, key)); return; case SyncDictionaryItemSlot.Operation.OP_REMOVE: InventorySlots.Remove(key); return; } if (equipableSlot == null) { return; } equipableSlot.SlotData = itemSlotData; equipableSlot.OnSlotChange(); EquipmentSlotChanged(itemSlotData, equipableSlot); }
public void OnSlotChanged(SyncDictionaryItemSlot.Operation op, int inventoryIndex, ItemSlotData itemSlotData) { if (itemSlotData.SlotType != ItemSlotType.Any) { return; // return if equipment slot } SlotUis.TryGetValue(inventoryIndex, out var slotUi); if (slotUi == null) { return; } slotUi.SlotData = itemSlotData; }
public void OnSlotChanged(SyncDictionaryItemSlot.Operation op, int inventoryIndex, ItemSlotData itemSlotData) { if (itemSlotData.SlotType == ItemSlotType.Any) { return; // return if non equipment slot } SlotUis.TryGetValue(inventoryIndex, out var slotUi); if (slotUi == null) { return; } slotUi.SlotData = itemSlotData; // handle slotImage slotUi.SlotImage.gameObject.SetActive(!itemSlotData.Occupant()); }
protected virtual void OnSlotChanged(SyncDictionaryItemSlot.Operation op, int key, ItemSlotData itemSlotData) { if (itemSlotData.SlotType != ItemSlotType.Any) { return; } InventorySlots.TryGetValue(key, out var itemSlot); switch (op) { case SyncDictionaryItemSlot.Operation.OP_ADD: InventorySlots.Add(key, new Slot(_inventoryTransform, itemSlotData, key)); return; case SyncDictionaryItemSlot.Operation.OP_REMOVE: InventorySlots.Remove(key); return; } if (itemSlot == null) { return; } itemSlot.SlotData = itemSlotData; itemSlot.OnSlotChange(); }