Ejemplo n.º 1
0
    // Start is called before the first frame update
    void Start()
    {
        for (int i = 0; i < jointCount; i++)
        {
            Vector2 position = Vector2.Lerp(begin.transform.position, end.transform.position, (float)i / ((float)jointCount - 1f));
            var     obj      = Instantiate(baseString, position, Quaternion.identity, stringParent);
            m_strings.Add(obj.transform);
            if (i != 0)
            {
                var joint = m_strings[i - 1].GetComponent <HingeJoint2D>();
                joint.connectedBody = obj.GetComponent <Rigidbody2D>();
            }
            else
            {
                begin.connectedBody = obj.GetComponent <Rigidbody2D>();
            }
        }
        end.connectedBody = begin.GetComponent <Rigidbody2D>();

        // m_strings[0].GetComponent<Rigidbody2D>().isKinematic=true;

        m_line.material      = new Material(Shader.Find("Unlit/Color"));
        m_line.positionCount = m_strings.Count;
        m_line.startWidth    = lineWidth;
        m_line.endWidth      = lineWidth;
        baseString.SetActive(false);
    }
Ejemplo n.º 2
0
        public new void OnSceneGUI()
        {
            HingeJoint2D hingeJoint2D = (HingeJoint2D)base.target;

            if (hingeJoint2D.enabled)
            {
                if (hingeJoint2D.useLimits)
                {
                    Vector3 vector   = Joint2DEditor.TransformPoint(hingeJoint2D.transform, hingeJoint2D.anchor);
                    float   num      = Mathf.Min(hingeJoint2D.limits.min, hingeJoint2D.limits.max);
                    float   num2     = Mathf.Max(hingeJoint2D.limits.min, hingeJoint2D.limits.max);
                    float   angle    = num2 - num;
                    float   num3     = HandleUtility.GetHandleSize(vector) * 0.8f;
                    float   rotation = hingeJoint2D.GetComponent <Rigidbody2D>().rotation;
                    Vector3 vector2  = Joint2DEditor.RotateVector2(Vector3.right, -num2 - rotation);
                    Vector3 end      = vector + Joint2DEditor.RotateVector2(Vector3.right, -hingeJoint2D.jointAngle - rotation) * num3;
                    Handles.color = new Color(0f, 1f, 0f, 0.7f);
                    Joint2DEditor.DrawAALine(vector, end);
                    Handles.color = new Color(0f, 1f, 0f, 0.03f);
                    Handles.DrawSolidArc(vector, Vector3.back, vector2, angle, num3);
                    Handles.color = new Color(0f, 1f, 0f, 0.7f);
                    Handles.DrawWireArc(vector, Vector3.back, vector2, angle, num3);
                    this.DrawTick(vector, num3, 0f, vector2, 1f);
                    this.DrawTick(vector, num3, angle, vector2, 1f);
                }
                base.OnSceneGUI();
            }
        }
Ejemplo n.º 3
0
        public new void OnSceneGUI()
        {
            HingeJoint2D target = (HingeJoint2D)this.target;

            if (!target.enabled)
            {
                return;
            }
            if (target.useLimits)
            {
                Vector3 vector3_1 = Joint2DEditor.TransformPoint(target.transform, (Vector3)target.anchor);
                float   num1      = Mathf.Min(target.limits.min, target.limits.max);
                float   num2      = Mathf.Max(target.limits.min, target.limits.max);
                float   angle     = num2 - num1;
                float   radius    = HandleUtility.GetHandleSize(vector3_1) * 0.8f;
                float   rotation  = target.GetComponent <Rigidbody2D>().rotation;
                Vector3 vector3_2 = (Vector3)Joint2DEditor.RotateVector2((Vector2)Vector3.right, -num2 - rotation);
                Vector3 end       = vector3_1 + (Vector3)(Joint2DEditor.RotateVector2((Vector2)Vector3.right, -target.jointAngle - rotation) * radius);
                Handles.color = new Color(0.0f, 1f, 0.0f, 0.7f);
                Joint2DEditor.DrawAALine(vector3_1, end);
                Handles.color = new Color(0.0f, 1f, 0.0f, 0.03f);
                Handles.DrawSolidArc(vector3_1, Vector3.back, vector3_2, angle, radius);
                Handles.color = new Color(0.0f, 1f, 0.0f, 0.7f);
                Handles.DrawWireArc(vector3_1, Vector3.back, vector3_2, angle, radius);
                this.DrawTick(vector3_1, radius, 0.0f, vector3_2, 1f);
                this.DrawTick(vector3_1, radius, angle, vector3_2, 1f);
            }
            base.OnSceneGUI();
        }
