protected override bool IntersectsImpl(CollisionMode thisCollisionMode, IExtent otherExtent, CollisionMode otherCollisionMode) { switch (CollisionChecker.GetCollisionInteractionType(thisCollisionMode, otherCollisionMode)) { case CollisionInteractionType.ExtentVsInnerCircle: case CollisionInteractionType.InnerCircleVsInnerCircle: return(ExtentIntersector.AreInIntersectionCircleVsCircle(this, otherExtent)); case CollisionInteractionType.ExtentVsExtent: case CollisionInteractionType.InnerCircleVsExtent: return(ExtentIntersector.AreInIntersectionCircleVsExtent(this, otherExtent)); case CollisionInteractionType.ExtentVsPoint: case CollisionInteractionType.InnerCircleVsPoint: return(ExtentIntersector.AreInIntersectionExtentVsPoint(this, otherExtent)); case CollisionInteractionType.PointVsCircle: case CollisionInteractionType.PointVsExtent: return(ExtentIntersector.AreInIntersectionExtentVsPoint(otherExtent, this)); case CollisionInteractionType.PointVsPoint: case CollisionInteractionType.Invalid: default: return(false); } }
protected void CheckCollisionFor(ICollidableObject primary, ICollidableObject secondary) { CollisionRuleEntry collisionRule; if (CollisionRules.CanCollide(primary.CollisionClass, secondary.CollisionClass, out collisionRule)) { ICollisionLifetimeEntry collisionEntry = null; //Check the collision lifetime tracker. If there is already a collision lifetime entry being tracked, do nothing and return. if (_collisionLifetimes.Contains(primary, secondary, out collisionEntry)) { //The specified entities have collided before. Check to see if this collision time is last the cooldown period if ((collisionRule != null) && !collisionEntry.CanCollideAgain(collisionRule.Cooldown, Globals.TotalGameTimeSeconds)) { return; } } if (CollisionChecker.AreInCollision(primary, secondary)) { if (collisionRule == null || collisionRule.TrackLifeTime) { _collisionLifetimes.Add(primary, secondary, Globals.TotalGameTimeSeconds); } _onCollision.Notify(new CollisionEventArgs(primary, secondary)); } } }