Selsion / DSPMods

MIT License
10 stars 3 forks source link

Nebula compatibility #5

Open NocturnalScream opened 2 years ago

NocturnalScream commented 2 years ago

Hello, me and my friend are playing with your mod and nebula - sadly the clients game keep crashing when warping out of a system? We would be super happy if you can add nebula compatibility :) you talked about it in the readme

NocturnalScream commented 2 years ago

any chance i can maybe help?`going to look into the code a bit as well - what are the issues we are facing here?

starfi5h commented 2 years ago

It's because nebula do some behaviors that won't happen in vanilla game thus breaks some assumptions of DSPOptimizations. For example, nebula will unload all planet factories when client leaves a system, but StationStorageOpt doesn't change along with it.

I add a patch in NebulaCompatibilityAssist to solve this issue. You can try and check if there is anything needs fixing too. NebulaCompatibilityAssist.zip If it's ok I can update it in Thunderstore. the related change commit


Edit: A equivalence is to add this checking in DSPOptimizations.StationStorageOpt to reset data after Nebula unload the factories:

[HarmonyPostfix]
[HarmonyPatch(typeof(GameData), nameof(GameData.LeaveStar))]
public static void LeaveStar_Postfix()
{
    if (GameMain.data.factoryCount == 0)
        InitFactoryInfo(GameMain.data);
}
Jessomadic commented 2 months ago

Assuming this was never confirmed to be working. I'm willing to give it a look if that is the case