Ejemplo n.º 4
0
        public void OnSceneGUI()
        {
            HingeJoint2D target = (HingeJoint2D)this.target;

            if (target.enabled)
            {
                if (target.useLimits)
                {
                    Vector3 position = Joint2DEditorBase.TransformPoint(target.transform, (Vector3)target.anchor);
                    float   num      = Mathf.Min(target.limits.min, target.limits.max);
                    float   num2     = Mathf.Max(target.limits.min, target.limits.max);
                    float   angle    = num2 - num;
                    float   radius   = HandleUtility.GetHandleSize(position) * 0.8f;
                    float   rotation = target.GetComponent <Rigidbody2D>().rotation;
                    Vector3 from     = (Vector3)Joint2DEditorBase.RotateVector2(Vector3.right, -num2 - rotation);
                    Vector3 end      = position + ((Vector3)(Joint2DEditorBase.RotateVector2(Vector3.right, -target.jointAngle - rotation) * radius));
                    Handles.color = new Color(0f, 1f, 0f, 0.7f);
                    Joint2DEditorBase.DrawAALine(position, end);
                    Handles.color = new Color(0f, 1f, 0f, 0.03f);
                    Handles.DrawSolidArc(position, Vector3.back, from, angle, radius);
                    Handles.color = new Color(0f, 1f, 0f, 0.7f);
                    Handles.DrawWireArc(position, Vector3.back, from, angle, radius);
                    this.DrawTick(position, radius, 0f, from, 1f);
                    this.DrawTick(position, radius, angle, from, 1f);
                }
                base.OnSceneGUI();
            }
        }
Ejemplo n.º 5
0
    void GenerateLinks()
    {
        for (int i = chainStart.childCount - 1; i >= 0; i--)
        {
            DestroyImmediate(chainStart.GetChild(i).gameObject);
        }

        chains = new HingeJoint2D[numChains];

        Vector2 chainPos = Vector2.zero;

        for (int i = 0; i < numChains; i++)
        {
            chains[i] = Instantiate(chainPrefab);
            chains[i].transform.parent   = chainStart;
            chains[i].transform.position = chainStart.position - (chainStart.up * i * chainLength);
        }

        for (int i = 0; i < numChains - 1; i++)
        {
            chains[i].connectedBody = chains[i + 1].GetComponent <Rigidbody2D>();
        }

        ballObject.connectedBody = chains[0].GetComponent <Rigidbody2D>();
        ballObject.GetComponent <DistanceJoint2D>().connectedBody          = ballObject.connectedBody;
        chains[chains.Length - 1].GetComponent <Rigidbody2D>().isKinematic = true;
        chains[chains.Length - 1].enabled = false;
    }
Ejemplo n.º 6
0
        private void CreateSegments(Vector3 targetPos)
        {
            // first link connects to us
            Rigidbody2D previousLink = GetComponent <Rigidbody2D>();
            //int numSegments = Mathf.CeilToInt((targetPos - mouth.position).magnitude / tongueLength);
            int numSegments = Mathf.RoundToInt((targetPos - mouth.position).magnitude / tongueLength);

            // always make at least a few segments, otherwise things get weird
            numSegments = Mathf.Max(numSegments, minSegments);
            // figure out the angle between us and the target, and set positionOffset accordingly
            Vector3 offset = targetPos - mouth.position;
            float   angle  = Mathf.Rad2Deg * Mathf.Atan(offset.y / offset.x);

            if (targetPos.x - mouth.position.x < 0)
            {
                angle += 180;
            }
            Vector3    positionOffset = new Vector3(tongueLength, 0f, 0);
            Quaternion rot            = Quaternion.Euler(new Vector3(0, 0, angle));

            positionOffset = rot * positionOffset;
            links          = new TongueLink[numSegments];
            for (int i = 0; i < numSegments; i++)
            {
                Vector3 pos = (Vector3)previousLink.position;
                if (i != 0)
                {
                    pos += positionOffset;
                }
                GameObject   obj   = Instantiate(tongueLinkPrefab.gameObject, pos, rot) as GameObject;
                HingeJoint2D joint = obj.GetComponent <HingeJoint2D>();
                joint.connectedBody = previousLink;
                if (i == 0)
                {
                    // first link attaches to us at a different position.
                    // Set the anchor, and move the position to it
                    joint.connectedAnchor = mouth.transform.localPosition;
                    // move the segment so the anchor and connectedAnchor overlap
                    Vector3 tmpAnchor = Vector3.Scale(Quaternion.Euler(0, 0, previousLink.rotation) * (Vector3)joint.connectedAnchor, previousLink.transform.localScale) - (Vector3)joint.anchor;
                    joint.transform.position = (Vector3)previousLink.position + tmpAnchor;
                }
                previousLink        = joint.GetComponent <Rigidbody2D>();
                links[i]            = joint.GetComponent <TongueLink>();
                links[i].segmentNum = i;
            }
        }
