Example #1
0
 private void CreatedCollider(Collider created, AuthorChHit.Rep repFormat, bool addJoints, int?layerIndex)
 {
     if (!created)
     {
         return;
     }
     repFormat.bone = created.transform;
     if (addJoints)
     {
         Rigidbody rigidbody = created.rigidbody;
         if (!rigidbody)
         {
             rigidbody = created.gameObject.AddComponent <Rigidbody>();
         }
         rigidbody.mass        = this.mass;
         rigidbody.drag        = this.drag;
         rigidbody.angularDrag = this.angularDrag;
         if (this.myJoints != null)
         {
             AuthorChJoint[] authorChJointArray = this.myJoints;
             for (int i = 0; i < (int)authorChJointArray.Length; i++)
             {
                 AuthorChJoint authorChJoint = authorChJointArray[i];
                 if (authorChJoint)
                 {
                     authorChJoint.AddJoint(repFormat.bone.root, ref repFormat);
                 }
             }
         }
     }
     if (layerIndex.HasValue)
     {
         created.gameObject.layer = layerIndex.Value;
     }
 }
Example #2
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 #3
0
 internal void OnJointDestroy(AuthorChJoint joint)
 {
     if (this.myJoints != null)
     {
         int index = Array.IndexOf <AuthorChJoint>(this.myJoints, joint);
         if (index != -1)
         {
             for (int i = index; i < (this.myJoints.Length - 1); i++)
             {
                 this.myJoints[i] = this.myJoints[i + 1];
             }
             Array.Resize <AuthorChJoint>(ref this.myJoints, this.myJoints.Length - 1);
         }
     }
 }
Example #4
0
    internal void OnJointDestroy(AuthorChJoint joint)
    {
        if (this.myJoints == null)
        {
            return;
        }
        int num = Array.IndexOf <AuthorChJoint>(this.myJoints, joint);

        if (num != -1)
        {
            for (int i = num; i < (int)this.myJoints.Length - 1; i++)
            {
                this.myJoints[i] = this.myJoints[i + 1];
            }
            Array.Resize <AuthorChJoint>(ref this.myJoints, (int)this.myJoints.Length - 1);
        }
    }
Example #5
0
 protected override void OnPeiceDestroy()
 {
     try
     {
         if (this.myJoints != null)
         {
             AuthorChJoint[] authorChJointArray = this.myJoints;
             this.myJoints = null;
             AuthorChJoint[] authorChJointArray1 = authorChJointArray;
             for (int i = 0; i < (int)authorChJointArray1.Length; i++)
             {
                 AuthorChJoint authorChJoint = authorChJointArray1[i];
                 if (authorChJoint)
                 {
                     UnityEngine.Object.Destroy(authorChJoint);
                 }
             }
         }
     }
     finally
     {
         base.OnPeiceDestroy();
     }
 }
Example #6
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);
    }