Пример #1
0
        private void Update() //called by Unity every frame
        {
            if (!Game.Manager)
            {
                return;                //don't run update code before Game.Manager exists
            }
            BasePatches.Update(); CheatPatches.Update(); InputPatches.Update(); RunTimerPatches.Update();

            if (tooltip != null)
            {
                if (tooltipTimer.ElapsedMilliseconds > tooltipLength)
                {
                    tooltipTimer.Reset();
                    tooltip.Hide();
                    tooltip = null;
                }
            }
            //if tooltip became null, stop timer
            else
            {
                tooltipTimer.Reset();
            }

            //Check for the Return hotkey
            if (ResetKey.Value.IsDown() || ResetKey2.Value.IsDown())
            {
                if (UnloadGame())
                {
                    hasReturned             = true;
                    BasePatches.searchForMe = -111;
                    if (run != null)
                    {
                        run.reset();
                        run = null;
                    }
                }
            }

            if (Input.GetKey(KeyCode.LeftControl) || Input.GetKey(KeyCode.RightControl))
            {
                //display the splits folder on Ctrl+S
                if (Input.GetKeyDown(KeyCode.S))
                {
                    if (Game.Manager.Ui.currentCanvas.titleCanvas)
                    {
                        System.Diagnostics.Process.Start(Directory.GetCurrentDirectory() + "/splits");
                    }

                    /*
                     * else if (run != null)
                     * {
                     *  run.save();
                     *  ShowNotif("Run saved!", 2);
                     * }*/
                    //don't allow saving midrun, could be done accidentally
                }
                //reset run on Ctrl+R
                if (Input.GetKeyDown(KeyCode.R) && run != null)
                {
                    run.reset(true);
                    ShowNotif("Run reset!", 2);
                }
                //quit run on Ctrl+Q
                if (Input.GetKeyDown(KeyCode.Q) && run != null)
                {
                    run.reset(false);
                    ShowNotif("Run quit!", 2);
                }
            }

            //if currently in a puzzle, and the status bar is up, and it's not nonstop mode, send data to autosplitters
            if (!Game.Manager.Ui.currentCanvas.titleCanvas && Game.Session && Game.Session.Puzzle.isPuzzleActive &&
                !Game.Session.gameCanvas.cellphone.isOpen && Game.Session.Puzzle.puzzleStatus.statusType != PuzzleStatusType.NONSTOP)
            {
                //this is a possibly bold but necessary assumption to make about cellphone._currentApp
                UiCellphoneAppStatus status = (UiCellphoneAppStatus)AccessTools.Field(typeof(UiCellphone), "_currentApp").GetValue(Game.Session.gameCanvas.cellphone);
                bool isBonusRound           = Game.Session.Puzzle.puzzleStatus.bonusRound;
                if (status.affectionMeter.currentValue == 0)
                {
                    startingRelationshipType = Game.Persistence.playerFile.GetPlayerFileGirlPair(Game.Session.Location.currentGirlPair).relationshipType;
                    startingCompletedPairs   = Game.Persistence.playerFile.completedGirlPairs.Count;
                }
                if (status.affectionMeter.currentValue == status.affectionMeter.maxValue &&
                    (Game.Session.gameCanvas.puzzleGrid.roundState == PuzzleRoundState.SUCCESS || isBonusRound))
                {
                    if (!splitThisDate && run != null)
                    {
                        bool didSplit = false;
                        //always split for the two tutorial splits
                        if (Game.Session.Location.currentGirlPair.girlDefinitionOne.girlName == "Kyu")
                        {
                            didSplit = run.split(isBonusRound);
                        }
                        //don't split for dates in 48 Shoes, or in postgame
                        else if (run.goal != 48 && Game.Persistence.playerFile.storyProgress < 13)
                        {
                            if (run.goal == 1 || SplitRules.Value <= 0)
                            {
                                didSplit = run.split(isBonusRound);
                            }
                            else if (SplitRules.Value == 1 && !isBonusRound)
                            {
                                didSplit = run.split(isBonusRound);
                            }
                            else if (SplitRules.Value == 2 && isBonusRound)
                            {
                                didSplit = run.split(isBonusRound);
                            }
                            //check for final split regardless of option
                            else if (isBonusRound && (run.goal == startingCompletedPairs + 1 ||
                                                      (run.goal == 25 && Game.Session.Puzzle.puzzleStatus.statusType == PuzzleStatusType.BOSS)))
                            {
                                didSplit = run.split(isBonusRound);
                            }
                        }
                        if (didSplit)
                        {
                            //initiate the timers for displaying and removing our split times
                            RunTimerPatches.initialTimerDelay.Start();
                            if (!isBonusRound)
                            {
                                RunTimerPatches.undoTimer.Start();
                            }

                            GirlPairDefinition pair = Game.Session.Location.currentGirlPair;
                            int dateNum             = 1;
                            if (startingRelationshipType == GirlPairRelationshipType.ATTRACTED)
                            {
                                dateNum = 2;
                            }
                            if (isBonusRound)
                            {
                                dateNum = 3;
                            }
                            //Kyu pair starts at ATTRACTED (2) and her bonus should be 2, not 3, so this is the easiest way
                            if (pair.girlDefinitionOne.girlName == "Kyu")
                            {
                                dateNum--;
                            }
                            if (Game.Session.Puzzle.puzzleStatus.statusType == PuzzleStatusType.BOSS)
                            {
                                dateNum = 5 - (Game.Session.Puzzle.puzzleStatus.girlListCount / 2);
                            }
                            string newSplit = pair.girlDefinitionOne.girlName + " & " + pair.girlDefinitionTwo.girlName;
                            //don't put a number on the date if they started as lovers, or it's nonstop mode? (for 100%)
                            //the storyProgress check probably makes this pointless
                            if (startingRelationshipType != GirlPairRelationshipType.LOVERS &&
                                Game.Session.Puzzle.puzzleStatus.statusType != PuzzleStatusType.NONSTOP)
                            {
                                newSplit += " #" + dateNum;
                            }
                            newSplit += "\n      " + run.splitText + "\n";
                            run.push(newSplit);

                            if (isBonusRound && pair.girlDefinitionOne.girlName != "Kyu")
                            {
                                //I think it's possible that, with a huge chain reaction, completedGirlPairs.Count might not have updated yet
                                //so use the number from before the date, +1
                                //funnily enough, that also makes the final boss's goal of "25" count
                                //but I'll leave the double-check there
                                if (run.goal == startingCompletedPairs + 1 ||
                                    (run.goal == 25 && Game.Session.Puzzle.puzzleStatus.statusType == PuzzleStatusType.BOSS))
                                {
                                    Logger.LogMessage("initiating run.save");
                                    if (run.rerollOccurred)
                                    {
                                        run.push("\n(Rerolled for Lillian)\n");
                                    }
                                    //run.save();
                                    RunTimerPatches.savePBDelay.Start();
                                }
                            }
                        }
                    }

                    if (isBonusRound)
                    {
                        BasePatches.searchForMe = 200;
                    }
                    else
                    {
                        BasePatches.searchForMe = 100;
                    }

                    splitThisDate = true;
                }

                else
                {
                    BasePatches.searchForMe = 0;
                    splitThisDate           = false;
                }
            }

            //title-screen only options, to prevent non-vanilla things happening midrun
            if (Game.Manager.Ui.currentCanvas.titleCanvas)
            {
                UiTitleCanvas tc        = (UiTitleCanvas)Game.Manager.Ui.currentCanvas;
                bool          isLoading = (bool)AccessTools.Field(typeof(UiTitleCanvas), "_loadingGame").GetValue(tc);
                //display New Version tooltip for 10 seconds
                if (newVersionAvailable && !alertedOfUpdate)
                {
                    alertedOfUpdate = true;
                    ShowTooltip("Update Available!\nClick on Credits!", 10000, 0, 45);
                }

                if (!InputPatches.codeScreen && Input.GetKeyDown(KeyCode.A))
                {
                    CodeDefinition codeDefinition = Game.Data.Codes.Get(ABIAHAIR);
                    if (!Game.Persistence.playerData.unlockedCodes.Contains(codeDefinition))
                    {
                        Game.Persistence.playerData.unlockedCodes.Add(codeDefinition);
                        ShowTooltip("Abia's Hair Enabled!", 2000);
                    }
                    else
                    {
                        Game.Persistence.playerData.unlockedCodes.Remove(codeDefinition);
                        ShowTooltip("Abia's Hair Disabled!", 2000);
                    }
                    Game.Manager.Ui.currentCanvas.GetComponent <UiTitleCanvas>().coverArt.Refresh();
                }

                //check for Kyu outfits
                if (Input.GetKey(KeyCode.K))
                {
                    bool hairstyle = (Input.GetKey(KeyCode.LeftControl) || Input.GetKey(KeyCode.RightControl));
                    for (int i = (int)KeyCode.Alpha0; i <= (int)KeyCode.Alpha5; i++)
                    {
                        //Alpha0 = 48, Keypad0 = 256
                        int num = i - 48;
                        if ((Input.GetKeyDown((KeyCode)i) || Input.GetKeyDown((KeyCode)(i + 208))))
                        {
                            SetKyuOutfit(num, hairstyle);
                            string s = "Kyu ";
                            if (hairstyle)
                            {
                                s += "Hairstyle #";
                            }
                            else
                            {
                                s += "Outfit #";
                            }
                            s += num + " Chosen!";
                            ShowTooltip(s, 2000);
                        }
                    }
                }

                //check for the Cheat Mode hotkey
                if (!InputPatches.codeScreen && cheatsEnabled == false && !isLoading && CheatHotkey.Value.IsDown())
                {
                    Game.Manager.Audio.Play(AudioCategory.SOUND, Game.Manager.Ui.sfxReject);
                    PlayCheatLine();
                    Harmony.CreateAndPatchAll(typeof(CheatPatches), null);
                    CheatPatches.UnlockAllCodes();
                    ShowTooltip("Cheat Mode Activated!", 2000, 0, 30);
                    cheatsEnabled = true;
                }
            }
        }