Ejemplo n.º 7
0
 private void Awake()
 {
     if (joint == null)
     {
         joint = GetComponent <HingeJoint2D>();
     }
     _jointRigidbody = joint.GetComponent <Rigidbody2D>();
 }
Ejemplo n.º 8
0
 // Use this for initialization
 void Start()
 {
     rb2d2.GetComponent <Rigidbody2D>();
     hinge2D2.GetComponent <HingeJoint2D>();
     motorRef            = hinge2D2.motor;
     hinge2D2.useMotor   = true;
     motorRef.motorSpeed = -500;
     hinge2D2.motor      = motorRef;
 }
Ejemplo n.º 9
0
    public void                                     AddNode()
    {
        GameObject   tmp;
        HingeJoint2D lastJoint = this.joints[this.joints.Count - 1];
        HingeJoint2D currentJoint;

        if (this.currentSize + 1 > this.maxSize)
        {
            return;
        }
        this.GrowthAudio.Play(this.audioSource);
        tmp = Instantiate(nodePrefab, Vector3.zero, Quaternion.identity);
        tmp.GetComponent <SpriteRenderer>().sprite = this.skin.head;
        tmp.transform.SetParent(this.transform);
        tmp.transform.position = lastJoint.transform.position;
        if (this.joints.Count > 1)
        {
            tmp.transform.position += lastJoint.transform.up * distance;
        }
        tmp.transform.up           = lastJoint.transform.up;
        currentJoint               = tmp.GetComponentInChildren <HingeJoint2D>();
        currentJoint.connectedBody = lastJoint.GetComponent <Rigidbody2D>();
        ++controlledNodes; // maybe not
        lastJoint.GetComponent <SpriteRenderer>().sprite = (this.joints.Count == 1 ? this.skin.sprout : this.skin.stem);
        Destroy(lastJoint.GetComponent <PolygonCollider2D>());
        Destroy(lastJoint.GetComponent <Leaf>());
        this.head = currentJoint;
        this.head.gameObject.AddComponent <PolygonCollider2D>();
        this.head.gameObject.AddComponent <Leaf>().Initialize(this, this.waterAmount, this.pollenAmount);
        this.joints.Add(currentJoint);
        if (Random.Range(0, 100) < this.leafProbability || ++this.noLeafSince > this.maximalLeafGap)
        {
            GameObject leaf = Instantiate(leafPrefab, Vector3.zero, Quaternion.identity);
            leaf.GetComponent <SpriteRenderer>().sprite = (Random.Range(0, 2) % 2 == 0 ? this.skin.leftLeaf : this.skin.rightLeaf);
            leaf.GetComponent <Leaf>().Initialize(this);
            leaf.transform.parent        = currentJoint.transform;
            leaf.transform.localPosition = Vector3.zero;
            this.noLeafSince             = 0;
        }
        ++this.currentSize;
        this.SkinMutation();
    }
Ejemplo n.º 10
0
 void Start()
 {
     ball.autoConfigureConnectedAnchor = false;
     chainLink     = new Rigidbody2D[chainLinks + 1];
     chainLink [0] = baseJoint.attachedRigidbody;
     CreateChain();
     ball.connectedBody   = chainLink [chainLinks];
     ball.connectedAnchor = Vector2.up * linkDistance;
     //Don'n even ask why, just worked this way
     ball.GetComponent <Rigidbody2D> ().AddForce(Vector2.right * 800);
 }
