/// <summary> /// Checks all "Colliding" collisions to see if they are still colliding. /// If not, they are removed from the "Colliding" collision list and added to the "Stop" collision list. /// </summary> public void Process() { var collisions = ECSCore.collisionPool.collisions; Entity e; Collision collision; List <Collision> collidingCollisions; List <Collision> stopCollisions; foreach (var collisionMap in collisions) { e = collisionMap.Key; collidingCollisions = collisionMap.Value[CollisionState.Colliding]; stopCollisions = collisionMap.Value[CollisionState.Stop]; for (int i = collidingCollisions.Count - 1; i >= 0; --i) { collision = collidingCollisions[i]; if (!Collisions.EntitiesCollide(e, collision.entity)) { collidingCollisions.RemoveAt(i); stopCollisions.Add(collision); } } } }
public void Process() { var entities = ECSCore.pool.GetEntities(); var collisionPool = ECSCore.collisionPool; // TODO: Simple optimisation with more efficient FOR-FOR loop. foreach (var e1 in entities) { foreach (var e2 in entities) { if (e1 == e2) { continue; } if (Collisions.EntitiesCollide(e1, e2)) { collisionPool.RegisterCollision(e1, e2); } } } }