Exemplo n.º 1
0
        public void ClearCheck(Run run, RunReport runReport)
        {
            if (run is null)
            {
                return;
            }
            if (runReport is null)
            {
                return;
            }

            if (!runReport.gameEnding)
            {
                return;
            }

            if (runReport.gameEnding.isWin)
            {
                DifficultyDef difficultyDef = DifficultyCatalog.GetDifficultyDef(runReport.ruleBook.FindDifficulty());

                if (difficultyDef != null && difficultyDef.nameToken == "DIFFICULTY_TYPHOON_NAME")
                {
                    if (base.meetsBodyRequirement)
                    {
                        base.Grant();
                    }
                }
            }
        }
Exemplo n.º 2
0
        private static RuleDef InitialiseRuleBookAndFinalizeList(On.RoR2.RuleDef.orig_FromDifficulty orig)
        {
            RuleDef ruleChoices = orig();
            var     vanillaDefs = typeof(DifficultyCatalog).GetFieldValue <DifficultyDef[]>("difficultyDefs");

            if (difficultyAlreadyAdded == false)  //Technically this function we are hooking is only called once, but in the weird case it's called multiple times, we don't want to add the definitions again.
            {
                difficultyAlreadyAdded = true;
                for (int i = 0; i < vanillaDefs.Length; i++)
                {
                    difficultyDefinitions.Insert(i, vanillaDefs[i]);
                }
            }

            for (int i = vanillaDefs.Length; i < difficultyDefinitions.Count; i++)  //This basically replicates what the orig does, but that uses the hardcoded enum.Count to end it's loop, instead of the actual array length.
            {
                DifficultyDef difficultyDef = difficultyDefinitions[i];
                RuleChoiceDef choice        = ruleChoices.AddChoice(Language.GetString(difficultyDef.nameToken), null, false);
                choice.spritePath       = difficultyDef.iconPath;
                choice.tooltipNameToken = difficultyDef.nameToken;
                choice.tooltipNameColor = difficultyDef.color;
                choice.tooltipBodyToken = difficultyDef.descriptionToken;
                choice.difficultyIndex  = (DifficultyIndex)i;
            }

            ruleChoices.choices.Sort(delegate(RuleChoiceDef x, RuleChoiceDef y) {
                var xDiffValue = DifficultyCatalog.GetDifficultyDef(x.difficultyIndex).scalingValue;
                var yDiffValue = DifficultyCatalog.GetDifficultyDef(y.difficultyIndex).scalingValue;
                return(xDiffValue.CompareTo(yDiffValue));
            });

            return(ruleChoices);
        }
Exemplo n.º 3
0
        public void ClearCheck(Run run, RunReport runReport)
        {
            if (run is null)
            {
                return;
            }
            if (runReport is null)
            {
                return;
            }

            if (!runReport.gameEnding)
            {
                return;
            }

            if (runReport.gameEnding.isWin)
            {
                DifficultyDef difficultyDef = DifficultyCatalog.GetDifficultyDef(runReport.ruleBook.FindDifficulty());

                if (difficultyDef != null && difficultyDef.countsAsHardMode)
                {
                    if (UnityEngine.SceneManagement.SceneManager.GetActiveScene().name == "limbo")
                    {
                        if (base.meetsBodyRequirement)
                        {
                            Debug.Log("Is this working?");
                            base.Grant();
                        }
                    }
                }
            }
        }
Exemplo n.º 4
0
        public void ClearCheck(Run run, RunReport runReport)
        {
            if (run is null)
            {
                return;
            }
            if (runReport is null)
            {
                return;
            }

            if (!runReport.gameEnding)
            {
                return;
            }

            if (runReport.gameEnding.isWin)
            {
                DifficultyDef difficultyDef = DifficultyCatalog.GetDifficultyDef(runReport.ruleBook.FindDifficulty());

                if (difficultyDef != null && difficultyDef.countsAsHardMode)
                {
                    if (base.meetsBodyRequirement)
                    {
                        base.Grant();
                    }
                }
            }
        }
 // Token: 0x06002283 RID: 8835 RVA: 0x0009578C File Offset: 0x0009398C
 private void Start()
 {
     if (Run.instance)
     {
         DifficultyDef difficultyDef = DifficultyCatalog.GetDifficultyDef(Run.instance.selectedDifficulty);
         base.GetComponent <Image>().sprite = difficultyDef.GetIconSprite();
     }
 }
