Beispiel #1
0
        public void Equip(Equipment newItem)
        {
            int itemIndex = (int)newItem.equipmentSlot;

            Unequip(itemIndex);

            currentEquipment[itemIndex] = newItem;

            ShowEquipment(newItem);

            onItemEquip?.Invoke(newItem);
        }
Beispiel #2
0
        /// <summary>
        /// Eequips the entity to the player
        /// </summary>
        /// <param name="entity">The entity to equip</param>
        /// <param name="bodyPart">The bodypart to equip to</param>
        /// <param name="type">The equipment type</param>
        public void Equip(Entity entity, BodyPart bodyPart, EquipType type)
        {
            // If there is an item in the current slot, unequip it
            var currentEquip = activeEquipment[(int)bodyPart];

            if (currentEquip != null)
            {
                UnequipFromBodySlot(bodyPart);

                if (currentEquip == entity)
                {
                    return;
                }
            }

            activeEquipment[(int)bodyPart] = entity;
            OnItemEquip?.Invoke(entity, bodyPart, type);
        }