private void metjolturgent(float varpforcemin, float varpforcemax, float varptorquemin, float varptorquemax, ForceMode varpforcemode, bool varpjoltspine, bool varpjolthead, bool varpjoltarmleft, bool varpjoltarmright, bool varpjoltlegright, bool varpjoltlegleft)
    {
        clsurgent componentInChildren = base.gameObject.GetComponentInChildren <clsurgent>();

        if (componentInChildren == null)
        {
            return;
        }
        Vector3 force  = new Vector3(UnityEngine.Random.Range(varpforcemin, varpforcemax), UnityEngine.Random.Range(varpforcemin, varpforcemax), UnityEngine.Random.Range(varpforcemin, varpforcemax));
        Vector3 torque = new Vector3(UnityEngine.Random.Range(varptorquemin, varptorquemax), UnityEngine.Random.Range(varptorquemin, varptorquemax), UnityEngine.Random.Range(varptorquemin, varptorquemax));

        if (varpjoltspine)
        {
            for (int i = 0; i < componentInChildren.vargamnodes.vargamspine.Length; i++)
            {
                componentInChildren.vargamnodes.vargamspine[i].GetComponent <Rigidbody>().AddForce(force, varpforcemode);
                componentInChildren.vargamnodes.vargamspine[i].GetComponent <Rigidbody>().AddTorque(torque, varpforcemode);
            }
        }
        if (varpjolthead)
        {
            for (int j = 0; j < componentInChildren.vargamnodes.vargamhead.Length; j++)
            {
                componentInChildren.vargamnodes.vargamhead[j].GetComponent <Rigidbody>().AddForce(force, varpforcemode);
                componentInChildren.vargamnodes.vargamhead[j].GetComponent <Rigidbody>().AddTorque(torque, varpforcemode);
            }
        }
        if (varpjoltarmleft)
        {
            for (int k = 0; k < componentInChildren.vargamnodes.vargamarmleft.Length; k++)
            {
                componentInChildren.vargamnodes.vargamarmleft[k].GetComponent <Rigidbody>().AddForce(force, varpforcemode);
                componentInChildren.vargamnodes.vargamarmleft[k].GetComponent <Rigidbody>().AddTorque(torque, varpforcemode);
            }
        }
        if (varpjoltarmright)
        {
            for (int l = 0; l < componentInChildren.vargamnodes.vargamarmright.Length; l++)
            {
                componentInChildren.vargamnodes.vargamarmright[l].GetComponent <Rigidbody>().AddForce(force, varpforcemode);
                componentInChildren.vargamnodes.vargamarmright[l].GetComponent <Rigidbody>().AddTorque(torque, varpforcemode);
            }
        }
        if (varpjoltlegleft)
        {
            for (int m = 0; m < componentInChildren.vargamnodes.vargamlegleft.Length; m++)
            {
                componentInChildren.vargamnodes.vargamlegleft[m].GetComponent <Rigidbody>().AddForce(force, varpforcemode);
                componentInChildren.vargamnodes.vargamlegleft[m].GetComponent <Rigidbody>().AddTorque(torque, varpforcemode);
            }
        }
        if (varpjoltlegright)
        {
            for (int n = 0; n < componentInChildren.vargamnodes.vargamlegright.Length; n++)
            {
                componentInChildren.vargamnodes.vargamlegright[n].GetComponent <Rigidbody>().AddForce(force, varpforcemode);
                componentInChildren.vargamnodes.vargamlegright[n].GetComponent <Rigidbody>().AddTorque(torque, varpforcemode);
            }
        }
    }
Example #2
0
 void Start()
 {
     //if we don't have a remote target, we search the URGent manager in our gameobject
     if (vargamurgentities == null)
         vargamurgentities = GetComponent<clsurgent>();
     //we automatically enable the physics animation, required to interact physically with kinematic objects
     if (transform.root.animation)
         transform.root.animation.animatePhysics = true;
 }
Example #3
0
 private void Start()
 {
     if (this.vargamurgentities == null)
     {
         this.vargamurgentities = base.GetComponent <clsurgent>();
     }
     if (base.transform.root.GetComponent <Animation>())
     {
         base.transform.root.GetComponent <Animation>().animatePhysics = true;
     }
 }
