public static void Postfix(KMod.Manager __instance, List <Mod> ___mods, ref bool ___dirty) { var mod = ___mods.FirstOrDefault(m => m.label.id == LocalId || m.label.id == SteamId); if (mod == null) { return; } mod.enabled = true; ___dirty = true; __instance.Update(__instance); }
private void Awake() { KCrashReporter crash_reporter = GetComponent <KCrashReporter>(); if (((UnityEngine.Object)crash_reporter != (UnityEngine.Object)null) & (SceneInitializerLoader.ReportDeferredError == null)) { SceneInitializerLoader.ReportDeferredError = delegate(SceneInitializerLoader.DeferredError deferred_error) { crash_reporter.ShowDialog(deferred_error.msg, deferred_error.stack_trace); }; } globalCanvas = GameObject.Find("Canvas"); UnityEngine.Object.DontDestroyOnLoad(globalCanvas.gameObject); OutputSystemInfo(); Debug.Assert((UnityEngine.Object)Instance == (UnityEngine.Object)null); Instance = this; Debug.Log("Initializing at " + System.DateTime.UtcNow.ToString("yyyy-MM-dd HH:mm:ss.fff")); Debug.Log("Save path: " + Util.RootFolder()); if (forcedAtlasInitializationList != null) { SpriteAtlas[] array = forcedAtlasInitializationList; foreach (SpriteAtlas spriteAtlas in array) { int spriteCount = spriteAtlas.spriteCount; Sprite[] array2 = new Sprite[spriteCount]; spriteAtlas.GetSprites(array2); Sprite[] array3 = array2; foreach (Sprite sprite in array3) { Texture2D texture = sprite.texture; if ((UnityEngine.Object)texture != (UnityEngine.Object)null) { texture.filterMode = FilterMode.Bilinear; texture.anisoLevel = 4; texture.mipMapBias = 0f; } } } } FileSystem.Initialize(); Singleton <StateMachineUpdater> .CreateInstance(); Singleton <StateMachineManager> .CreateInstance(); Localization.RegisterForTranslation(typeof(UI)); modManager = new KMod.Manager(); modManager.Load(Content.DLL); modManager.Load(Content.Strings); KSerialization.Manager.Initialize(); mInputManager = new GameInputManager(GenerateDefaultBindings()); Audio.Get(); KAnimBatchManager.CreateInstance(); Singleton <SoundEventVolumeCache> .CreateInstance(); mAnimEventManager = new AnimEventManager(); Singleton <KBatchedAnimUpdater> .CreateInstance(); DistributionPlatform.Initialize(); Localization.Initialize(false); modManager.Load(Content.Translation); modManager.distribution_platforms.Add(new Local("Local", Label.DistributionPlatform.Local)); modManager.distribution_platforms.Add(new Local("Dev", Label.DistributionPlatform.Dev)); mainThread = Thread.CurrentThread; KProfiler.main_thread = Thread.CurrentThread; RestoreLegacyMetricsSetting(); if (DistributionPlatform.Initialized) { if (!KPrivacyPrefs.instance.disableDataCollection) { Debug.Log("Logged into " + DistributionPlatform.Inst.Name + " with ID:" + DistributionPlatform.Inst.LocalUser.Id + ", NAME:" + DistributionPlatform.Inst.LocalUser.Name); ThreadedHttps <KleiAccount> .Instance.AuthenticateUser(OnGetUserIdKey); } } else { Debug.LogWarning("Can't init " + DistributionPlatform.Inst.Name + " distribution platform..."); OnGetUserIdKey(); } modManager.Load(Content.LayerableFiles); GlobalResources.Instance(); }
private bool Load(IReader reader) { string a = reader.ReadKleiString(); Debug.Assert(a == "world"); Deserializer deserializer = new Deserializer(reader); SaveFileRoot saveFileRoot = new SaveFileRoot(); deserializer.Deserialize(saveFileRoot); SaveGame.GameInfo gameInfo = GameInfo; if (gameInfo.saveMajorVersion != 7) { SaveGame.GameInfo gameInfo2 = GameInfo; if (gameInfo2.saveMinorVersion >= 8) { goto IL_00f7; } } if (saveFileRoot.requiredMods != null) { saveFileRoot.active_mods = new List <Label>(); foreach (ModInfo requiredMod in saveFileRoot.requiredMods) { ModInfo current = requiredMod; saveFileRoot.active_mods.Add(new Label { id = current.assetID, version = current.lastModifiedTime, distribution_platform = Label.DistributionPlatform.Steam, title = current.description }); } saveFileRoot.requiredMods.Clear(); } goto IL_00f7; IL_00f7: KMod.Manager modManager = Global.Instance.modManager; modManager.Load(Content.LayerableFiles); if (!modManager.MatchFootprint(saveFileRoot.active_mods, Content.LayerableFiles | Content.Strings | Content.DLL | Content.Translation | Content.Animation)) { DebugUtil.LogWarningArgs("Mod footprint of save file doesn't match current mod configuration"); } Global.Instance.modManager.SendMetricsEvent(); string text = saveFileRoot.worldID; if (text == null) { try { text = CustomGameSettings.Instance.GetCurrentQualitySetting(CustomGameSettingConfigs.World).id; } catch { text = "worlds/SandstoneDefault"; } } Game.worldID = text; worldGen = new WorldGen(text, null); Game.LoadSettings(deserializer); GridSettings.Reset(saveFileRoot.WidthInCells, saveFileRoot.HeightInCells); Singleton <KBatchedAnimUpdater> .Instance.InitializeGrid(); Sim.SIM_Initialize(Sim.DLL_MessageHandler); SimMessages.CreateSimElementsTable(ElementLoader.elements); SimMessages.CreateDiseaseTable(); byte[] bytes = saveFileRoot.streamed["Sim"]; FastReader reader2 = new FastReader(bytes); if (Sim.Load(reader2) != 0) { DebugUtil.LogWarningArgs("\n--- Error loading save ---\nSimDLL found bad data\n"); Sim.Shutdown(); return(false); } SceneInitializer.Instance.PostLoadPrefabs(); mustRestartOnFail = true; if (!saveManager.Load(reader)) { Sim.Shutdown(); DebugUtil.LogWarningArgs("\n--- Error loading save ---\n"); SetActiveSaveFilePath(null); return(false); } Grid.Visible = saveFileRoot.streamed["GridVisible"]; if (saveFileRoot.streamed.ContainsKey("GridSpawnable")) { Grid.Spawnable = saveFileRoot.streamed["GridSpawnable"]; } Grid.Damage = BytesToFloat(saveFileRoot.streamed["GridDamage"]); Game.Instance.Load(deserializer); FastReader reader3 = new FastReader(saveFileRoot.streamed["Camera"]); CameraSaveData.Load(reader3); return(true); }