Exemplo n.º 6
0
        /// <summary>
        /// Calculates the projected increase in RoR2.Run.instance.difficultyCoefficient after a certain amount of passed time and completed stages.
        /// </summary>
        /// <param name="time">The amount of passed time to simulate.</param>
        /// <param name="stages">The number of completed stages to simulate.</param>
        /// <returns>A float representing the increase in difficulty coefficient that the given parameters would cause.</returns>
        public static float GetDifficultyCoeffIncreaseAfter(float time, int stages)
        {
            DifficultyDef difficultyDef = DifficultyCatalog.GetDifficultyDef(Run.instance.selectedDifficulty);
            float         num2          = Mathf.Floor((Run.instance.GetRunStopwatch() + time) * 0.0166666675f);
            float         num4          = 0.7f + (float)Run.instance.participatingPlayerCount * 0.3f;
            float         num7          = 0.046f * difficultyDef.scalingValue * Mathf.Pow((float)Run.instance.participatingPlayerCount, 0.2f);
            float         num9          = Mathf.Pow(1.15f, (float)Run.instance.stageClearCount + (float)stages);

            return((num4 + num7 * num2) * num9 - Run.instance.difficultyCoefficient);
        }
Exemplo n.º 7
0
        /// <summary>
        /// Add a DifficultyDef to the list of available difficulties.
        /// This must be called before the DifficultyCatalog inits, so before plugin.Start()
        /// You'll get your new index returned that you can work with for comparing to Run.Instance.selectedDifficulty.
        /// If this is called after the DifficultyCatalog inits then this will return -1/DifficultyIndex.Invalid and ignore the difficulty
        /// </summary>
        /// <param name="difficulty">The difficulty to add.</param>
        /// <returns>DifficultyIndex.Invalid if it fails. Your index otherwise.</returns>
        public static DifficultyIndex AddDifficulty(DifficultyDef difficulty)
        {
            if (difficultyAlreadyAdded)
            {
                R2API.Logger.LogError($"Tried to add difficulty: {difficulty.nameToken} after difficulty list was created");
                return(DifficultyIndex.Invalid);
            }
            difficultyDefinitions.Add(difficulty);

            return(VanillaFinalIndex + difficultyDefinitions.Count);
        }
Exemplo n.º 8
0
 static bool Prefix(Rect rect, ref StorytellerDef chosenStoryteller, ref DifficultyDef difficulty, ref Difficulty difficultyValues, Listing_Standard infoListing)
 {
     if (Find.GameInitData?.permadeathChosen == false)
     {
         Find.GameInitData.permadeathChosen = true;
         Find.GameInitData.permadeath       = false;
     }
     if (difficulty == null)
     {
         difficulty       = DifficultyDefOf.Rough;
         difficultyValues = new Difficulty(difficulty);
     }
     return(true);
 }
Exemplo n.º 9
0
        public void IncreaseDifficultyScaling()
        {
            pluginLogger.LogInfo("Created Faster Difficulty");

            Color DifficultyColor = new Color(0.94f, 0.51f, 0.15f);

            DifficultyDef FasterDef = new DifficultyDef(
                9f,             // 0 is Normal mode. 2.5f is 50% which is monsoon
                "Faster",
                ":Assets/FasterGames/DifficultyIcon.png",
                "Gotta go Faster!",
                DifficultyColor
                );
            DifficultyIndex DelugeIndex = R2API.DifficultyAPI.AddDifficulty(FasterDef);
        }
Exemplo n.º 10
0
        public void CalcDifficultyCoefficient()
        {
            Run           run           = Run.instance;
            float         num           = run.GetRunStopwatch();
            DifficultyDef difficultyDef = DifficultyCatalog.GetDifficultyDef(run.selectedDifficulty);
            float         num2          = Mathf.Floor(num * 0.0166666675f);
            float         num3          = (float)run.participatingPlayerCount * 0.3f;
            float         num4          = 0.7f + num3;
            float         num5          = 0.7f + num3;
            float         num6          = Mathf.Pow((float)run.participatingPlayerCount, 0.2f);
            float         num7          = 0.046f * difficultyDef.scalingValue * num6;
            float         num8          = 0.046f * difficultyDef.scalingValue * num6;
            float         num9          = Mathf.Pow(1.15f, (float)run.stageClearCount);

            //this.compensatedDifficultyCoefficient = (num5 + num8 * num2) * num9;
            CurrentDifficultyCoefficient = (num4 + num7 * num2) * num9;
        }
Exemplo n.º 11
0
        public static void DrawCustomStorytellerInterface(Rect rect, ref StorytellerDef chosenStoryteller, ref DifficultyDef difficulty, Listing_Standard infoListing)
        {
            //if (chosenStoryteller.defName != "StorytellerPacks") return;

            Rect storytellerPacksButton = new Rect(140f, rect.height - 50f, 190f, 38f);

            if (Widgets.ButtonText(storytellerPacksButton, "Storyteller Packs"))
            {
                Window_StorytellerPacks window = new Window_StorytellerPacks();
                Find.WindowStack.TryRemove(window.GetType());
                Find.WindowStack.Add(window);
            }
        }
