public GameObject BuildCharacter(GameObject characterContainer, PartsManager caller = null)
    {
        SetEquippedUsingIndex(equip.equippedParts);

        if (currentTorsoPrefab == null)
        {
            return(null);
        }

        GameObject ad = Instantiate(currentTorsoPrefab, characterContainer.transform, false);

        ad.transform.localPosition = Vector3.zero;
        if (caller != null)
        {
            caller.TorsoEquipped = ad.GetComponent <TorsoPart>();
        }

        TorsoPart parent = ad.GetComponent <TorsoPart>();

        if (currentHeadPrefab != null)
        {
            GameObject adding = Instantiate(currentHeadPrefab, parent.neckForHead.transform, false);
            adding.transform.localPosition = Vector3.zero;
            if (caller != null)
            {
                caller.headEquipped = adding.GetComponent <ItemPart>();
            }
        }

        if (currentLeftArmPrefab != null)
        {
            GameObject adding  = Instantiate(currentLeftArmPrefab, parent.LeftArmUpper.transform, false);
            ArmPart    armPart = adding.GetComponent <ArmPart>();
            armPart.EquipArm(parent, parent.LeftArmUpper, parent.LeftArmFore, parent.LeftArmHand);
            if (caller != null)
            {
                caller.leftArmEquipped = armPart;
            }
        }
        if (currentRightArmPrefab != null)
        {
            GameObject adding  = Instantiate(currentRightArmPrefab, parent.RightArmUpper.transform, false);
            ArmPart    armPart = adding.GetComponent <ArmPart>();

            armPart.EquipArm(parent, parent.RightArmUpper, parent.RightArmFore, parent.RightArmHand);
            if (caller != null)
            {
                caller.rightArmEquipped = armPart;
            }
        }


        if (currentLeftLegPrefab != null)
        {
            GameObject adding  = Instantiate(currentLeftLegPrefab, parent.LeftUpperThigh.transform, false);
            LegPart    legPart = adding.GetComponent <LegPart>();

            legPart.EquipLeg(parent.LeftUpperThigh, parent.Leftshin, parent.LefttAnkle, parent.LeftFoot);
            if (caller != null)
            {
                caller.leftLegEquipped = legPart;
            }
        }
        if (currentRightLegPrefab != null)
        {
            GameObject adding  = Instantiate(currentRightLegPrefab, parent.RightUpperThigh.transform, false);
            LegPart    legPart = adding.GetComponent <LegPart>();

            legPart.EquipLeg(parent.RightUpperThigh, parent.Rightshin, parent.RightAnkle, parent.RightFoot);
            if (caller != null)
            {
                caller.rightLegEquipped = legPart;
            }
        }

        if (parent.bodyType == BodyType.FourArm)
        {
            Debug.Log("Four");

            if (currentRightArmPrefab != null)
            {
                GameObject adding  = Instantiate(currentRightArmPrefab, parent.LowerRightArmUpper.transform, false);
                ArmPart    armPart = adding.GetComponent <ArmPart>();

                armPart.EquipArm(parent, parent.LowerRightArmUpper, parent.LowerRightArmFore, parent.LowerRightArmHand);
            }

            if (currentLeftArmPrefab != null)
            {
                GameObject adding  = Instantiate(currentLeftArmPrefab, parent.LowerLeftArmUpper.transform, false);
                ArmPart    armPart = adding.GetComponent <ArmPart>();

                armPart.EquipArm(parent, parent.LowerLeftArmUpper, parent.LowerLeftArmFore, parent.LowerLeftArmHand);
            }
        }
        return(ad);
    }
    public void addLimb()
    {
        combinedShop.Refresh = true;

        changed = true;

        GameObject adding;

        GameObject currentPart = combinedShop.currentPart; //The object, found at the index inside the list.

        int currentIndex = combinedShop.currentIndex;

        partType currentType = combinedShop.currentType;



        if (currentPart == null)
        {
            return;
        }


        if (currentType == partType.Torso)
        {
            addingTorso();
            return;
        }

        if (TorsoEquipped == null)
        {
            return;
        }

        switch (currentType)
        {
        case partType.Head:
            if (headEquipped != null && currentPart.name == headEquipped.gameObject.name)
            {
                return;
            }
            if (headEquipped != null)
            {
                Destroy(headEquipped.gameObject);
            }

            adding       = Instantiate(currentPart, TorsoEquipped.neckForHead.transform, false);
            headEquipped = adding.GetComponent <ItemPart>();
            list.ChangeEquip(currentPart, partType.Head, currentIndex);
            adding.name = currentPart.name;
            break;

        case partType.LeftArm:
            if (leftArmEquipped != null && currentPart.name == leftArmEquipped.gameObject.name)
            {
                return;
            }
            if (leftArmEquipped != null)
            {
                leftArmEquipped.deleteArm();
            }
            adding          = Instantiate(currentPart, TorsoEquipped.LeftArmUpper.transform, false);
            leftArmEquipped = adding.GetComponent <ArmPart>();
            leftArmEquipped.EquipArm(TorsoEquipped, TorsoEquipped.LeftArmUpper, TorsoEquipped.LeftArmFore, TorsoEquipped.LeftArmHand);

            adding.name = currentPart.name;
            list.ChangeEquip(currentPart, partType.LeftArm, currentIndex);
            adding = null;
            break;

        case partType.RightArm:
            if (rightArmEquipped != null && currentPart.name == rightArmEquipped.gameObject.name)
            {
                return;
            }
            if (rightArmEquipped != null)
            {
                rightArmEquipped.deleteArm();
            }
            adding = Instantiate(currentPart, TorsoEquipped.RightArmUpper.transform, false);


            rightArmEquipped = adding.GetComponent <ArmPart>();
            rightArmEquipped.EquipArm(TorsoEquipped, TorsoEquipped.RightArmUpper, TorsoEquipped.RightArmFore, TorsoEquipped.RightArmHand);


            adding.name = currentPart.name;
            list.ChangeEquip(currentPart, partType.RightArm, currentIndex);
            adding = null;
            break;

        case partType.LeftLeg:
            if (leftLegEquipped != null && currentPart.name == leftLegEquipped.gameObject.name)
            {
                return;
            }
            if (leftLegEquipped != null)
            {
                leftLegEquipped.DeleteLeg();
            }
            adding          = Instantiate(currentPart, TorsoEquipped.RightUpperThigh.transform, false);
            leftLegEquipped = adding.GetComponent <LegPart>();
            leftLegEquipped.EquipLeg(TorsoEquipped.LeftUpperThigh, TorsoEquipped.Leftshin, TorsoEquipped.LefttAnkle, TorsoEquipped.LeftFoot);


            list.ChangeEquip(currentPart, partType.LeftLeg, currentIndex);
            adding.name = currentPart.name;
            adding      = null;
            break;

        case partType.RightLeg:
            if (rightLegEquipped != null && currentPart.name == rightLegEquipped.gameObject.name)
            {
            }
            if (rightLegEquipped != null)
            {
                rightLegEquipped.DeleteLeg();
            }
            adding           = Instantiate(currentPart, TorsoEquipped.RightUpperThigh.transform, false);
            rightLegEquipped = adding.GetComponent <LegPart>();
            rightLegEquipped.EquipLeg(TorsoEquipped.RightUpperThigh, TorsoEquipped.Rightshin, TorsoEquipped.RightAnkle, TorsoEquipped.RightFoot);


            list.ChangeEquip(currentPart, partType.RightLeg, currentIndex);
            adding.name = currentPart.name;
            adding      = null;
            break;

        default:
            break;
        }

        if (TorsoEquipped.bodyType == BodyType.FourArm)
        {
            Destroy(TorsoEquipped.gameObject);
            list.BuildCharacter(parentOfTorso, this);
            return;
        }
    }