CitiesSkylinesMods / TMPE

Cities: Skylines Traffic Manager: President Edition
https://steamcommunity.com/sharedfiles/filedetails/?id=1637663252
MIT License
564 stars 85 forks source link

Compatibility checks should be skipped during hot reload #727

Open originalfoo opened 4 years ago

originalfoo commented 4 years ago

While they don't take much time, compatibility checks should still be completely skipped during hot reload. This can likely be achieved through active scene checking.

Ideally compatibilty classes should be changed from static to instance-based (see also: #211), and completely bypass firing up the instances.

@kianzarrin Any comments on detecting in-game hotload?

kianzarrin commented 4 years ago

Any comments on detecting in-game hotload?

There are several ways of checking whether we are in game or not each of them with minor differences. Those minor differences don't matter as far as checking for incompatible mods are concerned. So both of these methods work:

  1. One way as you said is to check the scene.
  2. Another way is to check LoadingExtension.InGame (which checks app mode)

I suspect 99% of the hot-reload time is spent on Harmony.

originalfoo commented 4 years ago

Yup. I've decided to keep static methods and stuff for now as it's just so much simpler than managing instance lifecycle. But the compatibility checks will now be skipped if a hot-reload occurs in-game.

EDIT: If nothing else it will reduce stuff going in to log file which should make finding any debug trace a little bit quicker.

originalfoo commented 4 years ago
Debug 827.3824706: CompatibilityManager.Activate() Scene = Game
Debug 827.3830747: - Skipping due to in-game hot reload