コード例 #1
0
    private void DoAutoSave(int day)
    {
        if (!GenericGameSettings.instance.disableAutosave)
        {
            day++;
            newDayMetric[NewCycleKey] = day;
            ThreadedHttps <KleiMetrics> .Instance.SendEvent(newDayMetric);

            string text = SaveLoader.GetActiveSaveFilePath();
            if (text == null)
            {
                text = SaveLoader.GetAutosaveFilePath();
            }
            int num = text.LastIndexOf("\\");
            if (num > 0)
            {
                int num2 = text.IndexOf(" Cycle ", num);
                if (num2 > 0)
                {
                    text = text.Substring(0, num2);
                }
            }
            text = text.Replace(".sav", string.Empty);
            text = text + " Cycle " + day.ToString();
            text = SaveScreen.GetValidSaveFilename(text);
            string autoSavePrefix = SaveLoader.GetAutoSavePrefix();
            text = Path.Combine(autoSavePrefix, Path.GetFileName(text));
            string text2 = text;
            int    num3  = 1;
            while (File.Exists(text))
            {
                text = text2.Replace(".sav", string.Empty);
                text = SaveScreen.GetValidSaveFilename(text2 + " (" + num3 + ")");
                num3++;
            }
            Game.Instance.StartDelayedSave(text, true, false);
        }
    }
