Exemplo n.º 1
0
 public static void Correct(JRigidbody body)
 {
     lock (CorPool)
     {
         if (!CorPool.Contains(body)) CorPool.Add(body);
     }
 }
Exemplo n.º 2
0
 public static void AddBody(JRigidbody body)
 {
     CheckInstance();
     lock (BodyPool)
     {
         if (!BodyPool.Contains(body)) BodyPool.Add(body);
     }
     lock (Bodies) if (!Bodies.ContainsValue(body)) Bodies.Add(body.Body, body);
 }
Exemplo n.º 3
0
 public static void Correct(JRigidbody body)
 {
     lock (CorPool)
     {
         if (!CorPool.Contains(body))
         {
             CorPool.Add(body);
         }
     }
 }
Exemplo n.º 4
0
        void OnEnable()
        {
            shape          = MakeShape();
            cacheTransform = transform;

            if (Rigidbody == null)
            {
                rigidbody            = gameObject.AddComponent <JRigidbody>();
                rigidbody.Damping    = JRigidbody.DampingType.None;
                rigidbody.UseGravity = false;
                rigidbody.IsStatic   = true;
                rigidbody.hideFlags  = HideFlags.HideInHierarchy | HideFlags.HideInInspector;
            }
        }
Exemplo n.º 5
0
 public static void RemoveBody(JRigidbody body)
 {
     lock (BodyPoolToRemove)
     {
         if (!BodyPoolToRemove.Contains(body))
         {
             BodyPoolToRemove.Add(body);
         }
     }
     lock (Bodies) if (!Bodies.ContainsValue(body))
         {
             Bodies.Remove(body.Body);
         }
 }
Exemplo n.º 6
0
 public static void AddBody(JRigidbody body)
 {
     CheckInstance();
     lock (BodyPool)
     {
         if (!BodyPool.Contains(body))
         {
             BodyPool.Add(body);
         }
     }
     lock (Bodies) if (!Bodies.ContainsValue(body))
         {
             Bodies.Add(body.Body, body);
         }
 }
Exemplo n.º 7
0
 //TODO make this threadsafe. Dangerous code
 public static bool Raycast(Vector3 origin, Vector3 direction, out JRigidbody body, out Vector3 normal, out float distance)
 {
     body     = null;
     normal   = Vector3.zero;
     distance = 0;
     if (IsInstance)
     {
         RigidBody b;
         JVector   n;
         var       v = Instance.World.CollisionSystem.Raycast(origin.ConvertToJVector(), direction.ConvertToJVector(),
                                                              null, out b, out n, out distance);
         if (b != null && Bodies.ContainsKey(b))
         {
             body = Bodies[b];
             if (body != null)
             {
                 normal = n;
                 return(v);
             }
         }
         return(false);
     }
     return(false);
 }
Exemplo n.º 8
0
 public static void RemoveBody(JRigidbody body)
 {
     lock (BodyPoolToRemove)
     {
         if (!BodyPoolToRemove.Contains(body)) BodyPoolToRemove.Add(body);
     }
     lock (Bodies) if (!Bodies.ContainsValue(body)) Bodies.Remove(body.Body);
 }
Exemplo n.º 9
0
 //TODO make this threadsafe. Dangerous code
 public static bool Raycast(Vector3 origin, Vector3 direction, out JRigidbody body, out Vector3 normal, out float distance)
 {
     body = null;
     normal = Vector3.zero;
     distance = 0;
     if (IsInstance)
     {
         RigidBody b;
         JVector n;
         var v =  Instance.World.CollisionSystem.Raycast(origin.ConvertToJVector(), direction.ConvertToJVector(),
                                                       null, out b, out n, out distance);
         if (b != null && Bodies.ContainsKey(b))
         {
             body = Bodies[b];
             if (body != null)
             {
                 normal = n;
                 return v;
             }
         }
         return false;
     }
     return false;
 }
Exemplo n.º 10
0
        void OnEnable()
        {
            shape = MakeShape();
            cacheTransform = transform;

            if (Rigidbody == null)
            {
                rigidbody = gameObject.AddComponent<JRigidbody>();
                rigidbody.Damping = JRigidbody.DampingType.None;
                rigidbody.UseGravity = false;
                rigidbody.IsStatic = true;
                rigidbody.hideFlags = HideFlags.HideInHierarchy | HideFlags.HideInInspector;
            }
        }