public override void UnEquip(CharacterEquipmentTypeBinder binder, bool deleteItem)
 {
     if (deleteItem)
     {
         UnityEngine.Object.Destroy(binder.currentItem);
     }
 }
        protected virtual void HandleSkinnedMeshes(EquippableInventoryItem copy, CharacterEquipmentTypeBinder binder)
        {
            if (binder.equipTransform == null)
            {
                return;
            }

            if (replaceSkinnedMeshBones)
            {
                var itemSkinned = copy.GetComponentInChildren <SkinnedMeshRenderer>();
                if (itemSkinned != null)
                {
                    // It's a skinned mesh, combine the bones of this mesh with the player's bones to sync animations.
                    var playerSkinned = binder.equipTransform.GetComponentInParent <SkinnedMeshRenderer>();
                    if (playerSkinned != null)
                    {
                        itemSkinned.rootBone = binder.rootBone;

                        if (forceReplaceAllBones)
                        {
                            itemSkinned.bones = playerSkinned.bones;
                            DevdogLogger.LogVerbose("Force copied " + itemSkinned.bones.Length + " bones to new skinned mesh", itemSkinned);
                        }
                        else
                        {
                            ReplaceBonesOnTarget(playerSkinned, itemSkinned);
                        }
                    }
                    else
                    {
                        DevdogLogger.LogWarning("Tried to equip skinned item to player, but no skinned mesh renderer found in equip position's parent.", binder.equipTransform);
                    }
                }
            }
        }
Exemple #3
0
        public override EquippableInventoryItem Equip(EquippableInventoryItem item, CharacterEquipmentTypeBinder binder, bool createCopy)
        {
            EquippableInventoryItem copy = item;

            if (createCopy)
            {
                copy = CreateDefaultCopy(item);
            }

            copy.transform.SetParent(binder.equipTransform.parent); // Same level

            //GameObject p = GameObject.FindGameObjectWithTag("Player");
            //Debug.Log(p.name);
            //p.GetComponent<PlayerMovement>().UpdateEquippedGear();

            copy.transform.SetSiblingIndex(binder.equipTransform.GetSiblingIndex());
            binder.equipTransform.gameObject.SetActive(false); // Swap the item by disabling the original

            copy.transform.localPosition = copy.equipmentPosition;
            copy.transform.localRotation = copy.equipmentRotation;

            HandleSkinnedMeshes(copy, binder);
            HandleClothMeshes(copy, binder);

            return(copy);
        }
 public override void UnEquip(CharacterEquipmentTypeBinder binder, bool deleteItem)
 {
     binder.equipTransform.gameObject.SetActive(true); // Re-enable the original
     if (deleteItem)
     {
         UnityEngine.Object.Destroy(binder.currentItem);
     }
 }
 protected virtual void UnEquipItemVisually(EquippableInventoryItem item, CharacterEquipmentTypeBinder binder)
 {
     if (binder != null && binder.currentItem != null)
     {
         var t = GetEquippableTypeFromItem(binder, item);
         t.equipmentHandler.UnEquip(binder, true);
         NotifyItemUnEquippedVisually(binder, item);
     }
 }
        private void NotifyItemUnEquippedVisually(CharacterEquipmentTypeBinder binder, EquippableInventoryItem item)
        {
            Assert.IsNotNull(item);
            Assert.IsNotNull(binder);

            if (OnUnEquippedVisually != null)
            {
                OnUnEquippedVisually(binder, item);
            }

            item.NotifyItemUnEquippedVisually(binder);
        }
        public override EquippableInventoryItem Equip(EquippableInventoryItem item, CharacterEquipmentTypeBinder binder, bool createCopy)
        {
            EquippableInventoryItem copy = item;

            if (createCopy)
            {
                copy = CreateDefaultCopy(item);
            }

            copy.transform.SetParent(binder.equipTransform);
            copy.transform.localPosition = copy.equipmentPosition;
            copy.transform.localRotation = copy.equipmentRotation;

            HandleSkinnedMeshes(copy, binder);
            HandleClothMeshes(copy, binder);

            return(copy);
        }
        protected virtual void HandleClothMeshes(EquippableInventoryItem copy, CharacterEquipmentTypeBinder binder)
        {
            if (binder.equipTransform == null)
            {
                return;
            }

            var cloth = copy.GetComponent <Cloth>();

            if (cloth != null)
            {
                if (copyCapsuleColliders)
                {
                    cloth.capsuleColliders = binder.equipTransform.GetComponentsInParent <CapsuleCollider>();
                }

                cloth.ClearTransformMotion();
            }
        }
        public override EquippableInventoryItem Equip(EquippableInventoryItem item, CharacterEquipmentTypeBinder binder, bool createCopy)
        {
            EquippableInventoryItem copy = item;
            if (createCopy)
            {
                copy = CreateDefaultCopy(item);
            }

            copy.transform.SetParent(binder.equipTransform.parent); // Same level
            copy.transform.SetSiblingIndex(binder.equipTransform.GetSiblingIndex());
            binder.equipTransform.gameObject.SetActive(false); // Swap the item by disabling the original

            copy.transform.localPosition = copy.equipmentPosition;
            copy.transform.localRotation = copy.equipmentRotation;

            HandleSkinnedMeshes(copy, binder);
            HandleClothMeshes(copy, binder);

            return copy;
        }
Exemple #10
0
 /// <summary>
 /// Called when the item is equipped visually / bound to a mesh.
 /// Useful if you wish to remove a custom component whenever the item is equipped.
 /// </summary>
 public virtual void NotifyItemUnEquippedVisually(CharacterEquipmentTypeBinder binder)
 {
 }
 private EquipmentType GetEquippableTypeFromItem(CharacterEquipmentTypeBinder binder, EquippableInventoryItem item)
 {
     return(binder.equippableSlot.equipmentTypes.FirstOrDefault(o => o == item.equipmentType));
 }
 public abstract void UnEquip(CharacterEquipmentTypeBinder binder, bool deleteItem);
 public abstract EquippableInventoryItem Equip(EquippableInventoryItem item, CharacterEquipmentTypeBinder binder, bool createCopy);