private static void HandleCollision( Ecs.Registry registry, Queue <Entity> toRemove, Entity entity, Comps.Solid solidComp, Comps.Position positionComp, Comps.Shapes.Rectangle rectangleComp, PhysicalVector2 tilePosition, Rectangle tileRectangle ) { if (solidComp.ephemeral) { toRemove.Enqueue(entity); } else { PhysicalVector2 correction = GetMinCorrection( rectangleComp.data, positionComp.data, tileRectangle, tilePosition ); positionComp.data += correction; } }
private static void HandleCollision( Ecs.Registry registry, Queue <Entity> toRemove, Entity entity1, Comps.Solid entity1Solid, Comps.Position entity1Pos, Comps.Shapes.Rectangle entity1Rect, Entity entity2, Comps.Solid entity2Solid, Comps.Position entity2Pos, Comps.Shapes.Rectangle entity2Rect ) { if (entity1Solid.ephemeral) { toRemove.Enqueue(entity1); return; } if (entity2Solid.ephemeral) { toRemove.Enqueue(entity2); return; } Vector2 correction = GetMinCorrection( entity1Rect.data, entity1Pos.data, entity2Rect.data, entity2Pos.data ); // Ignore the case where both are unmovable if (entity1Solid.unmovable) { entity2Pos.data -= correction; } else if (entity2Solid.unmovable) { entity1Pos.data += correction; } else { entity1Pos.data += correction / 2f; entity2Pos.data -= correction / 2f; } }