libgdx / ashley

A Java entity system inspired by Ash & Artemis.
Apache License 2.0
875 stars 144 forks source link

PooledEntity instances are not reset() if their pool is full #302

Closed carlislefox closed 2 years ago

carlislefox commented 2 years ago

Hello!

I've recently upgraded LibGDX 1.10.0 and noticed a behavioural change that results in pooled components not having their reset() methods called. It appears that PooledEntity instances no longer have their reset() method called if the pool the Entity is being returned to is full, this has a few side effects:

I have tracked this behaviour down to this change to Poolable in LibGDX:

https://github.com/libgdx/libgdx/commit/049174598204936eab55375079944983c39530e1#diff-2b502e40add95b689c7f66b2f0a0fa97d4b1d1961881443a6e4a7d470a2c6208

It would appear a discard() method has been added to Pool that is called should the above circumstance occur. Given Ashley's nature, might I suggest implementing this method in PooledEntity and simply calling reset() in it's implementation? This would keep behaviour consistent with how it used to function prior to this change in LibGDX.

If this is agreeable, may I make the change and submit a pull request?

Cheers, Fhox