コード例 #1
0
    // Token: 0x060001E9 RID: 489 RVA: 0x000087AC File Offset: 0x000069AC
    public Joint AddJoint(Transform root, ref global::AuthorChHit.Rep self)
    {
        Joint result;

        switch (this.kind)
        {
        case global::AuthorChJoint.Kind.Hinge:
        {
            HingeJoint hingeJoint = this.CreateJoint <HingeJoint>(root, ref self);
            hingeJoint.limits    = this.limit;
            hingeJoint.useLimits = this.useLimit;
            hingeJoint.motor     = this.motor;
            hingeJoint.useMotor  = this.useMotor;
            hingeJoint.spring    = this.spring;
            hingeJoint.useSpring = this.useSpring;
            result = hingeJoint;
            break;
        }

        case global::AuthorChJoint.Kind.Character:
        {
            CharacterJoint characterJoint = this.CreateJoint <CharacterJoint>(root, ref self);
            characterJoint.swingAxis      = self.AxisFlip(this.swingAxis);
            characterJoint.lowTwistLimit  = this.lowTwist;
            characterJoint.highTwistLimit = this.highTwist;
            characterJoint.lowTwistLimit  = this.lowTwist;
            characterJoint.swing1Limit    = this.swing1;
            characterJoint.swing2Limit    = this.swing2;
            result = characterJoint;
            break;
        }

        case global::AuthorChJoint.Kind.Fixed:
        {
            FixedJoint fixedJoint = this.CreateJoint <FixedJoint>(root, ref self);
            result = fixedJoint;
            break;
        }

        case global::AuthorChJoint.Kind.Spring:
        {
            SpringJoint springJoint = this.CreateJoint <SpringJoint>(root, ref self);
            springJoint.spring      = this.spring_spring;
            springJoint.damper      = this.spring_damper;
            springJoint.minDistance = this.spring_min;
            springJoint.maxDistance = this.spring_max;
            result = springJoint;
            break;
        }

        default:
            return(null);
        }
        return(result);
    }
コード例 #2
0
 // Token: 0x060001E6 RID: 486 RVA: 0x00008668 File Offset: 0x00006868
 private void ConfigureJointShared(Joint joint, Transform root, ref global::AuthorChHit.Rep self)
 {
     if (this.connect)
     {
         global::AuthorChHit.Rep rep;
         if (self.mirrored)
         {
             rep = this.connect.secondary;
             if (!rep.valid)
             {
                 rep = this.connect.primary;
             }
         }
         else
         {
             rep = this.connect.primary;
             if (!rep.valid)
             {
                 rep = this.connect.secondary;
             }
         }
         if (rep.valid)
         {
             Transform transform = root.FindChild(rep.path);
             Rigidbody rigidbody = transform.rigidbody;
             if (!rigidbody)
             {
                 rigidbody = transform.gameObject.AddComponent <Rigidbody>();
             }
             joint.connectedBody = rigidbody;
         }
         else
         {
             Debug.LogWarning("No means of making/getting rigidbody", this.connect);
         }
     }
     joint.anchor      = self.Flip(this.anchor);
     joint.axis        = self.AxisFlip(this.axis);
     joint.breakForce  = this.breakForce;
     joint.breakTorque = this.breakTorque;
 }
コード例 #3
0
    // Token: 0x060001EA RID: 490 RVA: 0x000088F0 File Offset: 0x00006AF0
    private bool DoTransformHandles(ref global::AuthorChHit.Rep self, ref global::AuthorChHit.Rep connect)
    {
        if (!self.valid)
        {
            return(false);
        }
        Vector3   v       = self.Flip(this.anchor);
        Vector3   vector  = self.AxisFlip(this.axis);
        Vector3   vector2 = self.AxisFlip(this.swingAxis);
        Matrix4x4 matrix  = global::AuthorShared.Scene.matrix;

        if (connect.valid)
        {
            global::AuthorShared.Scene.matrix = connect.bone.localToWorldMatrix;
            Color color = global::AuthorShared.Scene.color;
            global::AuthorShared.Scene.color = color * new Color(1f, 1f, 1f, 0.4f);
            Vector3 vector3 = connect.bone.InverseTransformPoint(self.bone.position);
            if (vector3 != Vector3.zero)
            {
                global::AuthorShared.Scene.DrawBone(Vector3.zero, Quaternion.LookRotation(vector3), vector3.magnitude, 0.02f, new Vector3(0.05f, 0.05f, 0.5f));
            }
            global::AuthorShared.Scene.color = color;
        }
        global::AuthorShared.Scene.matrix = self.bone.localToWorldMatrix;
        bool result = false;

        if (global::AuthorShared.Scene.PivotDrag(ref v, ref vector))
        {
            result      = true;
            this.anchor = self.Flip(v);
            this.axis   = self.AxisFlip(vector);
        }
        global::AuthorChJoint.Kind kind = this.kind;
        if (kind != global::AuthorChJoint.Kind.Hinge)
        {
            if (kind == global::AuthorChJoint.Kind.Character)
            {
                Color color2 = global::AuthorShared.Scene.color;
                global::AuthorShared.Scene.color = color2 * global::AuthorChJoint.twistColor;
                SoftJointLimit softJointLimit = this.lowTwist;
                SoftJointLimit highTwist      = this.highTwist;
                if (global::AuthorShared.Scene.LimitDrag(v, vector, ref this.twistOffset, ref softJointLimit, ref highTwist))
                {
                    result         = true;
                    this.lowTwist  = softJointLimit;
                    this.highTwist = highTwist;
                }
                global::AuthorShared.Scene.color = color2 * global::AuthorChJoint.swing1Color;
                softJointLimit = this.swing1;
                if (global::AuthorShared.Scene.LimitDrag(v, vector2, ref this.swingOffset1, ref softJointLimit))
                {
                    result      = true;
                    this.swing1 = softJointLimit;
                }
                global::AuthorShared.Scene.color = color2 * global::AuthorChJoint.swing2Color;
                softJointLimit = this.swing2;
                if (global::AuthorShared.Scene.LimitDrag(v, Vector3.Cross(vector2, vector), ref this.swingOffset2, ref softJointLimit))
                {
                    result      = true;
                    this.swing2 = softJointLimit;
                }
                global::AuthorShared.Scene.color = color2;
            }
        }
        else if (this.useLimit)
        {
            JointLimits limit = this.limit;
            if (global::AuthorShared.Scene.LimitDrag(v, vector, ref this.limitOffset, ref limit))
            {
                result     = true;
                this.limit = limit;
            }
        }
        global::AuthorShared.Scene.matrix = matrix;
        return(result);
    }