Ejemplo n.º 11
0
    public void removeLink()
    {
/*        if (top.gameObject.GetComponent<RopeSegment>().isPlayerAttached)
 *      {
 *          player.Slide(-1);
 *      }*/
        HingeJoint2D newTop = top.gameObject.GetComponent <RopeSegment>().connectedBelow.GetComponent <HingeJoint2D>();

        newTop.connectedBody = hook;
        newTop.gameObject.transform.position = hook.gameObject.transform.position;
        newTop.GetComponent <RopeSegment>().ResetAnchor();
        Destroy(top.gameObject);
        top = newTop;
    }
Ejemplo n.º 12
0
 void CreateChain()
 {
     for (int i = 1; i <= chainLinks; i++)
     {
         GameObject zelda = Instantiate(chainLinkPrefab, transform);              // Link is too mainstream =P
         zelda.transform.localPosition = chainLink[i - 1].transform.localPosition + (Vector3.down * linkDistance);
         zelda.name = "ChainLink" + i.ToString();
         HingeJoint2D triforce = zelda.GetComponent <HingeJoint2D>(); // Let's steal the Triforce of wisdom for this to work!
         triforce.connectedBody = chainLink[i - 1];                   // Connect the triforce to previous hero of time
         triforce.autoConfigureConnectedAnchor = false;
         triforce.connectedAnchor = Vector2.down * linkDistance;
         chainLink [i]            = triforce.GetComponent <Rigidbody2D> ();
     }
 }
Ejemplo n.º 13
0
 // Update is called once per frame
 void Update()
 {
     if (mainCharacterJoint.GetComponent <ChainConnection>().IsCharacterAttachedToChain)
     {
         if (isRunningUp)
         {
             goUp();
         }
         else if (isRunningDown)
         {
             goDown();
         }
     }
 }
Ejemplo n.º 14
0
    public void addLink()
    {
        int        index   = Random.Range(0, prefabsRopeSegments.Length);
        GameObject newLink = Instantiate(prefabsRopeSegments[index]);

        newLink.transform.parent   = transform;
        newLink.transform.position = transform.position;
        HingeJoint2D hj = newLink.GetComponent <HingeJoint2D>();

        hj.connectedBody = hook;
        newLink.GetComponent <RopeSegment>().connectedBelow = top.gameObject;
        top.connectedBody = newLink.GetComponent <Rigidbody2D>();
        top.GetComponent <RopeSegment>().ResetAnchor();
        top = hj;
    }
Ejemplo n.º 15
0
 void Start()
 {
     //Paddle Left
     rb2d.GetComponent <Rigidbody2D>();
     hinge2D.GetComponent <HingeJoint2D>();
     motor            = hinge2D.motor;
     hinge2D.useMotor = true;
     motor.motorSpeed = 500;
     hinge2D.motor    = motor;
     //Paddle Right
     rb2d2.GetComponent <Rigidbody2D>();
     hinge2D2.GetComponent <HingeJoint2D>();
     motorRef            = hinge2D2.motor;
     hinge2D2.useMotor   = true;
     motorRef.motorSpeed = -500;
     hinge2D2.motor      = motorRef;
 }
Ejemplo n.º 16
0
    private void GenerateRope()
    {
        Rigidbody2D previousLink = hook.GetComponent <Rigidbody2D>();

        for (int i = 0; i < links; i++)
        {
            GameObject link = Instantiate(linkPrefab, this.transform);

            link.GetComponent <HingeJoint2D>().connectedBody = previousLink;

            if (i < links - 1)
            {
                previousLink = link.GetComponent <Rigidbody2D>();
            }
            else
            {
                weight.ConnectRopeEnd(link.GetComponent <Rigidbody2D>());
            }
        }
    }