Exemplo n.º 12
0
		public static void DrawStorytellerSelectionInterface_Postfix(Rect rect, ref StorytellerDef chosenStoryteller, ref DifficultyDef difficulty, Listing_Standard infoListing) {
			Widgets.CheckboxLabeled (new Rect(140f, 610f, 400f, 30f), "Completely replace vanilla animals with RimMon", ref PokemonConfig.startWith, false, null, null, true);
		}
Exemplo n.º 13
0
        // Token: 0x060022D8 RID: 8920 RVA: 0x000975E4 File Offset: 0x000957E4
        public void SetDisplayData(GameEndReportPanelController.DisplayData newDisplayData)
        {
            if (this.displayData.Equals(newDisplayData))
            {
                return;
            }
            this.displayData = newDisplayData;
            if (this.resultLabel)
            {
                GameResultType gameResultType = GameResultType.Unknown;
                if (this.displayData.runReport != null)
                {
                    gameResultType = this.displayData.runReport.gameResultType;
                }
                string token;
                if (gameResultType != GameResultType.Lost)
                {
                    if (gameResultType != GameResultType.Won)
                    {
                        token = "GAME_RESULT_UNKNOWN";
                    }
                    else
                    {
                        token = "GAME_RESULT_WON";
                    }
                }
                else
                {
                    token = "GAME_RESULT_LOST";
                }
                this.resultLabel.text = Language.GetString(token);
            }
            DifficultyIndex difficultyIndex = DifficultyIndex.Invalid;

            if (this.displayData.runReport != null)
            {
                difficultyIndex = this.displayData.runReport.ruleBook.FindDifficulty();
            }
            DifficultyDef difficultyDef = DifficultyCatalog.GetDifficultyDef(difficultyIndex);

            if (this.selectedDifficultyImage)
            {
                this.selectedDifficultyImage.sprite = ((difficultyDef != null) ? difficultyDef.GetIconSprite() : null);
            }
            if (this.selectedDifficultyLabel)
            {
                this.selectedDifficultyLabel.token = ((difficultyDef != null) ? difficultyDef.nameToken : null);
            }
            RunReport runReport = this.displayData.runReport;

            RunReport.PlayerInfo playerInfo = (runReport != null) ? runReport.GetPlayerInfoSafe(this.displayData.playerIndex) : null;
            this.SetPlayerInfo(playerInfo);
            RunReport runReport2 = this.displayData.runReport;
            int       num        = (runReport2 != null) ? runReport2.playerInfoCount : 0;

            this.playerNavigationController.gameObject.SetActive(num > 1);
            this.playerNavigationController.SetDisplayData(new CarouselNavigationController.DisplayData(num, this.displayData.playerIndex));
            ReadOnlyCollection <MPButton> elements = this.playerNavigationController.buttonAllocator.elements;

            for (int i = 0; i < elements.Count; i++)
            {
                MPButton             mpbutton                = elements[i];
                RunReport.PlayerInfo playerInfo2             = this.displayData.runReport.GetPlayerInfo(i);
                CharacterBody        bodyPrefabBodyComponent = BodyCatalog.GetBodyPrefabBodyComponent(playerInfo2.bodyIndex);
                Texture texture = bodyPrefabBodyComponent ? bodyPrefabBodyComponent.portraitIcon : null;
                mpbutton.GetComponentInChildren <RawImage>().texture = texture;
                mpbutton.GetComponent <TooltipProvider>().SetContent(TooltipProvider.GetPlayerNameTooltipContent(playerInfo2.name));
            }
            this.selectedPlayerEffectRoot.transform.SetParent(this.playerNavigationController.buttonAllocator.elements[this.displayData.playerIndex].transform);
            this.selectedPlayerEffectRoot.gameObject.SetActive(false);
            this.selectedPlayerEffectRoot.gameObject.SetActive(true);
            this.selectedPlayerEffectRoot.offsetMin  = Vector2.zero;
            this.selectedPlayerEffectRoot.offsetMax  = Vector2.zero;
            this.selectedPlayerEffectRoot.localScale = Vector3.one;
        }
 internal void CreateDifficultyDef()
 {
     DifficultyDef = new DifficultyDef(scalingValue, nameToken, string.Empty, descriptionToken, difficultyColor, serverTag, countsAsHardMode);
     DifficultyDef.foundIconSprite = true;
     DifficultyDef.iconSprite      = iconSprite;
 }