Skip to content

Commit

Permalink
fix(collision) : Calculate all collisions
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexis Huvier committed Aug 16, 2023
1 parent 77348e0 commit 4d6af7e
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions SharpEngine.Core/Component/CollisionComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ public Rect GetCollisionRect(Vec2? position = null)
/// <returns>True if can go to position</returns>
public bool CanGo(Vec2 position)
{
var canGo = true;
foreach (var entity in Entity?.Scene?.Entities!)
{
if (entity == Entity) continue;
Expand All @@ -76,11 +77,13 @@ public bool CanGo(Vec2 position)
{
CollisionCallback?.Invoke(Entity, entity);
entityPhysics.CollisionCallback?.Invoke(Entity, entity);
return !(Solid && entityPhysics.Solid);

if (canGo)
canGo = !(Solid && entityPhysics.Solid);
}
}

return true;
return canGo;
}

/// <inheritdoc />
Expand Down

0 comments on commit 4d6af7e

Please sign in to comment.