protected void UpdateText() { var component = GetComponent <Text>(); var dateTimeOfBuild = SNUtils.GetDateTimeOfBuild(); var plasticChangeSetOfBuild = SNUtils.GetPlasticChangeSetOfBuild(); component.text = Language.main.GetFormat("EarlyAccessWatermarkFormat", dateTimeOfBuild, plasticChangeSetOfBuild) + "\nScaphandre Engine v" + Scaphandre.Version; if (!Scaphandre.IsStableRelease) { component.text += "\n<color=#FF00007F>You're using an unstable release of Scaphandre!</color>"; } }
internal GameDetector() { bool isSubnautica = Directory.GetFiles(Environment.CurrentDirectory, "Subnautica.exe", SearchOption.TopDirectoryOnly).Length > 0 || Directory.GetDirectories(Environment.CurrentDirectory, "Subnautica.app", SearchOption.TopDirectoryOnly).Length > 0; bool isBelowZero = Directory.GetFiles(Environment.CurrentDirectory, "SubnauticaZero.exe", SearchOption.TopDirectoryOnly).Length > 0 || Directory.GetDirectories(Environment.CurrentDirectory, "SubnauticaZero.app", SearchOption.TopDirectoryOnly).Length > 0; if (isSubnautica && !isBelowZero) { Logger.Info("Detected game: Subnautica"); CurrentlyRunningGame = QModGame.Subnautica; } else if (isBelowZero && !isSubnautica) { Logger.Info("Detected game: BelowZero"); CurrentlyRunningGame = QModGame.BelowZero; } else if (isSubnautica && isBelowZero) { Logger.Fatal("A fatal error has occurred. Both Subnautica and Below Zero files detected!"); throw new FatalPatchingException("Both Subnautica and Below Zero files detected!"); } else { Logger.Fatal("A fatal error has occurred. No game executable was found!"); throw new FatalPatchingException("No game executable was found!"); } Logger.Info($"Game Version: {SNUtils.GetPlasticChangeSetOfBuild()} Build Date: {SNUtils.GetDateTimeOfBuild():dd-MMMM-yyyy}"); Logger.Info($"Loading QModManager v{Assembly.GetExecutingAssembly().GetName().Version.ToStringParsed()}{(IsValidGameRunning && MinimumBuildVersion != 0 ? $" built for {CurrentlyRunningGame} v{MinimumBuildVersion}" : string.Empty)}..."); Logger.Info($"Today is {DateTime.Today:dd-MMMM-yyyy}"); CurrentGameVersion = SNUtils.GetPlasticChangeSetOfBuild(-1); if (!IsValidGameVersion) { Logger.Fatal("A fatal error has occurred. An invalid game version was detected!"); throw new FatalPatchingException("An invalid game version was detected!"); } }
internal static void Patch() { try { if (Patched) { Logger.Warn("Patch method was called multiple times!"); return; // Halt patching } Patched = true; Logger.Info("Game Version: " + SNUtils.GetPlasticChangeSetOfBuild() + " Build Date: " + SNUtils.GetDateTimeOfBuild().ToLongDateString()); Logger.Info($"Loading QModManager v{Assembly.GetExecutingAssembly().GetName().Version.ToStringParsed()}..."); Logger.Info($"Today is {DateTime.Today:dd-MMMM-yyyy}"); if (QModBaseDir == null) { Logger.Fatal("A fatal error has occurred."); Logger.Fatal("There was an error with the QMods directory"); Logger.Fatal("Please make sure that you ran Subnautica from Steam/Epic/Discord, and not from the executable file!"); new Dialog() { message = "A fatal error has occurred. QModManager could not be initialized.", color = Dialog.DialogColor.Red, leftButton = Dialog.Button.SeeLog, rightButton = Dialog.Button.Close, }.Show(); return; } try { Logger.Info($"Folder structure:\n{IOUtilities.GetFolderStructureAsTree()}\n"); } catch (Exception e) { Logger.Error("There was an error while trying to display the folder structure."); Logger.Exception(e); } PirateCheck.IsPirate(Environment.CurrentDirectory); var gameDetector = new GameDetector(); if (!gameDetector.IsValidGameRunning) { return; } CurrentlyRunningGame = gameDetector.CurrentlyRunningGame; try { PatchHarmony(); } catch (Exception e) { Logger.Error("There was an error while trying to apply Harmony patches."); Logger.Exception(e); } if (NitroxCheck.IsInstalled) { Logger.Fatal($"Nitrox was detected!"); new Dialog() { message = "Both QModManager and Nitrox detected. QModManager is not compatible with Nitrox. Please uninstall one of them.", leftButton = Dialog.Button.Disabled, rightButton = Dialog.Button.Disabled, color = Dialog.DialogColor.Red, }.Show(); return; } VersionCheck.Check(); Logger.Info("Started loading mods"); AddAssemblyResolveEvent(); IQModFactory modFactory = new QModFactory(); List <QMod> modsToLoad = modFactory.BuildModLoadingList(QModBaseDir); QModServices.LoadKnownMods(modsToLoad); var initializer = new Initializer(CurrentlyRunningGame); initializer.InitializeMods(modsToLoad); SummaryLogger.ReportIssues(modsToLoad); SummaryLogger.LogSummaries(modsToLoad); } catch (FatalPatchingException pEx) { Logger.Fatal($"A fatal patching exception has been caught! Patching ended prematurely!"); Logger.Exception(pEx); new Dialog() { message = "A fatal patching exception has been caught. QModManager could not be initialized.", color = Dialog.DialogColor.Red, leftButton = Dialog.Button.SeeLog, }.Show(); } catch (Exception e) { Logger.Fatal("An unhandled exception has been caught! Patching ended prematurely!"); Logger.Exception(e); new Dialog() { message = "An unhandled exception has been caught. QModManager could not be initialized.", color = Dialog.DialogColor.Red, leftButton = Dialog.Button.SeeLog, }.Show(); } }
internal static bool ApplyFix() => (Patcher.CurrentlyRunningGame == API.QModGame.BelowZero || SNUtils.GetPlasticChangeSetOfBuild(65271) < 65271);