Ejemplo n.º 17
0
    private void CreateRope(int numLinks, Rigidbody2D prevBody, float len, Vector2 offset, bool leaveLast, Rigidbody2D endRB)
    {
        if (numLinks == 0)
        {
            return;
        }
        HingeJoint2D newLink = Instantiate(link, prevBody.transform.position + ((Vector3)offset.normalized * len), Quaternion.identity, transform).GetComponent <HingeJoint2D>();

        newLink.connectedBody   = prevBody;
        newLink.connectedAnchor = offset.normalized * len;

        linePath[numLinks - 1] = newLink.transform;
        if (leaveLast && numLinks == 1)
        {
            HingeJoint2D newJoint = newLink.gameObject.AddComponent <HingeJoint2D>();
            newJoint.connectedBody   = endRB;
            newJoint.connectedAnchor = endRB.transform.InverseTransformPoint(hook.position);
        }
        CreateRope(numLinks - 1, newLink.GetComponent <Rigidbody2D>(), len, offset, leaveLast, endRB);
    }
Ejemplo n.º 18
0
    void GenerateRope()
    {
        Rigidbody2D previousRB = hook;
        GameObject  lastPos    = hook.transform.gameObject;

        for (int i = 0; i < links; i++)
        {
            GameObject   link  = Instantiate(pref, transform);
            HingeJoint2D joint = link.GetComponent <HingeJoint2D>();
            joint.connectedBody = previousRB;
            joint.GetComponent <Line_Info>().PreviousPoint = lastPos;
            if (i < links - 1)
            {
                lastPos    = link.gameObject;
                previousRB = link.GetComponent <Rigidbody2D>();
            }
            else
            {
                weight.ConnectRopeEnd(link.GetComponent <Rigidbody2D>());
            }
        }
    }
Ejemplo n.º 19
0
 void FixedUpdate()
 {
     //Drag while the mouse is held down
     if (Input.GetMouseButton(0))
     {
         if (currentlyDraggedTransform != null && currentlyDraggedRigidbody != null && currentlyDraggedJoint != null)
         {
             if (snapToCenter)
             {
                 currentlyDraggedJoint.connectedAnchor = Vector2.Lerp(currentlyDraggedJoint.connectedAnchor, Vector2.zero, snapSpeed * Time.deltaTime);
             }
             Vector3 mouseCoords  = Input.mousePosition;
             Vector3 objectCoords = GetComponent <Camera>().WorldToScreenPoint(currentlyDraggedJoint.transform.position);
             float   distance     = Vector2.Distance(objectCoords, mouseCoords);
             Vector2 vector       = (mouseCoords - objectCoords).normalized * (distance / dragDamping);
             if (relativeToRigidbody != null)
             {
                 vector += relativeToRigidbody.velocity;
             }
             currentlyDraggedJoint.GetComponent <Rigidbody2D>().velocity = vector;
         }
     }
 }
Ejemplo n.º 20
0
 // Use this for initialization
 void Start()
 {
     armRigidbody  = arm.GetComponent <Rigidbody2D>();
     rotbRigidbody = restOfTheBody.GetComponent <Rigidbody2D>();
 }
Ejemplo n.º 21
0
    private void CalculateWalkingMotorAngularSpeed()
    {
        float footRadius = walkMotor.GetComponent <CircleCollider2D>().radius;

        motorMaxAngularSpeed = Mathf.Rad2Deg * maxWalkingSpeed / footRadius;
    }
