public static void SaveOnEntry(SubRoot __instance) { if (UnityEngine.Time.timeSinceLevelLoad < 10.0f) { return; // Save game load } if (__instance != null) { if (__instance.isBase && settings.PlayerBase.SaveOnEntry) { if (!settings.PlayerBase.SaveEvenWhenFloodedOrDamaged && __instance.IsLeaking()) { log("Base is leaking and settings.PlayerBase.SaveEvenWhenFloodedOrDamaged is set to false, skipping autosave!"); return; } ForceSave(settings.PlayerBase.PauseIntervalInSeconds); } else if (__instance.isCyclops && settings.Cyclops.SaveOnEntry) { // Get SubRoot.live LiveMixin live = null; { FieldInfo f_live = __instance.GetType().GetField("live", BindingFlags.NonPublic | BindingFlags.Instance); var v_live = f_live?.GetValue(__instance); live = v_live == null ? (LiveMixin)v_live : null; } if (live == null) { log("Could not get SubRoot.live on Cyclops entry, skipping autosave!"); return; } if (!settings.Cyclops.SaveEvenWhenFloodedOrDamaged && (__instance.IsLeaking() || live.GetHealthFraction() < 1.0f)) { log("Cyclops is leaking and/or is damaged, and settings.Cyclops.SaveEvenWhenFloodedOrDamaged is set to false, skipping autosave!"); return; } ForceSave(settings.Cyclops.PauseIntervalInSeconds); } } }