Esempio n. 1
0
        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);
        }