CodinGame / codingame-game-engine

CodinGame Engine
https://www.codingame.com
MIT License
110 stars 41 forks source link

Toogle module does not work if loaded before the GraphicEntityModule #65

Closed Butanium closed 1 year ago

Butanium commented 1 year ago

The doc about the tooltip module says :

⚠ This module requires the GraphicEntityModule to work.

But, the module needs more than that, it needs to be loaded after the graphicEntityModule (so needs an higher index in modules from the config.js). If you load it before the GraphicEntityModule, you get this error :

Drawer.js:86 TypeError: Cannot set properties of undefined (setting 'interactive')
    at TooltipModule.js:181:46
    at Map.forEach (<anonymous>)
    at TooltipModule.reinitScene (TooltipModule.js:179:31)
    at Drawer.initScene (Drawer.js:439:16)
    at Drawer.reinitScene (Drawer.js:625:12)
    at Drawer.reinit (Drawer.js:653:14)
    at Drawer.animate (Drawer.js:686:18)

Because the containers are not created.

I don't know if you noticed that and if we should change the doc.

CGjupoulton commented 1 year ago

Good point, if possible the tooltipmodule should be updated to either allow for this (hard), or detect the problem and print a warning.

Butanium commented 1 year ago

I think that detecting the problem with a warning would be enough. Let me know if you fix this issue so that I can include the same warning in my next module (https://github.com/CodinGame/codingame-game-engine/pull/66)

CGjupoulton commented 1 year ago

In version v4.3.2, dependencies between modules will be checked on load.

CGjupoulton commented 1 year ago

@Butanium FYI, you can see what declared dependencies look like here: https://github.com/CodinGame/codingame-game-engine/commit/ecd08da23e0d809e36e5c9230e45ace8fa585aeb

CGjupoulton commented 1 year ago

@Butanium I hope replacing your camera module's name "c" with a longer "camera" won't overcharge your game.json files?

Butanium commented 1 year ago

@Butanium I hope replacing your camera module's name "c" with a longer "camera" won't overcharge your game.json files?

No worries, I still use my local version of the module. Thanks for letting me know the declared dependency syntax (will use it in #66 )