Ejemplo n.º 22
0
        public void Apply()
        {
            this.isActive = true;
            this.mix      = 1f;
            Bone bone2 = this.skeleton.FindBone(this.startingBoneName);

            this.StartingBone = bone2;
            Bone b = bone2;

            this.RecursivelyCreateBoneProxies(b);
            this.RootRigidbody             = this.boneTable[b].GetComponent <Rigidbody2D>();
            this.RootRigidbody.isKinematic = this.pinStartBone;
            this.RootRigidbody.mass        = this.rootMass;
            List <Collider2D> list = new List <Collider2D>();

            foreach (KeyValuePair <Bone, Transform> pair in this.boneTable)
            {
                Transform ragdollRoot;
                Bone      key       = pair.Key;
                Transform transform = pair.Value;
                list.Add(transform.GetComponent <Collider2D>());
                if (key == b)
                {
                    this.ragdollRoot = new GameObject("RagdollRoot").transform;
                    this.ragdollRoot.SetParent(base.transform, false);
                    if (key == this.skeleton.RootBone)
                    {
                        this.ragdollRoot.localPosition = new Vector3(key.WorldX, key.WorldY, 0f);
                        this.ragdollRoot.localRotation = Quaternion.Euler(0f, 0f, GetPropagatedRotation(key));
                    }
                    else
                    {
                        this.ragdollRoot.localPosition = new Vector3(key.Parent.WorldX, key.Parent.WorldY, 0f);
                        this.ragdollRoot.localRotation = Quaternion.Euler(0f, 0f, GetPropagatedRotation(key.Parent));
                    }
                    ragdollRoot     = this.ragdollRoot;
                    this.rootOffset = transform.position - base.transform.position;
                }
                else
                {
                    ragdollRoot = this.boneTable[key.Parent];
                }
                Rigidbody2D component = ragdollRoot.GetComponent <Rigidbody2D>();
                if (component != null)
                {
                    HingeJoint2D jointd = transform.gameObject.AddComponent <HingeJoint2D>();
                    jointd.connectedBody = component;
                    Vector3 vector = ragdollRoot.InverseTransformPoint(transform.position);
                    jointd.connectedAnchor = vector;
                    jointd.GetComponent <Rigidbody2D>().mass = jointd.connectedBody.mass * this.massFalloffFactor;
                    JointAngleLimits2D limitsd = new JointAngleLimits2D {
                        min = -this.rotationLimit,
                        max = this.rotationLimit
                    };
                    jointd.limits    = limitsd;
                    jointd.useLimits = true;
                }
            }
            for (int i = 0; i < list.Count; i++)
            {
                for (int j = 0; j < list.Count; j++)
                {
                    if (i != j)
                    {
                        Physics2D.IgnoreCollision(list[i], list[j]);
                    }
                }
            }
            SkeletonUtilityBone[] componentsInChildren = base.GetComponentsInChildren <SkeletonUtilityBone>();
            if (componentsInChildren.Length > 0)
            {
                List <string> list2 = new List <string>();
                foreach (SkeletonUtilityBone bone4 in componentsInChildren)
                {
                    if (bone4.mode == SkeletonUtilityBone.Mode.Override)
                    {
                        list2.Add(bone4.gameObject.name);
                        UnityEngine.Object.Destroy(bone4.gameObject);
                    }
                }
                if (list2.Count > 0)
                {
                    string message = "Destroyed Utility Bones: ";
                    for (int j = 0; j < list2.Count; j++)
                    {
                        message = message + list2[j];
                        if (j != (list2.Count - 1))
                        {
                            message = message + ",";
                        }
                    }
                    UnityEngine.Debug.LogWarning(message);
                }
            }
            if (this.disableIK)
            {
                ExposedList <IkConstraint> ikConstraints = this.skeleton.IkConstraints;
                int index = 0;
                int count = ikConstraints.Count;
                while (index < count)
                {
                    ikConstraints.Items[index].mix = 0f;
                    index++;
                }
            }
            if (this.disableOtherConstraints)
            {
                ExposedList <TransformConstraint> transformConstraints = this.skeleton.transformConstraints;
                int index = 0;
                int count = transformConstraints.Count;
                while (index < count)
                {
                    transformConstraints.Items[index].rotateMix    = 0f;
                    transformConstraints.Items[index].scaleMix     = 0f;
                    transformConstraints.Items[index].shearMix     = 0f;
                    transformConstraints.Items[index].translateMix = 0f;
                    index++;
                }
                ExposedList <PathConstraint> pathConstraints = this.skeleton.pathConstraints;
                int num9  = 0;
                int num10 = pathConstraints.Count;
                while (num9 < num10)
                {
                    pathConstraints.Items[num9].rotateMix    = 0f;
                    pathConstraints.Items[num9].translateMix = 0f;
                    num9++;
                }
            }
            this.targetSkeletonComponent.UpdateWorld += new UpdateBonesDelegate(this.UpdateSpineSkeleton);
        }
