Example #1
0
    private AuthorChJoint AddJoint(AuthorChJoint.Kind kind)
    {
        AuthorChJoint joint = base.creation.CreatePeice <AuthorChJoint>(kind.ToString(), new Type[0]);

        if (joint != null)
        {
            joint.InitializeFromOwner(this, kind);
            Array.Resize <AuthorChJoint>(ref this.myJoints, (this.myJoints != null) ? (this.myJoints.Length + 1) : 1);
            this.myJoints[this.myJoints.Length - 1] = joint;
        }
        return(joint);
    }
Example #2
0
    public override bool PeiceInspectorGUI()
    {
        bool   flag = base.PeiceInspectorGUI();
        string str  = base.peiceID;

        if (AuthorShared.StringField("Title", ref str, new GUILayoutOption[0]))
        {
            base.peiceID = str;
            flag         = true;
        }
        AuthorShared.EnumField("Kind", this.kind, new GUILayoutOption[0]);
        AuthorShared.PrefixLabel("Self");
        if (GUILayout.Button(AuthorShared.ObjectContent <AuthorChHit>(this.self, typeof(AuthorChHit)), new GUILayoutOption[0]))
        {
            AuthorShared.PingObject(this.self);
        }
        flag = flag | AuthorShared.PeiceField <AuthorChHit>("Connected", this, ref this.connect, typeof(AuthorChHit), GUI.skin.button, new GUILayoutOption[0]);
        flag = flag | AuthorShared.Toggle("Reverse Link", ref this.reverseLink, new GUILayoutOption[0]);
        flag = flag | AuthorShared.Vector3Field("Anchor", ref this.anchor, new GUILayoutOption[0]);
        flag = flag | AuthorShared.Vector3Field("Axis", ref this.axis, new GUILayoutOption[0]);
        AuthorChJoint.Kind kind = this.kind;
        if (kind == AuthorChJoint.Kind.Hinge)
        {
            JointLimits jointLimit = this.limit;
            if (AuthorChJoint.Field("Limits", ref jointLimit, ref this.useLimit, ref this.limitOffset))
            {
                flag       = true;
                this.limit = jointLimit;
            }
        }
        else if (kind == AuthorChJoint.Kind.Character)
        {
            flag = flag | AuthorShared.Vector3Field("Swing Axis", ref this.swingAxis, new GUILayoutOption[0]);
            SoftJointLimit softJointLimit = this.lowTwist;
            if (AuthorChJoint.Field("Low Twist", ref softJointLimit, ref this.twistOffset))
            {
                flag          = true;
                this.lowTwist = softJointLimit;
            }
            softJointLimit = this.highTwist;
            if (AuthorChJoint.Field("High Twist", ref softJointLimit, ref this.twistOffset))
            {
                flag           = true;
                this.highTwist = softJointLimit;
            }
            softJointLimit = this.swing1;
            if (AuthorChJoint.Field("Swing 1", ref softJointLimit, ref this.swingOffset1))
            {
                flag        = true;
                this.swing1 = softJointLimit;
            }
            softJointLimit = this.swing2;
            if (AuthorChJoint.Field("Swing 2", ref softJointLimit, ref this.swingOffset2))
            {
                flag        = true;
                this.swing2 = softJointLimit;
            }
        }
        flag = flag | AuthorShared.FloatField("Break Force", ref this.breakForce, new GUILayoutOption[0]);
        flag = flag | AuthorShared.FloatField("Break Torque", ref this.breakTorque, new GUILayoutOption[0]);
        return(flag);
    }
Example #3
0
 internal void InitializeFromOwner(AuthorChHit self, AuthorChJoint.Kind kind)
 {
     this.self = self;
     this.kind = kind;
     AuthorShared.SetDirty(this);
 }
Example #4
0
    private bool DoTransformHandles(ref AuthorChHit.Rep self, ref AuthorChHit.Rep connect)
    {
        if (!self.valid)
        {
            return(false);
        }
        Vector3   vector3   = self.Flip(this.anchor);
        Vector3   vector31  = self.AxisFlip(this.axis);
        Vector3   vector32  = self.AxisFlip(this.swingAxis);
        Matrix4x4 matrix4x4 = AuthorShared.Scene.matrix;

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

        if (AuthorShared.Scene.PivotDrag(ref vector3, ref vector31))
        {
            flag        = true;
            this.anchor = self.Flip(vector3);
            this.axis   = self.AxisFlip(vector31);
        }
        AuthorChJoint.Kind kind = this.kind;
        if (kind != AuthorChJoint.Kind.Hinge)
        {
            if (kind == AuthorChJoint.Kind.Character)
            {
                Color color1 = AuthorShared.Scene.color;
                AuthorShared.Scene.color = color1 * AuthorChJoint.twistColor;
                SoftJointLimit softJointLimit  = this.lowTwist;
                SoftJointLimit softJointLimit1 = this.highTwist;
                if (AuthorShared.Scene.LimitDrag(vector3, vector31, ref this.twistOffset, ref softJointLimit, ref softJointLimit1))
                {
                    flag           = true;
                    this.lowTwist  = softJointLimit;
                    this.highTwist = softJointLimit1;
                }
                AuthorShared.Scene.color = color1 * AuthorChJoint.swing1Color;
                softJointLimit           = this.swing1;
                if (AuthorShared.Scene.LimitDrag(vector3, vector32, ref this.swingOffset1, ref softJointLimit))
                {
                    flag        = true;
                    this.swing1 = softJointLimit;
                }
                AuthorShared.Scene.color = color1 * AuthorChJoint.swing2Color;
                softJointLimit           = this.swing2;
                if (AuthorShared.Scene.LimitDrag(vector3, Vector3.Cross(vector32, vector31), ref this.swingOffset2, ref softJointLimit))
                {
                    flag        = true;
                    this.swing2 = softJointLimit;
                }
                AuthorShared.Scene.color = color1;
            }
        }
        else if (this.useLimit)
        {
            JointLimits jointLimit = this.limit;
            if (AuthorShared.Scene.LimitDrag(vector3, vector31, ref this.limitOffset, ref jointLimit))
            {
                flag       = true;
                this.limit = jointLimit;
            }
        }
        AuthorShared.Scene.matrix = matrix4x4;
        return(flag);
    }