Closed ihsoft closed 1 year ago
Does this mod try to access icons from the constructor?
In essense the order is the one you said. But this is in terms of Timberborn.
This means that in the constructor there will be no initialization, this is done by the singleton system. In TimberApi's case ITimberApiSingleton, which is called as very first.
Yes, it happen in the constructor. Specifically, here: https://github.com/ihsoft/KyP-timberborn-mods/blob/main/DraggableUtils/Configurators/DraggableUtilsConfigurator.cs#L29. I added configurator annotation to DraggableUtilsConfigurator
and expected this class not to be constructed until InGame
state is in effect. Apparently, DraggableUtilsConfigurator
class gets instantiated before the asset switch. It can be worked around when you know it (and that's what I eventually did), but it looks non-intuitive.
I actually don't understand why it was working in update 3. This has not been changed as far I can see on our side since the update. Best guess I could make is that some changes were made and now get's loaded earlier than before.
I tested some small things and it probably would be possible to load the assets earlier but this won't be implemented unless really needed. Because it will have an higher chance of breaking other things by not obying the dependency injection ordering.
Making the ToolGroups like this will also become obsolete with the new feature that will hit before or fast after update 4 is launched.
I've been migrating an old mod to Update 4 and got hit by error that the assest for the tool icon doesn't exist (BottomBarModuleProvider in configurator). The asset was set to load
InGame
. The configurator is annoteded with[Configurator(SceneEntrypoint.InGame)]
.After some troubleshooting, it turned out that the asset loading works kind of unexpected. Here is the log after triggering the saved game load :
So, its seems that confiurator is triggered before the related assets get loaded. I'd suggest that the right orded should be:
MainMenu
assets.InGame
asssets.InGame
configurators.