Ejemplo n.º 23
0
        public void Apply()
        {
            this.isActive = true;
            this.mix      = 1f;
            Bone bone = this.skeleton.FindBone(this.startingBoneName);

            this.StartingBone = bone;
            Bone bone2 = bone;

            this.RecursivelyCreateBoneProxies(bone2);
            this.RootRigidbody             = this.boneTable[bone2].GetComponent <Rigidbody2D>();
            this.RootRigidbody.isKinematic = this.pinStartBone;
            this.RootRigidbody.mass        = this.rootMass;
            List <Collider2D> list = new List <Collider2D>();

            foreach (KeyValuePair <Bone, Transform> keyValuePair in this.boneTable)
            {
                Bone      key   = keyValuePair.Key;
                Transform value = keyValuePair.Value;
                list.Add(value.GetComponent <Collider2D>());
                Transform transform;
                if (key == bone2)
                {
                    this.ragdollRoot = new GameObject("RagdollRoot").transform;
                    this.ragdollRoot.SetParent(base.transform, false);
                    if (key == this.skeleton.RootBone)
                    {
                        this.ragdollRoot.localPosition = new Vector3(key.WorldX, key.WorldY, 0f);
                        this.ragdollRoot.localRotation = Quaternion.Euler(0f, 0f, SkeletonRagdoll2D.GetPropagatedRotation(key));
                    }
                    else
                    {
                        this.ragdollRoot.localPosition = new Vector3(key.Parent.WorldX, key.Parent.WorldY, 0f);
                        this.ragdollRoot.localRotation = Quaternion.Euler(0f, 0f, SkeletonRagdoll2D.GetPropagatedRotation(key.Parent));
                    }
                    transform       = this.ragdollRoot;
                    this.rootOffset = value.position - base.transform.position;
                }
                else
                {
                    transform = this.boneTable[key.Parent];
                }
                Rigidbody2D component = transform.GetComponent <Rigidbody2D>();
                if (component != null)
                {
                    HingeJoint2D hingeJoint2D = value.gameObject.AddComponent <HingeJoint2D>();
                    hingeJoint2D.connectedBody = component;
                    Vector3 v = transform.InverseTransformPoint(value.position);
                    hingeJoint2D.connectedAnchor = v;
                    hingeJoint2D.GetComponent <Rigidbody2D>().mass = hingeJoint2D.connectedBody.mass * this.massFalloffFactor;
                    hingeJoint2D.limits = new JointAngleLimits2D
                    {
                        min = -this.rotationLimit,
                        max = this.rotationLimit
                    };
                    hingeJoint2D.useLimits = true;
                }
            }
            for (int i = 0; i < list.Count; i++)
            {
                for (int j = 0; j < list.Count; j++)
                {
                    if (i != j)
                    {
                        Physics2D.IgnoreCollision(list[i], list[j]);
                    }
                }
            }
            SkeletonUtilityBone[] componentsInChildren = base.GetComponentsInChildren <SkeletonUtilityBone>();
            if (componentsInChildren.Length > 0)
            {
                List <string> list2 = new List <string>();
                foreach (SkeletonUtilityBone skeletonUtilityBone in componentsInChildren)
                {
                    if (skeletonUtilityBone.mode == SkeletonUtilityBone.Mode.Override)
                    {
                        list2.Add(skeletonUtilityBone.gameObject.name);
                        UnityEngine.Object.Destroy(skeletonUtilityBone.gameObject);
                    }
                }
                if (list2.Count > 0)
                {
                    string str = "Destroyed Utility Bones: ";
                    for (int l = 0; l < list2.Count; l++)
                    {
                        str += list2[l];
                        if (l != list2.Count - 1)
                        {
                            str += ",";
                        }
                    }
                }
            }
            if (this.disableIK)
            {
                ExposedList <IkConstraint> ikConstraints = this.skeleton.IkConstraints;
                int m     = 0;
                int count = ikConstraints.Count;
                while (m < count)
                {
                    ikConstraints.Items[m].mix = 0f;
                    m++;
                }
            }
            if (this.disableOtherConstraints)
            {
                ExposedList <TransformConstraint> transformConstraints = this.skeleton.transformConstraints;
                int n      = 0;
                int count2 = transformConstraints.Count;
                while (n < count2)
                {
                    transformConstraints.Items[n].rotateMix    = 0f;
                    transformConstraints.Items[n].scaleMix     = 0f;
                    transformConstraints.Items[n].shearMix     = 0f;
                    transformConstraints.Items[n].translateMix = 0f;
                    n++;
                }
                ExposedList <PathConstraint> pathConstraints = this.skeleton.pathConstraints;
                int num    = 0;
                int count3 = pathConstraints.Count;
                while (num < count3)
                {
                    pathConstraints.Items[num].rotateMix    = 0f;
                    pathConstraints.Items[num].translateMix = 0f;
                    num++;
                }
            }
            this.targetSkeletonComponent.UpdateWorld += this.UpdateSpineSkeleton;
        }