craftworkgames / MonoGame.Extended

Extensions to make MonoGame more awesome
http://www.monogameextended.net/
Other
1.44k stars 325 forks source link

Check for undefined layer and throw on collision actor insertion #839

Closed safoster88 closed 7 months ago

safoster88 commented 9 months ago

When calling the CollisionComponent constructor, I incorrectly assumed that providing no arguments (i.e. layer = null) would define a default layer automatically. This is not the case, and attempting to insert an actor into a collision layer will result in a .NET exception being thrown as we try to index a dictionary entry that does not exist.

Wrapped this in a check which will now throw a custom exception, to make it clear from a public API perspective what has occurred.