/// <summary>
 /// URG entities alternative to metgodriven. Will scan the urgent array and ragdollify all children of the parameter part.
 /// Accessing this procedure is convenient in terms of efficiency and cpu since it's 'cheaper' than getcomponentsinchildren, when
 /// the source is based on the actual URGent armature
 /// NOTE: can be used to URG drive a clsurgent gameobject, when the actuator is passed as null
 /// </summary>
 /// <param name="varpsource">
 /// The URG entities manager which holds the armature structure data for the actuator
 /// </param>
 /// <param name="varpactuator">
 /// The actuator that will become driven, followed by its children. If this parameter is null, all the ragdoll will be URG driven.
 /// </param>
 public static void metdriveurgent(clsurgent varpsource, clsurgentactuator varpactuator)
 {
     if (varpsource == null) {
         Debug.LogError("Received a null parameter: " + varpsource + " - " + varpactuator);
         return;
     }
     //check if the actuator is null, of ir it's the source, in which case drive all body parts
     if (varpactuator == null || varpactuator.transform == varpsource.vargamnodes.vargamspine[0]) {
         metdrivebodypart(varpsource,enumparttypes.head,0);
         metdrivebodypart(varpsource,enumparttypes.arm_left,0);
         metdrivebodypart(varpsource,enumparttypes.arm_right,0);
         metdrivebodypart(varpsource,enumparttypes.leg_left,0);
         metdrivebodypart(varpsource,enumparttypes.leg_right,0);
         metdrivebodypart(varpsource,enumparttypes.spine,0);
     }
     //otherwise just call the drive procedure on the specified body part and index
     else {
         metdrivebodypart(varpsource,varpactuator.vargamparttype,varpactuator.vargampartindex);
     }
 }
 private void OnGUI()
 {
     if (this.vargamurgentities != null)
     {
         GUILayout.Label("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n", new GUILayoutOption[0]);
         if (this.varla)
         {
             if (GUILayout.Button("- Restore left arm", new GUILayoutOption[0]))
             {
                 clsurgentactuator component = this.vargamurgentities.vargamnodes.vargamarmleft[0].GetComponent <clsurgentactuator>();
                 this.vargamurgentities.vargamnodes.vargamarmleft[0].parent = component.vargamparent;
                 clsurgutils.metdriveanimatebodypart(this.vargamurgentities, clsurgutils.enumparttypes.arm_left, 0, true);
                 this.varla = false;
             }
         }
         else if (GUILayout.Button("Break left arm", new GUILayoutOption[0]))
         {
             this.vargamurgentities.vargamnodes.vargamarmleft[0].parent = this.vargamurgentities.transform;
             clsurgutils.metdrivebodypart(this.vargamurgentities, clsurgutils.enumparttypes.arm_left, 0);
             this.varla = true;
         }
         if (this.varra)
         {
             if (GUILayout.Button("- Restore right arm", new GUILayoutOption[0]))
             {
                 clsurgentactuator component2 = this.vargamurgentities.vargamnodes.vargamarmright[0].GetComponent <clsurgentactuator>();
                 if (component2 != null)
                 {
                     clsurgutils.metdriveanimatebodypart(this.vargamurgentities, clsurgutils.enumparttypes.arm_right, 0, true);
                 }
                 this.vargamurgentities.vargamnodes.vargamarmright[0].parent = component2.vargamparent;
                 this.varra = false;
             }
         }
         else if (GUILayout.Button("Break right arm", new GUILayoutOption[0]))
         {
             this.vargamurgentities.vargamnodes.vargamarmright[0].parent = this.vargamurgentities.transform;
             clsurgutils.metdrivebodypart(this.vargamurgentities, clsurgutils.enumparttypes.arm_right, 0);
             clsdrop componentInChildren = base.GetComponentInChildren <clsdrop>();
             if (componentInChildren != null)
             {
                 componentInChildren.metdrop(false);
             }
             this.varra = true;
         }
         if (this.varll)
         {
             if (GUILayout.Button("- Restore left leg", new GUILayoutOption[0]))
             {
                 clsurgentactuator component3 = this.vargamurgentities.vargamnodes.vargamlegleft[0].GetComponent <clsurgentactuator>();
                 if (component3 != null)
                 {
                     clsurgutils.metdriveanimatebodypart(this.vargamurgentities, clsurgutils.enumparttypes.leg_left, 0, true);
                 }
                 this.vargamurgentities.vargamnodes.vargamlegleft[0].parent = component3.vargamparent;
                 this.varll = false;
             }
         }
         else if (GUILayout.Button("Break left leg", new GUILayoutOption[0]))
         {
             this.vargamurgentities.vargamnodes.vargamlegleft[0].parent = this.vargamurgentities.transform;
             clsurgutils.metdrivebodypart(this.vargamurgentities, clsurgutils.enumparttypes.leg_left, 0);
             this.varll = true;
         }
         if (this.varrl)
         {
             if (GUILayout.Button("- Restore right leg", new GUILayoutOption[0]))
             {
                 clsurgentactuator component4 = this.vargamurgentities.vargamnodes.vargamlegright[0].GetComponent <clsurgentactuator>();
                 if (component4 != null)
                 {
                     clsurgutils.metdriveanimatebodypart(this.vargamurgentities, clsurgutils.enumparttypes.leg_right, 0, true);
                 }
                 this.vargamurgentities.vargamnodes.vargamlegright[0].parent = component4.vargamparent;
                 this.varrl = false;
             }
         }
         else if (GUILayout.Button("Break right leg", new GUILayoutOption[0]))
         {
             this.vargamurgentities.vargamnodes.vargamlegright[0].parent = this.vargamurgentities.transform;
             clsurgutils.metdrivebodypart(this.vargamurgentities, clsurgutils.enumparttypes.leg_right, 0);
             this.varrl = true;
         }
         if (GUILayout.Button("URG!", new GUILayoutOption[0]))
         {
             clsurgutils.metdriveurgent(this.vargamurgentities, null);
             this.vargamurgentities.transform.GetComponent <Animation>().Stop();
             this.vargamurgentities.transform.GetComponent <Animation>().animatePhysics = false;
             CharacterController component5 = this.vargamurgentities.transform.root.GetComponent <CharacterController>();
             Vector3             a          = default(Vector3);
             if (component5 != null)
             {
                 a   = component5.velocity;
                 a.y = 0.1f;
                 UnityEngine.Object.Destroy(component5);
                 this.vargamurgentities.vargamnodes.vargamspine[0].GetComponent <Rigidbody>().AddForce(a * 600f);
             }
             clsdrop componentInChildren2 = base.GetComponentInChildren <clsdrop>();
             if (componentInChildren2 != null)
             {
                 componentInChildren2.metdrop(a * 60f, true);
             }
             base.enabled = false;
         }
     }
 }
Exemple #3
0
 public static void metdriveurgent(clsurgent varpsource, clsurgentactuator varpactuator = null)
 {
     if (varpsource == null)
     {
         Debug.LogError(string.Concat(new object[]
         {
             "Received a null parameter: ",
             varpsource,
             " - ",
             varpactuator
         }));
         return;
     }
     if (varpactuator == null || varpactuator.transform == varpsource.vargamnodes.vargamspine[0])
     {
         clsurgutils.metdrivebodypart(varpsource, clsurgutils.enumparttypes.head, 0);
         clsurgutils.metdrivebodypart(varpsource, clsurgutils.enumparttypes.arm_left, 0);
         clsurgutils.metdrivebodypart(varpsource, clsurgutils.enumparttypes.arm_right, 0);
         clsurgutils.metdrivebodypart(varpsource, clsurgutils.enumparttypes.leg_left, 0);
         clsurgutils.metdrivebodypart(varpsource, clsurgutils.enumparttypes.leg_right, 0);
         clsurgutils.metdrivebodypart(varpsource, clsurgutils.enumparttypes.spine, 0);
     }
     else
     {
         clsurgutils.metdrivebodypart(varpsource, varpactuator.vargamparttype, varpactuator.vargampartindex);
     }
 }