Example #4
0
 private void OnTriggerEnter(Collider varsource)
 {
     if (varsource.name == "bumper")
     {
         base.GetComponent <Animation>().Stop();
         clsurgent component = base.GetComponent <clsurgent>();
         if (component != null)
         {
             clsurgutils.metdriveurgent(component, null);
         }
     }
 }
Example #5
0
 /// <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);
     }
 }
Example #6
0
 /// <summary>
 /// Auxilliary function to drive an urgent object, can be used to directly ragdollimbify a body part without the need
 /// of a collision or trigger effect
 /// </summary>
 /// <param name="varpsource">
 /// The URG entities manager which holds the armature structure data for the limb
 /// </param>
 /// <param name="varppart">
 /// The body part type
 /// </param>
 /// <param name="varppartindex">
 /// The source part index, which will be driven followed with its children
 /// </param>
 public static void metdrivebodypart(clsurgent varpsource, clsurgutils.enumparttypes varppart, int varppartindex)
 {
     //determine the body part
     if (varpsource != null) {
         Transform[] varcurrentbodypart = new Transform[0];
         switch (varppart) {
             case enumparttypes.spine:
                 varcurrentbodypart = varpsource.vargamnodes.vargamspine;
                 break;
             case enumparttypes.head:
                 varcurrentbodypart = varpsource.vargamnodes.vargamhead;
                 break;
             case enumparttypes.arm_left:
                 varcurrentbodypart = varpsource.vargamnodes.vargamarmleft;
                 break;
             case enumparttypes.arm_right:
                 varcurrentbodypart = varpsource.vargamnodes.vargamarmright;
                 break;
             case enumparttypes.leg_left:
                 varcurrentbodypart = varpsource.vargamnodes.vargamlegleft;
                 break;
             case enumparttypes.leg_right:
                 varcurrentbodypart = varpsource.vargamnodes.vargamlegright;
                 break;
             default:
                 Debug.LogError("Unmanaged part type");
                 break;
         }
         //cycle 'outwards' in the parts list, and set the part as physics driven
         for (int varcounter = varppartindex; varcounter < varcurrentbodypart.Length; varcounter++) {
             varcurrentbodypart[varcounter].rigidbody.isKinematic = false;
         }
     }
     else {
         Debug.LogError("Received a request to URG drive a null source");
     }
 }
Example #7
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);
     }
 }
Example #8
0
 public static void metdrivebodypart(clsurgent varpsource, clsurgutils.enumparttypes varppart, int varppartindex)
 {
     clsurgutils.metdriveanimatebodypart(varpsource, varppart, varppartindex, false);
 }
Example #9
0
 public static void metdriveanimatebodypart(clsurgent varpsource, clsurgutils.enumparttypes varppart, int varppartindex, bool varpanimate)
 {
     if (varpsource != null)
     {
         Transform[] array = new Transform[0];
         switch (varppart)
         {
         case clsurgutils.enumparttypes.head:
             array = varpsource.vargamnodes.vargamhead;
             break;
         case clsurgutils.enumparttypes.spine:
             array = varpsource.vargamnodes.vargamspine;
             break;
         case clsurgutils.enumparttypes.arm_left:
             array = varpsource.vargamnodes.vargamarmleft;
             break;
         case clsurgutils.enumparttypes.arm_right:
             array = varpsource.vargamnodes.vargamarmright;
             break;
         case clsurgutils.enumparttypes.leg_left:
             array = varpsource.vargamnodes.vargamlegleft;
             break;
         case clsurgutils.enumparttypes.leg_right:
             array = varpsource.vargamnodes.vargamlegright;
             break;
         default:
             Debug.LogError("Unmanaged part type");
             break;
         }
         for (int i = varppartindex; i < array.Length; i++)
         {
             if (array[i] != null && array[i].GetComponent<Rigidbody>() != null)
             {
                 array[i].GetComponent<Rigidbody>().isKinematic = varpanimate;
             }
         }
     }
     else
     {
         Debug.LogError("Received a request to URG drive a null source");
     }
 }