/// <summary> /// Returns a list of collision delegates containing all delegates whose shapes met the collision check with the given shape. /// </summary> /// <param name="shape">Shape to be compared against for collision.</param> /// <param name="typeCheck">Definition of what a "collision" is for this check. Optional.</param> /// <returns></returns> public List<CollisionDelegate> CollisionCheckAllObjects(Shape shape, CollisionGroupIdentifier group, Shape.CollideType typeCheck = Shape.CollideType.All) { LinkedList<CollisionDelegate> delegates = m_Delegates[group]; List<CollisionDelegate> CollidingDelegates = new List<CollisionDelegate>(); foreach (CollisionDelegate cd in delegates) { if (shape.Collides(cd.shape, typeCheck)) { CollidingDelegates.Add(cd); } } return CollidingDelegates; }
/// <summary> /// Returns the first instance that is detected to collide with the given shape. /// </summary> /// <param name="shape">Shape to be checked against for collision.</param> /// <param name="typeCheck">Definition of what a "collision" is for this check. Optional.</param> /// <returns></returns> public CollisionDelegate CollisionCheckFirstObject(Shape shape, CollisionGroupIdentifier group, Shape.CollideType typeCheck = Shape.CollideType.All) { LinkedList<CollisionDelegate> delegates = m_Delegates[group]; CollisionDelegate firstInstance = new CollisionDelegate(); foreach (CollisionDelegate cd in delegates) { if (shape.Collides(cd.shape, typeCheck)) { firstInstance = cd; break; } } return firstInstance; }
/// <summary> /// Returns whether or not an instance collides with the given shape. /// </summary> /// <param name="shape">Shape to be checked against for collision.</param> /// <param name="typeCheck">Definition of what a "collision" is for this check. Optional.</param> /// <returns></returns> public bool CollisionCheck(Shape shape, CollisionGroupIdentifier group, Shape.CollideType typeCheck = Shape.CollideType.All) { LinkedList<CollisionDelegate> delegates = m_Delegates[group]; bool isColliding = false; foreach (CollisionDelegate cd in delegates) { if (shape.Collides(cd.shape, typeCheck)) isColliding = true; } return isColliding; }