コード例 #2
0
    public void OnKeyDown(KButtonEvent e)
    {
        if (!enabled)
        {
            return;
        }
        if (e.TryConsume(Action.DebugSpawnMinion))
        {
            SpawnMinion();
        }
        else if (e.TryConsume(Action.DebugSpawnStressTest))
        {
            for (int i = 0; i < 60; i++)
            {
                SpawnMinion();
            }
        }
        else if (e.TryConsume(Action.DebugSuperTestMode))
        {
            if (!superTestMode)
            {
                Time.timeScale = 15f;
                superTestMode  = true;
            }
            else
            {
                Time.timeScale = 1f;
                superTestMode  = false;
            }
        }
        else if (e.TryConsume(Action.DebugUltraTestMode))
        {
            if (!ultraTestMode)
            {
                Time.timeScale = 30f;
                ultraTestMode  = true;
            }
            else
            {
                Time.timeScale = 1f;
                ultraTestMode  = false;
            }
        }
        else if (e.TryConsume(Action.DebugSlowTestMode))
        {
            if (!slowTestMode)
            {
                Time.timeScale = 0.06f;
                slowTestMode   = true;
            }
            else
            {
                Time.timeScale = 1f;
                slowTestMode   = false;
            }
        }
        else if (e.TryConsume(Action.DebugDig))
        {
            int mouseCell = GetMouseCell();
            SimMessages.Dig(mouseCell, -1);
        }
        else if (e.TryConsume(Action.DebugInstantBuildMode))
        {
            InstantBuildMode = !InstantBuildMode;
            if ((UnityEngine.Object)Game.Instance == (UnityEngine.Object)null)
            {
                return;
            }
            if ((UnityEngine.Object)PlanScreen.Instance != (UnityEngine.Object)null)
            {
                PlanScreen.Instance.Refresh();
            }
            if ((UnityEngine.Object)BuildMenu.Instance != (UnityEngine.Object)null)
            {
                BuildMenu.Instance.Refresh();
            }
            if ((UnityEngine.Object)OverlayMenu.Instance != (UnityEngine.Object)null)
            {
                OverlayMenu.Instance.Refresh();
            }
            if ((UnityEngine.Object)ConsumerManager.instance != (UnityEngine.Object)null)
            {
                ConsumerManager.instance.RefreshDiscovered(null);
            }
            if ((UnityEngine.Object)ManagementMenu.Instance != (UnityEngine.Object)null)
            {
                ManagementMenu.Instance.CheckResearch(null);
                ManagementMenu.Instance.CheckSkills(null);
                ManagementMenu.Instance.CheckStarmap(null);
            }
            Game.Instance.Trigger(1594320620, "all_the_things");
        }
        else if (e.TryConsume(Action.DebugExplosion))
        {
            Vector3 mousePos = KInputManager.GetMousePos();
            Vector3 position = Camera.main.transform.GetPosition();
            mousePos.z = 0f - position.z - Grid.CellSizeInMeters;
            Vector3 explosion_pos = Camera.main.ScreenToWorldPoint(mousePos);
            GameUtil.CreateExplosion(explosion_pos);
        }
        else if (e.TryConsume(Action.DebugLockCursor))
        {
            if (GenericGameSettings.instance.developerDebugEnable)
            {
                KInputManager.isMousePosLocked = !KInputManager.isMousePosLocked;
                KInputManager.lockedMousePos   = KInputManager.GetMousePos();
            }
        }
        else if (e.TryConsume(Action.DebugDiscoverAllElements))
        {
            if ((UnityEngine.Object)WorldInventory.Instance != (UnityEngine.Object)null)
            {
                foreach (Element element in ElementLoader.elements)
                {
                    WorldInventory.Instance.Discover(element.tag, element.GetMaterialCategoryTag());
                }
            }
        }
        else if (e.TryConsume(Action.DebugToggleUI))
        {
            ToggleScreenshotMode();
        }
        else if (e.TryConsume(Action.SreenShot1x))
        {
            string filename = Path.ChangeExtension(SaveLoader.GetActiveSaveFilePath(), ".png");
            ScreenCapture.CaptureScreenshot(filename, 1);
        }
        else if (e.TryConsume(Action.SreenShot2x))
        {
            string filename2 = Path.ChangeExtension(SaveLoader.GetActiveSaveFilePath(), ".png");
            ScreenCapture.CaptureScreenshot(filename2, 2);
        }
        else if (e.TryConsume(Action.SreenShot8x))
        {
            string filename3 = Path.ChangeExtension(SaveLoader.GetActiveSaveFilePath(), ".png");
            ScreenCapture.CaptureScreenshot(filename3, 8);
        }
        else if (e.TryConsume(Action.SreenShot32x))
        {
            string filename4 = Path.ChangeExtension(SaveLoader.GetActiveSaveFilePath(), ".png");
            ScreenCapture.CaptureScreenshot(filename4, 32);
        }
        else if (e.TryConsume(Action.DebugCellInfo))
        {
            DebugCellInfo = !DebugCellInfo;
        }
        else if (e.TryConsume(Action.DebugToggle))
        {
            if ((UnityEngine.Object)Game.Instance != (UnityEngine.Object)null)
            {
                Game.Instance.UpdateGameActiveRegion(0, 0, Grid.WidthInCells, Grid.HeightInCells);
                SaveGame.Instance.worldGenSpawner.SpawnEverything();
            }
            if ((UnityEngine.Object)DebugPaintElementScreen.Instance != (UnityEngine.Object)null)
            {
                bool activeSelf = DebugPaintElementScreen.Instance.gameObject.activeSelf;
                DebugPaintElementScreen.Instance.gameObject.SetActive(!activeSelf);
                if ((bool)DebugElementMenu.Instance && DebugElementMenu.Instance.root.activeSelf)
                {
                    DebugElementMenu.Instance.root.SetActive(false);
                }
                DebugBaseTemplateButton.Instance.gameObject.SetActive(!activeSelf);
                PropertyTextures.FogOfWarScale = (float)((!activeSelf) ? 1 : 0);
                if ((UnityEngine.Object)CameraController.Instance != (UnityEngine.Object)null)
                {
                    CameraController.Instance.EnableFreeCamera(!activeSelf);
                }
            }
        }
        else if (e.TryConsume(Action.DebugCollectGarbage))
        {
            GC.Collect();
        }
        else if (e.TryConsume(Action.DebugInvincible))
        {
            InvincibleMode = !InvincibleMode;
        }
        else if (e.TryConsume(Action.DebugVisualTest))
        {
            Scenario.Instance.SetupVisualTest();
        }
        else if (e.TryConsume(Action.DebugGameplayTest))
        {
            Scenario.Instance.SetupGameplayTest();
        }
        else if (e.TryConsume(Action.DebugElementTest))
        {
            Scenario.Instance.SetupElementTest();
        }
        else if (e.TryConsume(Action.ToggleProfiler))
        {
            Sim.SIM_HandleMessage(-409964931, 0, null);
        }
        else if (e.TryConsume(Action.DebugRefreshNavCell))
        {
            Pathfinding.Instance.RefreshNavCell(GetMouseCell());
        }
        else if (e.TryConsume(Action.DebugToggleSelectInEditor))
        {
            SetSelectInEditor(!SelectInEditor);
        }
        else if (e.TryConsume(Action.DebugGotoTarget))
        {
            Debug.Log("Debug GoTo");
            Game.Instance.Trigger(775300118, null);
            foreach (Brain item in Components.Brains.Items)
            {
                item.GetSMI <DebugGoToMonitor.Instance>()?.GoToCursor();
                item.GetSMI <CreatureDebugGoToMonitor.Instance>()?.GoToCursor();
            }
        }
        else if (e.TryConsume(Action.DebugTeleport))
        {
            if ((UnityEngine.Object)SelectTool.Instance == (UnityEngine.Object)null)
            {
                return;
            }
            KSelectable selected = SelectTool.Instance.selected;
            if ((UnityEngine.Object)selected != (UnityEngine.Object)null)
            {
                int mouseCell2 = GetMouseCell();
                if (!Grid.IsValidBuildingCell(mouseCell2))
                {
                    PopFXManager.Instance.SpawnFX(PopFXManager.Instance.sprite_Negative, UI.DEBUG_TOOLS.INVALID_LOCATION, null, GetMousePos(), 1.5f, false, true);
                    return;
                }
                selected.transform.SetPosition(Grid.CellToPosCBC(mouseCell2, Grid.SceneLayer.Move));
            }
        }
        else if (!e.TryConsume(Action.DebugPlace) && !e.TryConsume(Action.DebugSelectMaterial))
        {
            if (e.TryConsume(Action.DebugNotification))
            {
                if (GenericGameSettings.instance.developerDebugEnable)
                {
                    Tutorial.Instance.DebugNotification();
                }
            }
            else if (e.TryConsume(Action.DebugNotificationMessage))
            {
                if (GenericGameSettings.instance.developerDebugEnable)
                {
                    Tutorial.Instance.DebugNotificationMessage();
                }
            }
            else if (e.TryConsume(Action.DebugSuperSpeed))
            {
                if ((UnityEngine.Object)SpeedControlScreen.Instance != (UnityEngine.Object)null)
                {
                    SpeedControlScreen.Instance.ToggleRidiculousSpeed();
                }
            }
            else if (e.TryConsume(Action.DebugGameStep))
            {
                if ((UnityEngine.Object)SpeedControlScreen.Instance != (UnityEngine.Object)null)
                {
                    SpeedControlScreen.Instance.DebugStepFrame();
                }
            }
            else if (e.TryConsume(Action.DebugSimStep))
            {
                Game.Instance.ForceSimStep();
            }
            else if (e.TryConsume(Action.DebugToggleMusic))
            {
                AudioDebug.Get().ToggleMusic();
            }
            else if (e.TryConsume(Action.DebugRiverTest))
            {
                Scenario.Instance.SetupRiverTest();
            }
            else if (e.TryConsume(Action.DebugTileTest))
            {
                Scenario.Instance.SetupTileTest();
            }
            else if (e.TryConsume(Action.DebugForceLightEverywhere))
            {
                PropertyTextures.instance.ForceLightEverywhere = !PropertyTextures.instance.ForceLightEverywhere;
            }
            else if (e.TryConsume(Action.DebugPathFinding))
            {
                DebugPathFinding = !DebugPathFinding;
                Debug.Log("DebugPathFinding=" + DebugPathFinding);
            }
            else if (!e.TryConsume(Action.DebugFocus))
            {
                if (e.TryConsume(Action.DebugReportBug))
                {
                    if (GenericGameSettings.instance.developerDebugEnable)
                    {
                        int    num = 0;
                        string validSaveFilename;
                        while (true)
                        {
                            validSaveFilename = SaveScreen.GetValidSaveFilename("bug_report_savefile_" + num.ToString());
                            if (!File.Exists(validSaveFilename))
                            {
                                break;
                            }
                            num++;
                        }
                        string save_file = "No save file (front end)";
                        if ((UnityEngine.Object)SaveLoader.Instance != (UnityEngine.Object)null)
                        {
                            save_file = SaveLoader.Instance.Save(validSaveFilename, false, false);
                        }
                        KCrashReporter.ReportBug("Bug Report", save_file);
                    }
                    else
                    {
                        Debug.Log("Debug crash keys are not enabled.");
                    }
                }
                else if (e.TryConsume(Action.DebugTriggerException))
                {
                    if (GenericGameSettings.instance.developerDebugEnable)
                    {
                        string     str        = Guid.NewGuid().ToString();
                        StackTrace stackTrace = new StackTrace(1, true);
                        str = str + "\n" + stackTrace.ToString();
                        KCrashReporter.ReportError("Debug crash with random stack", str, null, ScreenPrefabs.Instance.ConfirmDialogScreen, string.Empty);
                    }
                }
                else if (e.TryConsume(Action.DebugTriggerError))
                {
                    if (GenericGameSettings.instance.developerDebugEnable)
                    {
                        Debug.LogError("Oooops! Testing error!");
                    }
                }
                else if (e.TryConsume(Action.DebugDumpGCRoots))
                {
                    GarbageProfiler.DebugDumpRootItems();
                }
                else if (e.TryConsume(Action.DebugDumpGarbageReferences))
                {
                    GarbageProfiler.DebugDumpGarbageStats();
                }
                else if (e.TryConsume(Action.DebugDumpEventData))
                {
                    if (GenericGameSettings.instance.developerDebugEnable)
                    {
                        KObjectManager.Instance.DumpEventData();
                    }
                }
                else if (e.TryConsume(Action.DebugDumpSceneParitionerLeakData))
                {
                    if (!GenericGameSettings.instance.developerDebugEnable)
                    {
                        goto IL_0b5e;
                    }
                }
                else if (e.TryConsume(Action.DebugCrashSim))
                {
                    if (GenericGameSettings.instance.developerDebugEnable)
                    {
                        Sim.SIM_DebugCrash();
                    }
                }
                else if (e.TryConsume(Action.DebugNextCall))
                {
                    DebugNextCall = true;
                }
                else if (e.TryConsume(Action.DebugTogglePersonalPriorityComparison))
                {
                    Chore.ENABLE_PERSONAL_PRIORITIES = !Chore.ENABLE_PERSONAL_PRIORITIES;
                }
            }
        }
        goto IL_0b5e;
IL_0b5e:
        if (e.Consumed && (UnityEngine.Object)Game.Instance != (UnityEngine.Object)null)
        {
            Game.Instance.debugWasUsed  = true;
            KCrashReporter.debugWasUsed = true;
        }
    }