drekdrek / grinding-stats

Openplanet plugin which shows statistics
https://openplanet.dev/plugin/grindingstats
MIT License
6 stars 5 forks source link

change finishes, reset and respawns global variables to references #12

Closed TigerGorilla2 closed 2 years ago

TigerGorilla2 commented 2 years ago

To stop the coroutines for finishes, resets and respawns you set their member variable running to false. But because the class instances get deconstructed (reassignment of the variables) before the coroutines are able to run again their member variable running keep giving true even though it should be false and they run forever(?).

By only holding a reference to the instances they don't get deconstructed at reassignment but rather when the coroutine finishes and the garbage collector deconstructs it (because no one is holding a reference to it). That's at least how I understand it.

You can confirm it making a difference by opening Openplanet (F3) -> Developer -> Debug -> Profiler -> and simply opening multiple maps e.g. first five of the campaign. On your version the routines time keeps growing.

TigerGorilla2 commented 2 years ago

Timers might not be effected because they get paused when not running (global variable)

drekdrek commented 2 years ago

thank you, this makes sense.

I'm also working on rewriting the timer to further optimize it