gurkenlabs / litiengine

LITIENGINE 🕹 The pure 2D java game engine.
https://litiengine.com/
MIT License
725 stars 93 forks source link

Minor change to EntityControllers function to better target movement controllers. #440

Closed ecchilds closed 2 years ago

ecchilds commented 2 years ago

What feature / which classes are you referring to? The clearControllers() function in entities.EntityControllers.

Describe what could be enhanced. Fix a bug wherein animation controller can be removed instead of a specified movement controller. I believe this can be done by replacing clss.isAssignableFrom(clss) with x.isAssignableFrom(clss) on line 47.

I believe this bug is caused by that lambda function on line 47, as it checks if clss is assignable from itself. This means that the first controller in the controllers object gets deleted, regardless of what that controller is, or what the function's argument is.

Additional thoughts I'm putting this in a feature request, not a bug report, as I believe I've already nailed down the fix, but I do not know how to import a fork into my project in order to test this edit. So, I recommend testing it yourselves before committing, should you choose to implement this change.

ecchilds commented 2 years ago

Okay I found a way to test it, clss.isAssignableFrom(x) will work, not x.isAssignableFrom(clss).

Gamebuster19901 commented 2 years ago

Okay I found a way to test it, clss.isAssignableFrom(x) will work, not x.isAssignableFrom(clss).

Thanks for opening the issue! Please take a look at #441 to confirm that the changes are what you specified.