AdamsLair / duality

a 2D Game Development Framework
https://adamslair.github.io/duality
MIT License
1.4k stars 289 forks source link

Coroutines (and pooling) for v4, with improved tests #801

Closed SirePi closed 4 years ago

SirePi commented 4 years ago

This PR supersedes #755 as it is based on the most recent v4 master source and implements all reviews and user request of the previous pull request. In addition, pool-specific tests have been introduced and Scene.cs has a couple of missing "this" added to comply with the overall coding style.

Barsonax commented 4 years ago

You are absolutely correct that this is an eventuality; on the other hand, there is no way for the Manager to know beforehand what the Coroutine will affect (it could affect the spawning object, something else, no objects at all, ...).

You could make a API on the gameobject/component to start a coroutine and that API also queues up a cleanup action that is run when the gameobject is deactivated. A bit like the UseEffect from React I guess. This will tie the lifetime of the coroutine to the gameobject/component.

This is more something thats worth a separate issue altogether though because it might be preferable to generalize this so it can be reused.

SirePi commented 4 years ago

Added #817 to continue discussions on open points