derail-valley-modding / custom-car-loader

A Derail Valley mod that allows the addition of new cars and locomotive types to the game.
https://nexusmods.com/derailvalley/mods/324
MIT License
14 stars 6 forks source link

Fixed cars getting unloaded when reloading saves. #200

Closed WhistleWiz closed 10 months ago

WhistleWiz commented 10 months ago

Added Handcart case to bogie alignment. Cleaned up some code.

About the cars getting unloaded. I don't actually know how it works. I believe DV will force unload an asset bundle it believes unused with unloadAllLoadedObjects set to true as a resource saving measure. This would cause all already loaded models, textures, etc, from a car to get force unloaded. So instead of allowing the game to unload the bundle, we unload it first ourselves with that parameter set to false. As such, the game will not find a bundle to unload, and the assets we loaded will stay. In addition to this, I believe this opens the possibility of hotreloading in the future, as we can load the same asset bundle again. However, I have no knowledge on this matter, and this was just a lucky guess.