Пример #2
0
        void Start()
        {
            //I can't believe the game doesn't run in background by default
            Application.runInBackground = true;
            //allow max 144fps
            if (!VsyncEnabled.Value)
            {
                QualitySettings.vSyncCount = 0;
                if (CapAt144.Value)
                {
                    Application.targetFrameRate = 144;
                }
                else
                {
                    Application.targetFrameRate = 60;
                }
            }

            //Create the splits files for the first time if they don't exist
            if (!System.IO.Directory.Exists("splits"))
            {
                System.IO.Directory.CreateDirectory("splits");
                System.IO.Directory.CreateDirectory("splits/data");
            }
            RunTimer.ConvertOldSplits();

            //Check for a new update
            WebClient client = new WebClient();

            try
            {
                string reply = client.DownloadString("https://pastebin.com/raw/5z5PsCqr");

                if (reply != PluginVersion)
                {
                    newVersionAvailable = true;
                }
            }
            catch (Exception e) { Logger.LogMessage("Couldn't read the update pastebin! " + e.ToString()); }

            //initiate the variable used for autosplitting
            Harmony.CreateAndPatchAll(typeof(BasePatches), null); BasePatches.InitSearchForMe();
            Harmony.CreateAndPatchAll(typeof(CensorshipPatches), null);
            Harmony.CreateAndPatchAll(typeof(InputPatches), null);
            if (InGameTimer.Value)
            {
                Harmony.CreateAndPatchAll(typeof(RunTimerPatches), null);
            }
            if (AllPairsEnabled.Value)
            {
                Harmony.CreateAndPatchAll(typeof(AllPairsPatches), null);
            }

            string both = MouseKeys.Value + "," + ControllerKeys.Value;

            string[] keys          = both.Split(',');
            string   validKeycodes = "Mouse button bound to keys/buttons: ";

            for (int i = 0; i < keys.Length; i++)
            {
                keys[i] = keys[i].Trim();
                KeyCode kc = KeyCode.None;
                try
                {
                    kc = (KeyCode)System.Enum.Parse(typeof(KeyCode), keys[i]);
                }
                catch { Logger.LogMessage(keys[i] + " is not a valid keycode name!"); }
                if (kc != KeyCode.None)
                {
                    InputPatches.mouseKeyboardKeys.Add(kc);
                    validKeycodes += keys[i] + ", ";
                }
            }
            Logger.LogMessage(validKeycodes);
        }