Пример #1
0
 internal void SetColliders(Collider a, Collider b)
 {
     collider = b;
     for (int j = 0; j < contacts.Length; j++)
     {
         contacts[j].thisCollider = a;
         contacts[j].otherCollider = b;
     }
 }
Пример #2
0
 public void ResetStays(Collider collider)
 {
     for (int i = staying.Count - 1; i >= 0; i--)
     {
         if (staying[i].colliderA == collider || staying[i].colliderB == collider)
         {
             staysToRemove[i] = true;
         }
     }
 }
Пример #3
0
 public virtual void OnTriggerStay(Collider collider)
 {
     // NOTE: Do not make any code here. Typically base method is NOT called in MonoScripts so this will not be called either!!!!!
 }
Пример #4
0
 internal void RemoveStay(Collider compA, Collider compB)
 {
     for (int i = staying.Count - 1; i >= 0; i--)
     {
         if ((staying[i].colliderA == compA && staying[i].colliderB == compB) || (staying[i].colliderA == compB && staying[i].colliderB == compA))
         {
             staysToRemove[i] = true;
         }
     }
 }
Пример #5
0
            public ColliderContact(Contact contact)
            {
                this.colliderA = contact.FixtureA.Body.UserData;
                this.colliderB = contact.FixtureB.Body.UserData;
                involvesATrigger = colliderA.isTrigger || colliderB.isTrigger;

                // Creates collisions
                Microsoft.Xna.Framework.Vector2 normal;
                FarseerPhysics.Common.FixedArray2<Microsoft.Xna.Framework.Vector2> points;
                contact.GetWorldManifold(out normal, out points);
                collisionBToA = new Collision()
                {
                    collider = colliderB,
                    relativeVelocity = ((colliderA.rigidbody != null) ? colliderA.rigidbody.velocity : Vector3.zero) - ((colliderB.rigidbody != null) ? colliderB.rigidbody.velocity : Vector3.zero),
                    contacts = new ContactPoint[contact.Manifold.PointCount]
                };
                collisionAToB = new Collision()
                {
                    collider = colliderA,
                    relativeVelocity = ((colliderB.rigidbody != null) ? colliderB.rigidbody.velocity : Vector3.zero) - ((colliderA.rigidbody != null) ? colliderA.rigidbody.velocity : Vector3.zero),
                    contacts = new ContactPoint[contact.Manifold.PointCount]
                };
                for (int j = 0; j < collisionBToA.contacts.Length; j++)
                {
                    collisionBToA.contacts[j].thisCollider = colliderB;
                    collisionBToA.contacts[j].otherCollider = colliderA;
                    collisionBToA.contacts[j].point = VectorConverter.Convert(points[j], colliderB.to2dMode);
                    collisionBToA.contacts[j].normal = VectorConverter.Convert(-normal, colliderB.to2dMode);

                    collisionAToB.contacts[j].thisCollider = colliderA;
                    collisionAToB.contacts[j].otherCollider = colliderB;
                    collisionAToB.contacts[j].point = VectorConverter.Convert(points[j], colliderA.to2dMode);
                    collisionAToB.contacts[j].normal = VectorConverter.Convert(normal, colliderA.to2dMode);
                }
            }
Пример #6
0
 internal static void RemoveStays(Collider collider)
 {
     contactProcessor.ResetStays(collider);
 }
Пример #7
0
 private static void RemoveStays(Collider collider1, Collider collider2)
 {
     contactProcessor.RemoveStay(collider1, collider2);
 }
Пример #8
0
 internal static void MoveCollider(Collider coll)
 {
     Body body = coll.connectedBody;
     BodyType bodyType = body.BodyType;
     Transform t = coll.transform;
     if ((bodyType == BodyType.Kinematic) || (ApplicationSettings.Physics_MoveStaticColliders && bodyType == BodyType.Static))
     {
         if (((t.changes & TransformChanges.Position) == TransformChanges.Position) || ((t.changes & TransformChanges.Rotation) == TransformChanges.Rotation))
         {
             float rad = MathHelper.ToRadians(VectorConverter.Angle(t.eulerAngles, coll.to2dMode));
             Microsoft.Xna.Framework.Vector2 pos = VectorConverter.Convert(t.position, coll.to2dMode);
     #if DEBUG
             Debug.LogIf(DebugSettings.LogColliderChanges, String.Format("Move {0} to {1} and rotate to {2}", coll, pos, rad));
     #endif
             body.SetTransformIgnoreContacts(ref pos, rad);
         }
         if ((t.changes & TransformChanges.Scale) == TransformChanges.Scale)
         {
     #if DEBUG
             Debug.LogIf(DebugSettings.LogColliderChanges, String.Format("Resize collider {0}", coll));
     #endif
             coll.ResizeConnectedBody();
         }
     }
 }
Пример #9
0
 public static void IgnoreCollision(Collider collider1, Collider collider2, bool ignore)
 {
     if (ignore)
     {
         collider1.connectedBody.IgnoreCollisionWith(collider2.connectedBody);
         RemoveStays(collider1, collider2);
     }
     else
     {
         collider1.connectedBody.RestoreCollisionWith(collider2.connectedBody);
     }
 }
Пример #10
0
 public static void IgnoreCollision(Collider collider1, Collider collider2)
 {
     IgnoreCollision(collider1, collider2, true);
 }
Пример #11
0
 public Stay(Collision collisionAToB, Collision collisionBToA, GameObject gameObjectA, GameObject gameObjectB)
 {
     this.collisionAToB = collisionAToB;
     this.collisionBToA = collisionBToA;
     colliderToTriggerA = collisionAToB.collider;
     colliderToTriggerB = collisionBToA.collider;
     this.gameObjectA = gameObjectA;
     this.gameObjectB = gameObjectB;
 }
Пример #12
0
 public Stay(Collider colliderToTriggerA, Collider colliderToTriggerB, GameObject gameObjectA, GameObject gameObjectB)
 {
     this.colliderToTriggerA = colliderToTriggerA;
     this.colliderToTriggerB = colliderToTriggerB;
     this.gameObjectA = gameObjectA;
     this.gameObjectB = gameObjectB;
     collisionAToB = null;
     collisionBToA = null;
 }