/// <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> /// Adds the given delegate to the designated delegate group. /// </summary> /// <param name="group">Group the delegate should be added to.</param> /// <param name="collisionDelegate">Collision delegate to be added.</param> /// <returns>A CollisionDelegateReference to be used for removal of the delegate from the collision world and for manipulation of the delegate.</returns> public CollisionDelegateReference AddDelegate(CollisionGroupIdentifier group, CollisionDelegate collisionDelegate) { AutoCreateCollisionGroup(group); CollisionDelegateReference newReference = new CollisionDelegateReference(); newReference.m_NodeGroup = group; newReference.m_Node = m_Delegates[group].AddLast(collisionDelegate); newReference.m_OwnerWorld = this; return newReference; }