private void PlayerBody_OnSeparation(Fixture sender, Fixture other, tainicom.Aether.Physics2D.Dynamics.Contacts.Contact contact) { if (other.Body.BodyType == BodyType.Static) { IsGrounded = false; } }
/// <summary> /// Contacts are persistant and will keep being persistant unless they are /// flagged for filtering. /// This methods flags all contacts associated with the body for filtering. /// </summary> private void Refilter() { // Flag associated contacts for filtering. ContactEdge edge = Body.ContactList; while (edge != null) { Contacts.Contact contact = edge.Contact; Fixture fixtureA = contact.FixtureA; Fixture fixtureB = contact.FixtureB; if (fixtureA == this || fixtureB == this) { contact.FilterFlag = true; } edge = edge.Next; } World world = Body.World; if (world == null) { return; } // Touch each proxy so that new pairs may be created IBroadPhase broadPhase = world.ContactManager.BroadPhase; TouchProxies(broadPhase); }
private bool PlayerBody_OnCollision(Fixture sender, Fixture other, tainicom.Aether.Physics2D.Dynamics.Contacts.Contact contact) { if (other.Body.BodyType == BodyType.Static) { IsGrounded = true; } return(true); //throw new NotImplementedException(); }
/// <summary> /// Destroy a fixture. This removes the fixture from the broad-phase and /// destroys all contacts associated with this fixture. This will /// automatically adjust the mass of the body if the body is dynamic and the /// fixture has positive density. /// All fixtures attached to a body are implicitly destroyed when the body is destroyed. /// Warning: This method is locked during callbacks. /// </summary> /// <param name="fixture">The fixture to be removed.</param> /// <exception cref="System.InvalidOperationException">Thrown when the world is Locked/Stepping.</exception> public virtual void Remove(Fixture fixture) { if (World != null && World.IsLocked) { throw new InvalidOperationException("The World is locked."); } if (fixture == null) { throw new ArgumentNullException("fixture"); } if (fixture.Body != this) { throw new ArgumentException("You are removing a fixture that does not belong to this Body.", "fixture"); } // Destroy any contacts associated with the fixture. ContactEdge edge = ContactList; while (edge != null) { Contacts.Contact c = edge.Contact; edge = edge.Next; Fixture fixtureA = c.FixtureA; Fixture fixtureB = c.FixtureB; if (fixture == fixtureA || fixture == fixtureB) { // This destroys the contact and removes it from // this body's contact list. World.ContactManager.Destroy(c); } } if (Enabled) { IBroadPhase broadPhase = World.ContactManager.BroadPhase; fixture.DestroyProxies(broadPhase); } fixture.Body = null; FixtureList.Remove(fixture); #if DEBUG if (fixture.Shape.ShapeType == ShapeType.Polygon) { ((PolygonShape)fixture.Shape).Vertices.AttachedToBody = false; } #endif if (World.FixtureRemoved != null) { World.FixtureRemoved(World, this, fixture); } ResetMassData(); }