예제 #1
0
        private static void Resolve(Pair <string, ResolveParams> toResolve)
        {
            string        first  = toResolve.First;
            ResolveParams second = toResolve.Second;

            tmpResolvers.Clear();
            if (rulesBySymbol.TryGetValue(first, out List <RuleDef> value))
            {
                for (int i = 0; i < value.Count; i++)
                {
                    RuleDef ruleDef = value[i];
                    for (int j = 0; j < ruleDef.resolvers.Count; j++)
                    {
                        SymbolResolver symbolResolver = ruleDef.resolvers[j];
                        if (symbolResolver.CanResolve(second))
                        {
                            tmpResolvers.Add(symbolResolver);
                        }
                    }
                }
            }
            if (!tmpResolvers.Any())
            {
                Log.Warning("Could not find any RuleDef for symbol \"" + first + "\" with any resolver that could resolve " + second);
            }
            else
            {
                SymbolResolver symbolResolver2 = tmpResolvers.RandomElementByWeight((SymbolResolver x) => x.selectionWeight);
                symbolResolver2.Resolve(second);
            }
        }
예제 #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);
        }
예제 #3
0
        private static void Resolve(SymbolStack.Element toResolve)
        {
            string        symbol        = toResolve.symbol;
            ResolveParams resolveParams = toResolve.resolveParams;

            tmpResolvers.Clear();
            if (rulesBySymbol.TryGetValue(symbol, out var value))
            {
                for (int i = 0; i < value.Count; i++)
                {
                    RuleDef ruleDef = value[i];
                    for (int j = 0; j < ruleDef.resolvers.Count; j++)
                    {
                        SymbolResolver symbolResolver = ruleDef.resolvers[j];
                        if (symbolResolver.CanResolve(resolveParams))
                        {
                            tmpResolvers.Add(symbolResolver);
                        }
                    }
                }
            }
            if (!tmpResolvers.Any())
            {
                Log.Warning("Could not find any RuleDef for symbol \"" + symbol + "\" with any resolver that could resolve " + resolveParams);
            }
            else
            {
                tmpResolvers.RandomElementByWeight((SymbolResolver x) => x.selectionWeight).Resolve(resolveParams);
            }
        }
예제 #4
0
        public override bool CanResolve(ResolveParams rp)
        {
            bool result;

            if (!base.CanResolve(rp))
            {
                result = false;
            }
            else
            {
                List <RuleDef> allDefsListForReading = DefDatabase <RuleDef> .AllDefsListForReading;
                for (int i = 0; i < allDefsListForReading.Count; i++)
                {
                    RuleDef ruleDef = allDefsListForReading[i];
                    if (!(ruleDef.symbol != this.symbol))
                    {
                        for (int j = 0; j < ruleDef.resolvers.Count; j++)
                        {
                            if (ruleDef.resolvers[j].CanResolve(rp))
                            {
                                return(true);
                            }
                        }
                    }
                }
                result = false;
            }
            return(result);
        }
예제 #5
0
        static void RegisterVoteSelection(RuleDef selection)
        {
            List <RuleDef>       allRuleDefs    = (typeof(RuleCatalog)).GetFieldValue <List <RuleDef> >("allRuleDefs");
            List <RuleChoiceDef> allChoicesDefs = (typeof(RuleCatalog)).GetFieldValue <List <RuleChoiceDef> >("allChoicesDefs");

            selection.globalIndex = allRuleDefs.Count;
            if (selection.category.position == 0)
            {
                selection.category.position = selection.globalIndex;
            }
            for (int i = 0; i < selection.choices.Count; i++)
            {
                RuleChoiceDef choice = selection.choices[i];
                choice.globalIndex = allChoicesDefs.Count;
                choice.localIndex  = i;
                allChoicesDefs.Add(choice);
                RegisteredVoteChoices.Add(choice);
            }

            allRuleDefs.Add(selection);
            if (RuleCatalog.highestLocalChoiceCount < selection.choices.Count)
            {
                (typeof(RuleCatalog)).SetFieldValue <int>("highestLocalChoiceCount", selection.choices.Count);
            }
            (typeof(RuleCatalog)).GetFieldValue <Dictionary <string, RuleDef> >("ruleDefsByGlobalName").Add(selection.globalName, selection);
            foreach (RuleChoiceDef choice in selection.choices)
            {
                (typeof(RuleCatalog)).GetFieldValue <Dictionary <string, RuleChoiceDef> >("ruleChoiceDefsByGlobalName").Add(choice.globalName, choice);
            }
            RegisteredVoteSelections.Add(selection);
        }
        public override bool CanResolve(ResolveParams rp)
        {
            if (!base.CanResolve(rp))
            {
                return(false);
            }
            List <RuleDef> allDefsListForReading = DefDatabase <RuleDef> .AllDefsListForReading;

            for (int i = 0; i < allDefsListForReading.Count; i++)
            {
                RuleDef ruleDef = allDefsListForReading[i];
                if (ruleDef.symbol != symbol)
                {
                    continue;
                }
                for (int j = 0; j < ruleDef.resolvers.Count; j++)
                {
                    if (ruleDef.resolvers[j].CanResolve(rp))
                    {
                        return(true);
                    }
                }
            }
            return(false);
        }
예제 #7
0
파일: Hooks.cs 프로젝트: tung362/RoR2PVP
        public static void Init()
        {
            /*Assets*/
            RegisterAssets();

            /*Options menu for lobby*/
            //Header
            RuleCategoryDef PVPHeader = VoteAPI.AddVoteHeader("PVP", new Color(1.0f, 0.0f, 0.0f, 1.0f), false);

            //Selection
            RuleDef PVPSelection = VoteAPI.AddVoteSelection(PVPHeader, "PVP", new ChoiceMenu("Free For All PVP On", new Color(0.0f, 1.0f, 0.0f, 0.4f), "Enables free for all game mode", Color.black, "@TeamPVP:Assets/Resources/UI/FreeForAllPVPSelected.png", "artifact_teampvp", Settings.FreeForAllPVPToggle.Item2));

            VoteAPI.AddVoteChoice(PVPSelection, new ChoiceMenu("Team PVP On", new Color(0.0f, 1.0f, 0.0f, 0.4f), "Enables team pvp game mode", Color.black, "@TeamPVP:Assets/Resources/UI/TeamPVPSelected.png", "artifact_teampvp", Settings.TeamPVPToggle.Item2));
            VoteAPI.AddVoteChoice(PVPSelection, new ChoiceMenu("PVP Off", new Color(1.0f, 0.0f, 0.0f, 0.4f), "Disables Mod", Color.black, "@TeamPVP:Assets/Resources/UI/TeamPVPDeselected.png", "artifact_teampvp", -1));
            PVPSelection.defaultChoiceIndex = 2;

            RuleDef randomTeamsSelection = VoteAPI.AddVoteSelection(PVPHeader, "Random Teams", new ChoiceMenu("Random Teams On", new Color(0.0f, 0.58f, 1.0f, 0.4f), "Teams will be shuffled every round (only for team pvp game mode)", Color.black, "@TeamPVP:Assets/Resources/UI/RandomTeamsSelected.png", "artifact_teampvp", Settings.RandomTeams.Item2));

            VoteAPI.AddVoteChoice(randomTeamsSelection, new ChoiceMenu("Random Teams Off", new Color(1.0f, 0.0f, 0.0f, 0.4f), "Teams will stay the same every round (only for team pvp game mode)", Color.black, "@TeamPVP:Assets/Resources/UI/RandomTeamsDeselected.png", "artifact_teampvp", -1));
            randomTeamsSelection.defaultChoiceIndex = Settings.RandomTeams.Item1 ? 0 : 1;

            RuleDef mobSpawnSelection = VoteAPI.AddVoteSelection(PVPHeader, "Mob Spawn", new ChoiceMenu("Mob Spawn On", new Color(0.0f, 0.58f, 1.0f, 0.4f), "Mobs will spawn", Color.black, "@TeamPVP:Assets/Resources/UI/MobSpawnSelected.png", "artifact_teampvp", Settings.MobSpawn.Item2));

            VoteAPI.AddVoteChoice(mobSpawnSelection, new ChoiceMenu("Mob Spawn Off", new Color(1.0f, 0.0f, 0.0f, 0.4f), "Mobs will not spawn", Color.black, "@TeamPVP:Assets/Resources/UI/MobSpawnDeselected.png", "artifact_teampvp", -1));
            mobSpawnSelection.defaultChoiceIndex = Settings.MobSpawn.Item1 ? 0 : 1;

            RuleDef banItemsSelection = VoteAPI.AddVoteSelection(PVPHeader, "Ban Items", new ChoiceMenu("Ban Items On", new Color(0.0f, 0.58f, 1.0f, 0.4f), "Banned items configured in the config will be blacklisted", Color.black, "@TeamPVP:Assets/Resources/UI/BanItemsSelected.png", "artifact_teampvp", Settings.BanItems.Item2));

            VoteAPI.AddVoteChoice(banItemsSelection, new ChoiceMenu("Ban Items Off", new Color(1.0f, 0.0f, 0.0f, 0.4f), "Banned Items will not be blacklisted", Color.black, "@TeamPVP:Assets/Resources/UI/BanItemsDeselected.png", "artifact_teampvp", -1));
            banItemsSelection.defaultChoiceIndex = Settings.BanItems.Item1 ? 0 : 1;

            RuleDef companionsShareItemsSelection = VoteAPI.AddVoteSelection(PVPHeader, "Companions Share Items", new ChoiceMenu("Companions Share Items On", new Color(0.0f, 0.58f, 1.0f, 0.4f), "Items picked up by the player will be shared with their drones etc", Color.black, "@TeamPVP:Assets/Resources/UI/CompanionsShareItemsSelected.png", "artifact_teampvp", Settings.CompanionsShareItems.Item2));

            VoteAPI.AddVoteChoice(companionsShareItemsSelection, new ChoiceMenu("Companions Share Items Off", new Color(1.0f, 0.0f, 0.0f, 0.4f), "Items will not be shared with drones etc", Color.black, "@TeamPVP:Assets/Resources/UI/CompanionsShareItemsDeselected.png", "artifact_teampvp", -1));
            companionsShareItemsSelection.defaultChoiceIndex = Settings.CompanionsShareItems.Item1 ? 0 : 1;

            RuleDef customPlayableCharactersSelection = VoteAPI.AddVoteSelection(PVPHeader, "Custom Playable Characters", new ChoiceMenu("Custom Playable Characters On", new Color(0.0f, 0.58f, 1.0f, 0.4f), "Play custom characters configured in the config", Color.black, "@TeamPVP:Assets/Resources/UI/CustomPlayableCharactersSelected.png", "artifact_teampvp", Settings.CustomPlayableCharacters.Item2));

            VoteAPI.AddVoteChoice(customPlayableCharactersSelection, new ChoiceMenu("Custom Playable Characters Off", new Color(1.0f, 0.0f, 0.0f, 0.4f), "Play the default vanilla characters (unbalanced)", Color.black, "@TeamPVP:Assets/Resources/UI/CustomPlayableCharactersDeselected.png", "artifact_teampvp", -1));
            customPlayableCharactersSelection.defaultChoiceIndex = Settings.CustomPlayableCharacters.Item1 ? 0 : 1;

            RuleDef customInteractablesSpawnerSelection = VoteAPI.AddVoteSelection(PVPHeader, "Custom Interactables Spawner", new ChoiceMenu("Custom Interactables Spawner On", new Color(0.0f, 0.58f, 1.0f, 0.4f), "Spawn custom objects (chests, drones, etc) at custom rates configured in the config", Color.black, "@TeamPVP:Assets/Resources/UI/CustomInteractablesSpawnerSelected.png", "artifact_teampvp", Settings.CustomInteractablesSpawner.Item2));

            VoteAPI.AddVoteChoice(customInteractablesSpawnerSelection, new ChoiceMenu("Custom Interactables Spawner Off", new Color(1.0f, 0.0f, 0.0f, 0.4f), "Spawn objects (chests, drones, etc) normally as vanilla", Color.black, "@TeamPVP:Assets/Resources/UI/CustomInteractablesSpawnerDeselected.png", "artifact_teampvp", -1));
            customInteractablesSpawnerSelection.defaultChoiceIndex = Settings.CustomInteractablesSpawner.Item1 ? 0 : 1;

            RuleDef useDeathPlaneFailsafeSelection = VoteAPI.AddVoteSelection(PVPHeader, "Use Death Plane Failsafe", new ChoiceMenu("Use Death Plane Failsafe On", new Color(0.0f, 0.58f, 1.0f, 0.4f), "Force players to die should they fall off the map to prevent softlock", Color.black, "@TeamPVP:Assets/Resources/UI/UseDeathPlaneFailsafeSelected.png", "artifact_teampvp", Settings.UseDeathPlaneFailsafe.Item2));

            VoteAPI.AddVoteChoice(useDeathPlaneFailsafeSelection, new ChoiceMenu("Use Death Plane Failsafe Off", new Color(1.0f, 0.0f, 0.0f, 0.4f), "Disables the death plane. Only turn off if your using a custom map!", Color.black, "@TeamPVP:Assets/Resources/UI/UseDeathPlaneFailsafeDeselected.png", "artifact_teampvp", -1));
            useDeathPlaneFailsafeSelection.defaultChoiceIndex = Settings.UseDeathPlaneFailsafe.Item1 ? 0 : 1;

            RuleDef widerStageTransitionsSelection = VoteAPI.AddVoteSelection(PVPHeader, "Wider Stage Transitions", new ChoiceMenu("Wider Stage Transitions On", new Color(0.0f, 0.58f, 1.0f, 0.4f), "Transitions through a wider selection of stages when using the teleporter", Color.black, "@TeamPVP:Assets/Resources/UI/WiderStageTransitionsSelected.png", "artifact_teampvp", Settings.WiderStageTransitions.Item2));

            VoteAPI.AddVoteChoice(widerStageTransitionsSelection, new ChoiceMenu("Wider Stage Transitions Off", new Color(1.0f, 0.0f, 0.0f, 0.4f), "Vanilla stage transitions. Also turn off when using custom stages", Color.black, "@TeamPVP:Assets/Resources/UI/WiderStageTransitionsDeselected.png", "artifact_teampvp", -1));
            widerStageTransitionsSelection.defaultChoiceIndex = Settings.WiderStageTransitions.Item1 ? 0 : 1;
        }
예제 #8
0
        public static RuleDef AddVoteSelection(RuleCategoryDef header, string selectionName, ChoiceMenu choiceMenu)
        {
            RuleDef selection = new RuleDef("Votes." + selectionName, selectionName);

            selection.category = header;
            AddVoteChoice(selection, choiceMenu);
            header.children.Add(selection);
            VoteSelections.Add(selection);
            return(selection);
        }
예제 #9
0
        public static void AddVoteChoice(RuleDef selection, ChoiceMenu choiceMenu)
        {
            VoteChoiceDef choice = CreateChoice(ref selection, choiceMenu.TooltipName, null, false);

            choice.tooltipNameToken = choiceMenu.TooltipName;
            choice.tooltipNameColor = choiceMenu.TooltipNameColor;
            choice.tooltipBodyToken = choiceMenu.TooltipBody;
            choice.tooltipBodyColor = choiceMenu.TooltipBodyColor;
            choice.spritePath       = choiceMenu.IconPath;
            //choice.unlockableName = choiceMenu.UnlockableName;
            choice.VoteIndex = choiceMenu.ChoiceIndex;
        }
예제 #10
0
        protected void On(RuleUpdated @event)
        {
            if (@event.Trigger != null)
            {
                RuleDef = RuleDef.Update(@event.Trigger);
            }

            if (@event.Action != null)
            {
                RuleDef = RuleDef.Update(@event.Action);
            }
        }
예제 #11
0
        static VoteChoiceDef CreateChoice(ref RuleDef selection, string choiceName, object extraData = null, bool excludeByDefault = false)
        {
            RuleChoiceDef choice = new VoteChoiceDef();

            choice.ruleDef          = selection;
            choice.localName        = choiceName;
            choice.globalName       = selection.globalName + "." + choiceName;
            choice.localIndex       = selection.choices.Count;
            choice.extraData        = extraData;
            choice.excludeByDefault = excludeByDefault;
            selection.GetFieldValue <List <RuleChoiceDef> >("choices").Add(choice);
            return((VoteChoiceDef)choice);
        }
예제 #12
0
        // Token: 0x060024FD RID: 9469 RVA: 0x000A1408 File Offset: 0x0009F608
        public void SetData(RuleCategoryDef categoryDef, RuleChoiceMask availability, RuleBook ruleBook)
        {
            this.currentCategory = categoryDef;
            this.rulesToDisplay.Clear();
            List <RuleDef> children = categoryDef.children;

            for (int i = 0; i < children.Count; i++)
            {
                RuleDef ruleDef = children[i];
                int     num     = 0;
                foreach (RuleChoiceDef ruleChoiceDef in ruleDef.choices)
                {
                    if (availability[ruleChoiceDef.globalIndex])
                    {
                        num++;
                    }
                }
                bool flag = (!availability[ruleDef.choices[ruleDef.defaultChoiceIndex].globalIndex] && num != 0) || num > 1;
                if (flag)
                {
                    this.rulesToDisplay.Add(children[i]);
                }
            }
            this.AllocateStrips(this.rulesToDisplay.Count);
            List <RuleChoiceDef> list = new List <RuleChoiceDef>();

            for (int j = 0; j < this.rulesToDisplay.Count; j++)
            {
                RuleDef ruleDef2 = this.rulesToDisplay[j];
                list.Clear();
                foreach (RuleChoiceDef ruleChoiceDef2 in ruleDef2.choices)
                {
                    if (availability[ruleChoiceDef2.globalIndex])
                    {
                        list.Add(ruleChoiceDef2);
                    }
                }
                this.strips[j].GetComponent <RuleBookViewerStrip>().SetData(list, ruleBook.GetRuleChoiceIndex(ruleDef2));
            }
            if (this.headerObject)
            {
                this.headerObject.GetComponent <Image>().color = categoryDef.color;
                this.headerObject.GetComponentInChildren <LanguageTextMeshController>().token = categoryDef.displayToken;
            }
            this.SetTip(this.isEmpty ? categoryDef.emptyTipToken : null);
        }
예제 #13
0
        private static void Resolve(Pair <string, ResolveParams> toResolve)
        {
            string        first  = toResolve.First;
            ResolveParams second = toResolve.Second;

            BaseGen.tmpResolvers.Clear();
            List <RuleDef> list;

            if (BaseGen.rulesBySymbol.TryGetValue(first, out list))
            {
                for (int i = 0; i < list.Count; i++)
                {
                    RuleDef ruleDef = list[i];
                    for (int j = 0; j < ruleDef.resolvers.Count; j++)
                    {
                        SymbolResolver symbolResolver = ruleDef.resolvers[j];
                        if (symbolResolver.CanResolve(second))
                        {
                            BaseGen.tmpResolvers.Add(symbolResolver);
                        }
                    }
                }
            }
            if (!BaseGen.tmpResolvers.Any <SymbolResolver>())
            {
                Log.Warning(string.Concat(new object[]
                {
                    "Could not find any RuleDef for symbol \"",
                    first,
                    "\" with any resolver that could resolve ",
                    second
                }), false);
            }
            else
            {
                SymbolResolver symbolResolver2 = BaseGen.tmpResolvers.RandomElementByWeight((SymbolResolver x) => x.selectionWeight);
                symbolResolver2.Resolve(second);
            }
        }
예제 #14
0
        public void Awake()//Code that runs when the game starts
        {
            List <RuleDef>       allRuleDefs    = (List <RuleDef>)Harmony.AccessTools.Field(Harmony.AccessTools.TypeByName("RuleCatalog"), "allRuleDefs").GetValue(null);
            List <RuleChoiceDef> allChoicesDefs = (List <RuleChoiceDef>)Harmony.AccessTools.Field(Harmony.AccessTools.TypeByName("RuleCatalog"), "allChoicesDefs").GetValue(null);

            for (int k = 0; k < allRuleDefs.Count; k++)
            {
                RuleDef ruleDef = allRuleDefs[k];
                ruleDef.globalIndex = k;
                for (int j = 0; j < ruleDef.choices.Count; j++)
                {
                    RuleChoiceDef ruleChoiceDef6 = ruleDef.choices[j];
                    ruleChoiceDef6.localIndex  = j;
                    ruleChoiceDef6.globalIndex = allChoicesDefs.Count;
                    allChoicesDefs.Add(ruleChoiceDef6);
                }
            }

            On.RoR2.UI.RuleCategoryController.Awake += (orig, self) =>
            {
                self.SetCollapsed(true);
                orig(self);
            };

            On.RoR2.UI.RuleChoiceController.OnClick += (orig, self) =>
            {
                RuleChoiceDef myChoiceDef = (RuleChoiceDef)Harmony.AccessTools.Field(Harmony.AccessTools.TypeByName("RoR2.UI.RuleChoiceController"), "currentChoiceDef").GetValue(self);
                myChoiceDef.ruleDef.defaultChoiceIndex = myChoiceDef.localIndex;
                orig(self);
            };


            Harmony.AccessTools.Field(Harmony.AccessTools.TypeByName("RuleCatalog"), "allRuleDefs").SetValue(null, allRuleDefs);
            Harmony.AccessTools.Field(Harmony.AccessTools.TypeByName("RuleCatalog"), "allChoicesDefs").SetValue(null, allChoicesDefs);
            RuleCatalog.availability.MakeAvailable();
        }
예제 #15
0
        public void Awake()//Code that runs when the game starts
        {
            if (BetterInteractables.RunBetterInteractables())
            {
                Chat.AddMessage("[FW] Better Interactables Loaded");
            }
            if (InteractableManager.RunInteractableManager())
            {
                Chat.AddMessage("[FW] Interactable Manager Loaded");
            }
            if (SizeManager.RunSizeManager())
            {
                Chat.AddMessage("[FW] Size Manager Loaded");
            }
            if (CharacterEdits.RunCharacterEdits())
            {
                Chat.AddMessage("[FW] Character Edits Loaded");
            }
            if (EnemyEdits.RunEnemyEdits())
            {
                Chat.AddMessage("[FW] Enemy Edits Loaded");
            }
            if (AITeammates.RunAITeammates())
            {
                Chat.AddMessage("[FW] Teammate editor loaded");
            }

            List <RuleDef>       allRuleDefs    = (List <RuleDef>)Harmony.AccessTools.Field(Harmony.AccessTools.TypeByName("RuleCatalog"), "allRuleDefs").GetValue(null);
            List <RuleChoiceDef> allChoicesDefs = (List <RuleChoiceDef>)Harmony.AccessTools.Field(Harmony.AccessTools.TypeByName("RuleCatalog"), "allChoicesDefs").GetValue(null);

            for (int k = 0; k < allRuleDefs.Count; k++)
            {
                RuleDef ruleDef = allRuleDefs[k];
                ruleDef.globalIndex = k;
                for (int j = 0; j < ruleDef.choices.Count; j++)
                {
                    RuleChoiceDef ruleChoiceDef6 = ruleDef.choices[j];
                    ruleChoiceDef6.localIndex  = j;
                    ruleChoiceDef6.globalIndex = allChoicesDefs.Count;
                    allChoicesDefs.Add(ruleChoiceDef6);
                }
            }

            On.RoR2.UI.RuleCategoryController.Awake += (orig, self) =>
            {
                self.SetCollapsed(true);
                orig(self);
            };

            On.RoR2.UI.RuleChoiceController.OnClick += (orig, self) =>
            {
                RuleChoiceDef myChoiceDef = (RuleChoiceDef)Harmony.AccessTools.Field(Harmony.AccessTools.TypeByName("RoR2.UI.RuleChoiceController"), "currentChoiceDef").GetValue(self);
                myChoiceDef.ruleDef.defaultChoiceIndex = myChoiceDef.localIndex;
                orig(self);
            };

            On.RoR2.RuleDef.AddChoice += (orig, self, choiceName, extraData, excludeByDefault) =>
            {
                excludeByDefault = false;

                RuleChoiceDef ruleChoiceDef = new RuleChoiceDef();
                ruleChoiceDef.ruleDef          = self;
                ruleChoiceDef.localName        = choiceName;
                ruleChoiceDef.globalName       = self.globalName + "." + choiceName;
                ruleChoiceDef.localIndex       = self.choices.Count;
                ruleChoiceDef.extraData        = extraData;
                ruleChoiceDef.excludeByDefault = excludeByDefault;
                self.choices.Add(ruleChoiceDef);
                return(ruleChoiceDef);
            };

            On.RoR2.RuleCatalog.HiddenTestItemsConvar += (self) =>
            {
                return(false);
            };
            On.RoR2.RuleCatalog.HiddenTestTrue += (self) =>
            {
                return(false);
            };

            Harmony.AccessTools.Field(Harmony.AccessTools.TypeByName("RuleCatalog"), "allRuleDefs").SetValue(null, allRuleDefs);
            Harmony.AccessTools.Field(Harmony.AccessTools.TypeByName("RuleCatalog"), "allChoicesDefs").SetValue(null, allChoicesDefs);
            RuleCatalog.availability.MakeAvailable();
        }
예제 #16
0
        public void Awake()//Code that runs when the game starts
        {
            var addRule     = typeof(RuleCatalog).GetMethod("AddRule", BindingFlags.Static | BindingFlags.NonPublic, null, new Type[] { typeof(RuleDef) }, null);
            var addCategory = typeof(RuleCatalog).GetMethod("AddCategory", BindingFlags.Static | BindingFlags.NonPublic, null, new Type[] { typeof(string), typeof(Color), typeof(string), typeof(Func <bool>) }, null);

            Color mycolor = new Color(0.3f, 0f, 0.5f);

            //Creates a header for the mod itself
            addCategory.Invoke(null, new object[] { "Ryan's Turrets", mycolor, "A Fun mod for custom turrets", new Func <bool>(() => false) });
            //Create a header for the category, such as 'Huntress edits'
            addCategory.Invoke(null, new object[] { "Turret Type Config", mycolor, "", new Func <bool>(() => false) });
            //Creates a rule and an accessible variable
            RuleDef ruleDef3 = new RuleDef("RyanTurrets.TurretMode", "TurretModes");

            //Adds Choice name, variable and "hidden", (set this to false if you want it to show up), then adds the string to appear on hover.
            ruleDef3.AddChoice("1", 1, false).tooltipBodyToken = "Makes all turrets default";
            ruleDef3.AddChoice("2", 2, false).tooltipBodyToken = "Makes all turrets shoot rebar";
            ruleDef3.AddChoice("3", 3, false).tooltipBodyToken = "Makes all turrets machine guns";
            ruleDef3.AddChoice("4", 4, false).tooltipBodyToken = "Switches between Rebar and Machine gun turrets";
            ruleDef3.MakeNewestChoiceDefault();
            //Adds the choices to the catalog
            addRule.Invoke(null, new object[] { ruleDef3 });

            //This has to run once after all the custom rules are entered, in order to reset the game into knowing what rules exist.
            List <RuleDef>       allRuleDefs    = (List <RuleDef>)Harmony.AccessTools.Field(Harmony.AccessTools.TypeByName("RuleCatalog"), "allRuleDefs").GetValue(null);
            List <RuleChoiceDef> allChoicesDefs = (List <RuleChoiceDef>)Harmony.AccessTools.Field(Harmony.AccessTools.TypeByName("RuleCatalog"), "allChoicesDefs").GetValue(null);

            for (int k = 0; k < allRuleDefs.Count; k++)
            {
                RuleDef ruleDef4 = allRuleDefs[k];
                ruleDef4.globalIndex = k;

                for (int j = 0; j < ruleDef4.choices.Count; j++)
                {
                    RuleChoiceDef ruleChoiceDef6 = ruleDef4.choices[j];
                    ruleChoiceDef6.localIndex             = j;
                    ruleChoiceDef6.globalIndex            = allChoicesDefs.Count;
                    ruleChoiceDef6.availableInMultiPlayer = true;
                    ruleChoiceDef6.excludeByDefault       = false;
                    allChoicesDefs.Add(ruleChoiceDef6);
                }
            }
            Harmony.AccessTools.Field(Harmony.AccessTools.TypeByName("RuleCatalog"), "allRuleDefs").SetValue(null, allRuleDefs);
            Harmony.AccessTools.Field(Harmony.AccessTools.TypeByName("RuleCatalog"), "allChoicesDefs").SetValue(null, allChoicesDefs);
            RuleCatalog.availability.MakeAvailable();
            bool didReflect = false;

            currentRule = (int)Run.instance.ruleBook.GetRuleChoice(RuleCatalog.FindRuleDef("RyanTurrets.TurretMode")).extraData;

            On.EntityStates.Drone.DroneWeapon.FireMegaTurret.OnEnter += (orig, self) =>
            {
                if (!didReflect)
                {
                    Harmony.AccessTools.Field(Harmony.AccessTools.TypeByName("EntityStates.Drone.DroneWeapon.FireMegaTurret"), "force").SetValue(self, 0.1f);
                    didReflect = true;
                }
                orig(self);
            };
            bool  gotDefault         = false;
            float defaultspeed       = 0f;
            float defaultleveldamage = 0f;
            float defaultdamage      = 0f;

            On.RoR2.CharacterBody.HandleConstructTurret += (orig, netMsg) =>
            {
                if (!gotDefault)
                {
                    defaultspeed       = BodyCatalog.FindBodyPrefab("EngiTurretBody").GetComponent <CharacterBody>().baseAttackSpeed;
                    defaultdamage      = BodyCatalog.FindBodyPrefab("EngiTurretBody").GetComponent <CharacterBody>().baseDamage;
                    defaultleveldamage = BodyCatalog.FindBodyPrefab("EngiTurretBody").GetComponent <CharacterBody>().levelDamage;
                    gotDefault         = true;
                }

                if (currentRule == 1)
                {
                    BodyCatalog.FindBodyPrefab("EngiTurretBody").GetComponent <SkillLocator>().primary.activationState.stateType = typeof(EntityStates.Commando.CommandoWeapon.Reload).Assembly.GetType("EntityStates.EngiTurret.EngiTurretWeapon.FireGauss");
                    BodyCatalog.FindBodyPrefab("EngiTurretBody").GetComponent <CharacterBody>().baseAttackSpeed = defaultspeed;
                    BodyCatalog.FindBodyPrefab("EngiTurretBody").GetComponent <CharacterBody>().baseDamage      = defaultdamage;
                    BodyCatalog.FindBodyPrefab("EngiTurretBody").GetComponent <CharacterBody>().levelDamage     = defaultleveldamage;
                    BodyCatalog.FindBodyPrefab("EngiTurretBody").GetComponent <CharacterBody>().baseNameToken   = "Weak Boi Default";

                    for (int i = 0; i < MasterCatalog.FindMasterPrefab("EngiTurretMaster").GetComponents <AISkillDriver>().Length; i++)
                    {
                        if (MasterCatalog.FindMasterPrefab("EngiTurretMaster").GetComponents <AISkillDriver>()[i].customName == "FireAtEnemy")
                        {
                            MasterCatalog.FindMasterPrefab("EngiTurretMaster").GetComponents <AISkillDriver>()[i].maxDistance = 60;
                            MasterCatalog.FindMasterPrefab("EngiTurretMaster").GetComponents <AISkillDriver>()[i].selectionRequiresTargetLoS  = false;
                            MasterCatalog.FindMasterPrefab("EngiTurretMaster").GetComponents <AISkillDriver>()[i].activationRequiresTargetLoS = true;
                        }
                    }
                }
                else if (currentRule == 2)
                {
                    BodyCatalog.FindBodyPrefab("EngiTurretBody").GetComponent <SkillLocator>().primary.activationState.stateType = typeof(EntityStates.Toolbot.FireSpear);

                    BodyCatalog.FindBodyPrefab("EngiTurretBody").GetComponent <CharacterBody>().baseAttackSpeed = 0.5f;

                    BodyCatalog.FindBodyPrefab("EngiTurretBody").GetComponent <CharacterBody>().baseDamage = 13f;

                    BodyCatalog.FindBodyPrefab("EngiTurretBody").GetComponent <CharacterBody>().levelDamage   = 2.12f;
                    BodyCatalog.FindBodyPrefab("EngiTurretBody").GetComponent <CharacterBody>().baseNameToken = "Portable Railgun";
                    for (int i = 0; i < MasterCatalog.FindMasterPrefab("EngiTurretMaster").GetComponents <AISkillDriver>().Length; i++)
                    {
                        if (MasterCatalog.FindMasterPrefab("EngiTurretMaster").GetComponents <AISkillDriver>()[i].customName == "FireAtEnemy")
                        {
                            MasterCatalog.FindMasterPrefab("EngiTurretMaster").GetComponents <AISkillDriver>()[i].maxDistance = 1024;
                            MasterCatalog.FindMasterPrefab("EngiTurretMaster").GetComponents <AISkillDriver>()[i].selectionRequiresTargetLoS  = false;
                            MasterCatalog.FindMasterPrefab("EngiTurretMaster").GetComponents <AISkillDriver>()[i].activationRequiresTargetLoS = false;
                        }
                    }
                }
                else if (currentRule == 3)
                {
                    BodyCatalog.FindBodyPrefab("EngiTurretBody").GetComponent <SkillLocator>().primary.activationState.stateType = typeof(EntityStates.Commando.CommandoWeapon.Reload).Assembly.GetType("EntityStates.Drone.DroneWeapon.FireMegaTurret");
                    BodyCatalog.FindBodyPrefab("EngiTurretBody").GetComponent <CharacterBody>().baseAttackSpeed = 1f;
                    BodyCatalog.FindBodyPrefab("EngiTurretBody").GetComponent <CharacterBody>().baseDamage      = 2f;
                    BodyCatalog.FindBodyPrefab("EngiTurretBody").GetComponent <CharacterBody>().levelDamage     = 0.4f;
                    BodyCatalog.FindBodyPrefab("EngiTurretBody").GetComponent <CharacterBody>().baseNameToken   = ".50 Cal Maxim";
                    for (int i = 0; i < MasterCatalog.FindMasterPrefab("EngiTurretMaster").GetComponents <AISkillDriver>().Length; i++)
                    {
                        if (MasterCatalog.FindMasterPrefab("EngiTurretMaster").GetComponents <AISkillDriver>()[i].customName == "FireAtEnemy")
                        {
                            MasterCatalog.FindMasterPrefab("EngiTurretMaster").GetComponents <AISkillDriver>()[i].maxDistance = 100;
                            MasterCatalog.FindMasterPrefab("EngiTurretMaster").GetComponents <AISkillDriver>()[i].selectionRequiresTargetLoS  = false;
                            MasterCatalog.FindMasterPrefab("EngiTurretMaster").GetComponents <AISkillDriver>()[i].activationRequiresTargetLoS = false;
                        }
                    }
                }
                else
                {
                    if (lastWasRebar == false)
                    {
                        Chat.SendBroadcastChat(new Chat.SimpleChatMessage
                        {
                            baseToken = "Next Turret will be: [Machine Gun]"
                        });
                        BodyCatalog.FindBodyPrefab("EngiTurretBody").GetComponent <SkillLocator>().primary.activationState.stateType = typeof(EntityStates.Toolbot.FireSpear);
                        BodyCatalog.FindBodyPrefab("EngiTurretBody").GetComponent <CharacterBody>().baseAttackSpeed = 0.5f;
                        BodyCatalog.FindBodyPrefab("EngiTurretBody").GetComponent <CharacterBody>().baseDamage      = 13f;
                        BodyCatalog.FindBodyPrefab("EngiTurretBody").GetComponent <CharacterBody>().levelDamage     = 2.12f;
                        BodyCatalog.FindBodyPrefab("EngiTurretBody").GetComponent <CharacterBody>().baseNameToken   = "Portable Railgun";
                        for (int i = 0; i < MasterCatalog.FindMasterPrefab("EngiTurretMaster").GetComponents <AISkillDriver>().Length; i++)
                        {
                            if (MasterCatalog.FindMasterPrefab("EngiTurretMaster").GetComponents <AISkillDriver>()[i].customName == "FireAtEnemy")
                            {
                                MasterCatalog.FindMasterPrefab("EngiTurretMaster").GetComponents <AISkillDriver>()[i].maxDistance = 1024;
                                MasterCatalog.FindMasterPrefab("EngiTurretMaster").GetComponents <AISkillDriver>()[i].selectionRequiresTargetLoS  = false;
                                MasterCatalog.FindMasterPrefab("EngiTurretMaster").GetComponents <AISkillDriver>()[i].activationRequiresTargetLoS = false;
                            }
                        }
                        lastWasRebar = true;
                    }
                    else
                    {
                        Chat.SendBroadcastChat(new Chat.SimpleChatMessage
                        {
                            baseToken = "Next Turret will be: [Railgun]"
                        });

                        BodyCatalog.FindBodyPrefab("EngiTurretBody").GetComponent <SkillLocator>().primary.activationState.stateType = typeof(EntityStates.Commando.CommandoWeapon.Reload).Assembly.GetType("EntityStates.Drone.DroneWeapon.FireMegaTurret");
                        BodyCatalog.FindBodyPrefab("EngiTurretBody").GetComponent <CharacterBody>().baseAttackSpeed = 1f;
                        BodyCatalog.FindBodyPrefab("EngiTurretBody").GetComponent <CharacterBody>().baseDamage      = 2f;
                        BodyCatalog.FindBodyPrefab("EngiTurretBody").GetComponent <CharacterBody>().levelDamage     = 0.4f;
                        BodyCatalog.FindBodyPrefab("EngiTurretBody").GetComponent <CharacterBody>().baseNameToken   = ".50 Cal Maxim";
                        for (int i = 0; i < MasterCatalog.FindMasterPrefab("EngiTurretMaster").GetComponents <AISkillDriver>().Length; i++)
                        {
                            if (MasterCatalog.FindMasterPrefab("EngiTurretMaster").GetComponents <AISkillDriver>()[i].customName == "FireAtEnemy")
                            {
                                MasterCatalog.FindMasterPrefab("EngiTurretMaster").GetComponents <AISkillDriver>()[i].maxDistance = 100;
                                MasterCatalog.FindMasterPrefab("EngiTurretMaster").GetComponents <AISkillDriver>()[i].selectionRequiresTargetLoS  = false;
                                MasterCatalog.FindMasterPrefab("EngiTurretMaster").GetComponents <AISkillDriver>()[i].activationRequiresTargetLoS = false;
                            }
                        }
                        lastWasRebar = false;
                    }
                }

                orig(netMsg);
            };
        }
예제 #17
0
 protected void On(RuleEnabled @event)
 {
     RuleDef = RuleDef.Enable();
 }
예제 #18
0
        public static bool RunBetterInteractables()
        {
            var addRule      = typeof(RuleCatalog).GetMethod("AddRule", BindingFlags.Static | BindingFlags.NonPublic, null, new Type[] { typeof(RuleDef) }, null);
            var addCategory  = typeof(RuleCatalog).GetMethod("AddCategory", BindingFlags.Static | BindingFlags.NonPublic, null, new Type[] { typeof(string), typeof(Color), typeof(string), typeof(Func <bool>) }, null);
            int randomNumber = 0;

            addCategory.Invoke(null, new object[] { "Better Triple Shops", new Color(219 / 255, 182 / 255, 19 / 255, byte.MaxValue), "", new Func <bool>(() => false) });

            RuleDef shopExistenceRule = new RuleDef("FloodWarning.BetterShopExistenceChances", "Chance of a success on each roll of a Better Triple Shop Tier");

            for (int i = 0; i <= 20; i++)
            {
                float myNum = (i * 5) / 100f;

                RuleChoiceDef myRule = shopExistenceRule.AddChoice("0", myNum * 100f, false);
                if (myNum * 100 == 50f)
                {
                    shopExistenceRule.MakeNewestChoiceDefault();
                }
                myRule.spritePath       = "Textures/MiscIcons/texRuleBonusStartingMoney";
                myRule.tooltipNameToken = "" + myNum * 100 + " Base Chance";
                myRule.tooltipBodyToken = myNum * 100 + "% Chance to replace a vanilla triple shop with a custom one (Varied costs, cost types and rewards)";
                if (i == 0f)
                {
                    myRule.tooltipNameToken = "0% Chance";
                    myRule.tooltipBodyToken = "Triple shops will never have varied costs/tiers apart from vanilla";
                }
            }
            addRule.Invoke(null, new object[] { shopExistenceRule });

            RuleDef shopChancesRule = new RuleDef("FloodWarning.BetterShopChances", "Chance of a success on each roll of a Better Triple Shop Tier");

            for (int i = 0; i <= 20; i++)
            {
                float myNum = (i * 5) / 100f;

                RuleChoiceDef myRule = shopChancesRule.AddChoice("0", myNum * 100f, false);
                if (myNum * 100 == 50f)
                {
                    shopChancesRule.MakeNewestChoiceDefault();
                }
                myRule.spritePath       = "Textures/MiscIcons/texRuleBonusStartingMoney";
                myRule.tooltipNameToken = "" + myNum * 100 + " Chance to go up a tier (each tier)";
                myRule.tooltipBodyToken = (Math.Pow(myNum, 1) * 100).ToString("#.###") + "% reaches White, " + (Math.Pow(myNum, 2) * 100).ToString("#.###") + "% reaches Green, " + (Math.Pow(myNum, 3) * 100).ToString("#.###") + "% reaches Red, " + (Math.Pow(myNum, 4) * 100).ToString("#.###") + "% reaches Lunar, " + (Math.Pow(myNum, 5) * 100).ToString("#.###") + "% reaches Boss ";
                if (i == 0f)
                {
                    myRule.tooltipNameToken = "0% Chance";
                    myRule.tooltipBodyToken = "Triple shops will never have varied costs/tiers apart from vanilla";
                }
            }
            addRule.Invoke(null, new object[] { shopChancesRule });



            addCategory.Invoke(null, new object[] { "Better Shrines", new Color(219 / 255, 182 / 255, 19 / 255, byte.MaxValue), "", new Func <bool>(() => false) });

            RuleDef betterShrineRule = new RuleDef("FloodWarning.betterShrine", "Whether or not the game should have better shrines");
            {
                RuleChoiceDef myRule = betterShrineRule.AddChoice("0", false, false);
                myRule.spritePath       = "Textures/MiscIcons/texRuleBonusStartingMoney";
                myRule.tooltipNameToken = "Off";
                myRule.tooltipBodyToken = "Shrines and Duplicators are vanilla";

                RuleChoiceDef myRule2 = betterShrineRule.AddChoice("0", true, false);
                myRule2.spritePath       = "Textures/MiscIcons/texRuleBonusStartingMoney";
                myRule2.tooltipNameToken = "On";
                myRule2.tooltipBodyToken = "Shrines can be used more times (Random on generation, Different ranges for different shrines), shrines can be used quicker";
                betterShrineRule.MakeNewestChoiceDefault();
                addRule.Invoke(null, new object[] { betterShrineRule });
            }

            {
                On.EntityStates.Duplicator.Duplicating.DropDroplet += (orig, self) =>
                {
                    orig(self);
                };

                On.RoR2.ShrineChanceBehavior.Awake += (orig, self) =>
                {
                    if ((bool)Run.instance.ruleBook.GetRuleChoice(RuleCatalog.FindRuleDef("FloodWarning.betterShrine")).extraData)
                    {
                        Harmony.AccessTools.Field(Harmony.AccessTools.TypeByName("RoR2.ShrineChanceBehavior"), "maxPurchaseCount").SetValue(self, Run.instance.treasureRng.RangeInt(2, 5));
                        Harmony.AccessTools.Field(Harmony.AccessTools.TypeByName("RoR2.ShrineChanceBehavior"), "costMultiplierPerPurchase").SetValue(self, 1.2f);
                    }

                    orig(self);
                };
                On.RoR2.ShrineHealingBehavior.Awake += (orig, self) =>
                {
                    self.costMultiplierPerPurchase = 1.05f;
                    if ((bool)Run.instance.ruleBook.GetRuleChoice(RuleCatalog.FindRuleDef("FloodWarning.betterShrine")).extraData)
                    {
                        Harmony.AccessTools.Field(Harmony.AccessTools.TypeByName("RoR2.ShrineHealingBehavior"), "maxPurchaseCount").SetValue(self, Run.instance.treasureRng.RangeInt(5, 12));
                        Harmony.AccessTools.Field(Harmony.AccessTools.TypeByName("RoR2.ShrineHealingBehavior"), "costMultiplierPerPurchase").SetValue(self, 1.2f);
                    }
                    orig(self);
                };
                On.RoR2.ShrineRestackBehavior.Start += (orig, self) =>
                {
                    if ((bool)Run.instance.ruleBook.GetRuleChoice(RuleCatalog.FindRuleDef("FloodWarning.betterShrine")).extraData)
                    {
                        Harmony.AccessTools.Field(Harmony.AccessTools.TypeByName("RoR2.ShrineRestackBehavior"), "maxPurchaseCount").SetValue(self, Run.instance.treasureRng.RangeInt(1, 4));
                        Harmony.AccessTools.Field(Harmony.AccessTools.TypeByName("RoR2.ShrineRestackBehavior"), "costMultiplierPerPurchase").SetValue(self, 1);
                    }
                    orig(self);
                };

                On.RoR2.ShrineChanceBehavior.AddShrineStack += (orig, self, activator) =>
                {
                    self.tier1Weight *= 1;
                    self.tier2Weight *= 1.1f;
                    self.tier3Weight *= 1.05f;
                    orig(self, activator);
                    if ((bool)Run.instance.ruleBook.GetRuleChoice(RuleCatalog.FindRuleDef("FloodWarning.betterShrine")).extraData)
                    {
                        Harmony.AccessTools.Field(Harmony.AccessTools.TypeByName("RoR2.ShrineChanceBehavior"), "refreshTimer").SetValue(self, 0.1f);
                    }
                };
                On.RoR2.ShrineHealingBehavior.AddShrineStack += (orig, self, activator) =>
                {
                    orig(self, activator);
                    if ((bool)Run.instance.ruleBook.GetRuleChoice(RuleCatalog.FindRuleDef("FloodWarning.betterShrine")).extraData)
                    {
                        Harmony.AccessTools.Field(Harmony.AccessTools.TypeByName("RoR2.ShrineHealingBehavior"), "refreshTimer").SetValue(self, 0.1f);
                    }
                };

                On.EntityStates.Duplicator.Duplicating.OnEnter += (orig, self) =>
                {
                    orig(self);
                    if ((bool)Run.instance.ruleBook.GetRuleChoice(RuleCatalog.FindRuleDef("FloodWarning.betterShrine")).extraData)
                    {
                        Harmony.AccessTools.Field(Harmony.AccessTools.TypeByName("EntityStates.Duplicator.Duplicating"), "timeBetweenStartAndDropDroplet").SetValue(self, 1f);
                        Harmony.AccessTools.Field(Harmony.AccessTools.TypeByName("EntityStates.Duplicator.Duplicating"), "initialDelayDuration").SetValue(self, 0.2f);
                    }
                };
            }

            bool     isCustomCost   = false;
            CostType customCostType = CostType.WhiteItem;
            ItemTier customTier     = ItemTier.NoTier;
            int      customCost     = 0;



            //On.RoR2.MultiShopController.UpdateHologramContent += (orig, self, var) =>
            //{
            //    orig(self, var);
            //    CostHologramContent component = var.GetComponent<CostHologramContent>();
            //    component.costType = self.costType;
            //    component.displayValue = self.baseCost;
            //};

            On.RoR2.MultiShopController.Start += (orig, self) =>
            {
                customTier = (ItemTier)Harmony.AccessTools.Field(Harmony.AccessTools.TypeByName("RoR2.MultiShopController"), "itemTier").GetValue(self);

                randomNumber = Run.instance.treasureRng.RangeInt(0, 100);
                if (randomNumber < (float)Run.instance.ruleBook.GetRuleChoice(RuleCatalog.FindRuleDef("FloodWarning.BetterShopExistenceChances")).extraData || customTier != ItemTier.Tier1)
                {
                    randomNumber = Run.instance.treasureRng.RangeInt(0, 100);
                    if (randomNumber < 10)//15% chance to swap out item
                    {
                        switch (customTier)
                        {
                        case ItemTier.Tier1:
                            customCostType = CostType.WhiteItem;
                            customCost     = 1;
                            break;

                        case ItemTier.Tier2:
                            customCostType = CostType.GreenItem;
                            customCost     = 1;
                            break;

                        case ItemTier.Tier3:
                            customCostType = CostType.RedItem;
                            customCost     = 1;
                            break;

                        case ItemTier.Lunar:
                            customCostType = CostType.RedItem;
                            customCost     = 1;
                            break;

                        case ItemTier.Boss:
                            customCostType = CostType.GreenItem;
                            customCost     = 1;
                            break;
                        }
                        isCustomCost = true;
                    }
                    else if (randomNumber < 20)//10% Swap 2 for 1
                    {
                        switch (customTier)
                        {
                        case ItemTier.Tier1:
                            customCostType = CostType.WhiteItem;
                            customCost     = 2;
                            break;

                        case ItemTier.Tier2:
                            customCostType = CostType.GreenItem;
                            customCost     = 2;
                            break;

                        case ItemTier.Tier3:
                            customCostType = CostType.RedItem;
                            customCost     = 2;
                            break;

                        case ItemTier.Lunar:
                            customCostType = CostType.RedItem;
                            customCost     = 2;
                            break;

                        case ItemTier.Boss:
                            customCostType = CostType.GreenItem;
                            customCost     = 2;
                            break;
                        }
                        isCustomCost = true;
                    }
                    else if (randomNumber < 30)//10% Trade Up (Cheap)
                    {
                        isCustomCost = true;

                        switch (customTier)
                        {
                        case ItemTier.Tier1:
                            customCostType = CostType.Money;
                            customCost     = (int)Harmony.AccessTools.Field(Harmony.AccessTools.TypeByName("RoR2.MultiShopController"), "baseCost").GetValue(self) / 3;
                            isCustomCost   = false;
                            break;

                        case ItemTier.Tier2:
                            customCostType = CostType.WhiteItem;
                            customCost     = 2;
                            break;

                        case ItemTier.Tier3:
                            customCostType = CostType.GreenItem;
                            customCost     = 4;
                            break;

                        case ItemTier.Lunar:
                            customCostType = CostType.GreenItem;
                            customCost     = 5;
                            break;

                        case ItemTier.Boss:
                            customCostType = CostType.GreenItem;
                            customCost     = 1;
                            break;
                        }
                    }
                    else if (randomNumber < 45)//15% Trade Up (Normal)
                    {
                        isCustomCost = true;

                        switch (customTier)
                        {
                        case ItemTier.Tier1:
                            customCostType = CostType.Money;
                            customCost     = (int)Harmony.AccessTools.Field(Harmony.AccessTools.TypeByName("RoR2.MultiShopController"), "baseCost").GetValue(self) / 2;
                            isCustomCost   = false;
                            break;

                        case ItemTier.Tier2:
                            customCostType = CostType.WhiteItem;
                            customCost     = 3;
                            break;

                        case ItemTier.Tier3:
                            customCostType = CostType.GreenItem;
                            customCost     = 5;
                            break;

                        case ItemTier.Lunar:
                            customCostType = CostType.GreenItem;
                            customCost     = 7;
                            break;

                        case ItemTier.Boss:
                            customCostType = CostType.GreenItem;
                            customCost     = 2;
                            break;
                        }
                    }
                    else if (randomNumber < 60)//15% Trade Up (Expensive)
                    {
                        isCustomCost = true;

                        switch (customTier)
                        {
                        case ItemTier.Tier1:
                            customCostType = CostType.Money;
                            customCost     = (int)Harmony.AccessTools.Field(Harmony.AccessTools.TypeByName("RoR2.MultiShopController"), "baseCost").GetValue(self) / 2;
                            isCustomCost   = false;
                            break;

                        case ItemTier.Tier2:
                            customCostType = CostType.WhiteItem;
                            customCost     = 5;
                            break;

                        case ItemTier.Tier3:
                            customCostType = CostType.GreenItem;
                            customCost     = 7;
                            break;

                        case ItemTier.Lunar:
                            customCostType = CostType.GreenItem;
                            customCost     = 10;
                            break;

                        case ItemTier.Boss:
                            customCostType = CostType.GreenItem;
                            customCost     = 3;
                            break;
                        }
                    }
                    else if (randomNumber < 70)//10% cost health
                    {
                        switch (customTier)
                        {
                        case ItemTier.Tier1:
                            customCostType = CostType.PercentHealth;
                            customCost     = 99;
                            break;

                        case ItemTier.Tier2:
                            customCostType = CostType.PercentHealth;
                            customCost     = 99;
                            break;

                        case ItemTier.Tier3:
                            customCostType = CostType.PercentHealth;
                            customCost     = 99;
                            break;

                        case ItemTier.Lunar:
                            customCostType = CostType.PercentHealth;
                            customCost     = 99;
                            break;

                        case ItemTier.Boss:
                            customCostType = CostType.PercentHealth;
                            customCost     = 99;
                            break;
                        }
                        isCustomCost = true;
                    }
                    else if (randomNumber < 80)//10% Expensive
                    {
                        switch (customTier)
                        {
                        case ItemTier.Tier1:
                            customCostType = CostType.Money;
                            customCost     = (int)Harmony.AccessTools.Field(Harmony.AccessTools.TypeByName("RoR2.MultiShopController"), "baseCost").GetValue(self) * 2;
                            break;

                        case ItemTier.Tier2:
                            customCostType = CostType.Money;
                            customCost     = (int)Harmony.AccessTools.Field(Harmony.AccessTools.TypeByName("RoR2.MultiShopController"), "baseCost").GetValue(self) * 3;
                            break;

                        case ItemTier.Tier3:
                            customCostType = CostType.Money;
                            customCost     = (int)Harmony.AccessTools.Field(Harmony.AccessTools.TypeByName("RoR2.MultiShopController"), "baseCost").GetValue(self) * 5;
                            break;

                        case ItemTier.Lunar:
                            customCostType = CostType.Money;
                            customCost     = (int)Harmony.AccessTools.Field(Harmony.AccessTools.TypeByName("RoR2.MultiShopController"), "baseCost").GetValue(self) * 5;
                            break;

                        case ItemTier.Boss:
                            customCostType = CostType.Money;
                            customCost     = (int)Harmony.AccessTools.Field(Harmony.AccessTools.TypeByName("RoR2.MultiShopController"), "baseCost").GetValue(self) * 4;
                            break;
                        }
                        isCustomCost = false;
                    }
                    else if (randomNumber < 90)//10% Cheap
                    {
                        switch (customTier)
                        {
                        case ItemTier.Tier1:
                            customCostType = CostType.Money;
                            customCost     = (int)Harmony.AccessTools.Field(Harmony.AccessTools.TypeByName("RoR2.MultiShopController"), "baseCost").GetValue(self) / 2;
                            break;

                        case ItemTier.Tier2:
                            customCostType = CostType.Money;
                            customCost     = (int)Harmony.AccessTools.Field(Harmony.AccessTools.TypeByName("RoR2.MultiShopController"), "baseCost").GetValue(self);
                            break;

                        case ItemTier.Tier3:
                            customCostType = CostType.Money;
                            customCost     = (int)Harmony.AccessTools.Field(Harmony.AccessTools.TypeByName("RoR2.MultiShopController"), "baseCost").GetValue(self) * 3;
                            break;

                        case ItemTier.Lunar:
                            customCostType = CostType.Money;
                            customCost     = (int)Harmony.AccessTools.Field(Harmony.AccessTools.TypeByName("RoR2.MultiShopController"), "baseCost").GetValue(self) * 2;
                            break;

                        case ItemTier.Boss:
                            customCostType = CostType.Money;
                            customCost     = (int)Harmony.AccessTools.Field(Harmony.AccessTools.TypeByName("RoR2.MultiShopController"), "baseCost").GetValue(self) * 2;
                            break;
                        }
                        isCustomCost = false;
                    }
                    else if (randomNumber < 100)//10% Lunar
                    {
                        switch (customTier)
                        {
                        case ItemTier.Tier1:
                            customCostType = CostType.WhiteItem;
                            customCost     = 1;
                            break;

                        case ItemTier.Tier2:
                            customCostType = CostType.GreenItem;
                            customCost     = 2;
                            break;

                        case ItemTier.Tier3:
                            customCostType = CostType.Lunar;
                            customCost     = 3;
                            break;

                        case ItemTier.Lunar:
                            customCostType = CostType.Lunar;
                            customCost     = 2;
                            break;

                        case ItemTier.Boss:
                            customCostType = CostType.Lunar;
                            customCost     = 2;
                            break;
                        }
                        isCustomCost = true;
                    }
                    Harmony.AccessTools.Field(Harmony.AccessTools.TypeByName("RoR2.MultiShopController"), "baseCost").SetValue(self, customCost);
                    Harmony.AccessTools.Field(Harmony.AccessTools.TypeByName("RoR2.MultiShopController"), "costType").SetValue(self, customCostType);
                }
                if (isCustomCost)
                {
                    GameObject[] terminalGameObjects = (GameObject[])Harmony.AccessTools.Field(Harmony.AccessTools.TypeByName("RoR2.MultiShopController"), "terminalGameObjects").GetValue(self);

                    foreach (GameObject gameObject in terminalGameObjects)
                    {
                        gameObject.GetComponent <PurchaseInteraction>().automaticallyScaleCostWithDifficulty = false;
                        gameObject.GetComponent <PurchaseInteraction>().cost     = customCost;
                        gameObject.GetComponent <PurchaseInteraction>().costType = customCostType;
                    }
                    Harmony.AccessTools.Field(Harmony.AccessTools.TypeByName("RoR2.MultiShopController"), "terminalGameObjects").SetValue(self, terminalGameObjects);
                }
                orig(self);
            };
            On.RoR2.MultiShopController.CreateTerminals += (orig, self) =>
            {
                randomNumber = Run.instance.treasureRng.RangeInt(0, 100);
                if (randomNumber < (float)Run.instance.ruleBook.GetRuleChoice(RuleCatalog.FindRuleDef("FloodWarning.BetterShopExistenceChances")).extraData)
                {
                    customTier = ItemTier.Tier1;
                    bool failed = false;
                    while (failed == false)
                    {
                        randomNumber = Run.instance.treasureRng.RangeInt(0, 100);
                        if (randomNumber < (float)Run.instance.ruleBook.GetRuleChoice(RuleCatalog.FindRuleDef("FloodWarning.BetterShopChances")).extraData || customTier == ItemTier.Boss)
                        {
                            failed = true;
                            break;
                        }
                        else
                        {
                            customTier += 1;
                        }
                    }
                    Harmony.AccessTools.Field(Harmony.AccessTools.TypeByName("RoR2.MultiShopController"), "itemTier").SetValue(self, customTier);
                }

                orig(self);
            };
            On.RoR2.Run.GetDifficultyScaledCost += (orig, self, baseCost) =>
            {
                if (isCustomCost)
                {
                    isCustomCost = false;
                    return(baseCost);
                }
                else
                {
                    return(orig(self, baseCost));
                }
            };

            return(true);
        }
예제 #19
0
 /// <summary>
 /// Construct a rule. Does not affect the game until you push the rule to a category.
 /// </summary>
 public LobbyRule()
 {
     Def = new RuleDef(RuleNameSequence(), "R2API_RULE");
 }
예제 #20
0
        public void Awake()
        {
            // lets not ruin peoples save files
            On.RoR2.UserProfile.Save += (orig, self, blocking) =>
            {
                return(true);
            };

            // just incase they do add the artifacts we dont want duplicates in the unlockableDefTable and
            // since they dont check for those we will do that for them
            On.RoR2.UnlockableCatalog.RegisterUnlockable += (orig, name, unlockableDef) =>
            {
                if (UnlockableCatalog.GetUnlockableDef(name) != null)
                {
                    return;
                }

                orig(name, unlockableDef);
            };

            // add artifacts to unlocks
            On.RoR2.UnlockableCatalog.Init += (orig) =>
            {
                for (var artifactIdx = ArtifactIndex.Command; artifactIdx < ArtifactIndex.Count; artifactIdx++)
                {
                    var artifactDef = ArtifactCatalog.GetArtifactDef(artifactIdx);
                    if (artifactDef?.unlockableName.Length < 0)
                    {
                        continue;
                    }

                    Reflection.InvokeMethod(typeof(UnlockableCatalog), "RegisterUnlockable",
                                            artifactDef.unlockableName, new UnlockableDef
                    {
                        hidden = true,
                    });
                }

                orig();
            };

            // set neat colors and tooltips for artifacts that have none
            On.RoR2.RuleDef.FromArtifact += (orig, artifactIdx) =>
            {
                var tooltipClr  = ColorCatalog.GetColor(ColorCatalog.ColorIndex.Tier3ItemDark);
                var artifactDef = ArtifactCatalog.GetArtifactDef(artifactIdx);

                var ruleDef = new RuleDef("Artifacts." + artifactIdx.ToString(), artifactDef.nameToken);
                {
                    var ruleChoiceDef1 = ruleDef.AddChoice("On", null, false);
                    ruleChoiceDef1.spritePath       = artifactDef.smallIconSelectedPath;
                    ruleChoiceDef1.tooltipNameColor = tooltipClr;
                    ruleChoiceDef1.unlockableName   = artifactDef.unlockableName;
                    ruleChoiceDef1.artifactIndex    = artifactIdx;

                    var ruleChoiceDef2 = ruleDef.AddChoice("Off", null, false);
                    ruleChoiceDef2.spritePath       = artifactDef.smallIconDeselectedPath;
                    ruleChoiceDef2.tooltipNameColor = tooltipClr;
                    ruleChoiceDef2.materialPath     = "Materials/UI/matRuleChoiceOff";
                    ruleChoiceDef2.tooltipBodyToken = null;

                    switch (artifactIdx)
                    {
                    case ArtifactIndex.Bomb:
                        ruleChoiceDef1.tooltipNameToken = "Spite";
                        ruleChoiceDef2.tooltipNameToken = ruleChoiceDef1.tooltipNameToken;
                        ruleChoiceDef1.tooltipBodyToken = "Makes monsters explode on death";
                        ruleChoiceDef2.tooltipBodyToken = ruleChoiceDef1.tooltipBodyToken;
                        break;

                    case ArtifactIndex.Spirit:
                        ruleChoiceDef1.tooltipNameToken = "Spirit";
                        ruleChoiceDef2.tooltipNameToken = ruleChoiceDef1.tooltipNameToken;
                        ruleChoiceDef1.tooltipBodyToken = "Makes you and monsters move faster at low health";
                        ruleChoiceDef2.tooltipBodyToken = ruleChoiceDef1.tooltipBodyToken;
                        break;

                    case ArtifactIndex.Enigma:
                        ruleChoiceDef1.tooltipNameToken = "Enigma";
                        ruleChoiceDef2.tooltipNameToken = ruleChoiceDef1.tooltipNameToken;
                        ruleChoiceDef1.tooltipBodyToken = "Give you a special use item that triggers a random effect on use";
                        ruleChoiceDef2.tooltipBodyToken = ruleChoiceDef1.tooltipBodyToken;
                        break;

                    default:
                        ruleChoiceDef1.tooltipNameToken = "Work in Progress";
                        ruleChoiceDef2.tooltipNameToken = ruleChoiceDef1.tooltipNameToken;
                        ruleChoiceDef1.tooltipBodyToken = "This artifact does not do anything yet";
                        ruleChoiceDef2.tooltipBodyToken = ruleChoiceDef1.tooltipBodyToken;
                        break;
                    }
                }

                ruleDef.MakeNewestChoiceDefault();

                return(ruleDef);
            };

            // unlock artifacts for the current user
            LocalUserManager.onUserSignIn += (user) =>
            {
                for (var artifactIdx = ArtifactIndex.Command; artifactIdx < ArtifactIndex.Count; artifactIdx++)
                {
                    var artifactDef = ArtifactCatalog.GetArtifactDef(artifactIdx);
                    if (artifactDef?.unlockableName.Length < 0)
                    {
                        continue;
                    }

                    var unlockableDef = UnlockableCatalog.GetUnlockableDef(artifactDef.unlockableName);
                    if (unlockableDef is null)
                    {
                        Logger.LogError($"Could not unlock artifact {artifactDef.nameToken}, " +
                                        "UnlockableDef does not exist");
                        continue;
                    }

                    user.userProfile.GrantUnlockable(unlockableDef);
                }
            };
        }
예제 #21
0
 protected void On(RuleDisabled @event)
 {
     RuleDef = RuleDef.Disable();
 }
예제 #22
0
        public void Awake()
        {
            var addRule     = typeof(RuleCatalog).GetMethod("AddRule", BindingFlags.Static | BindingFlags.NonPublic, null, new Type[] { typeof(RuleDef) }, null);
            var addCategory = typeof(RuleCatalog).GetMethod("AddCategory", BindingFlags.Static | BindingFlags.NonPublic, null, new Type[] { typeof(string), typeof(Color), typeof(string), typeof(Func <bool>) }, null);

            addCategory.Invoke(null, new object[] { "Ally Editor", new Color(94 / 255, 82 / 255, 30 / 255, byte.MaxValue), "", new Func <bool>(() => false) });

            RuleDef allySpawnType = new RuleDef("FloodWarning.allySpawnType", "Guaranteed");


            RuleChoiceDef myRule = allySpawnType.AddChoice("0", 0, false);

            myRule.spritePath       = "Textures/MiscIcons/texRuleBonusStartingMoney";
            myRule.tooltipNameToken = "Vanilla";
            myRule.tooltipBodyToken = "Allies do not spawn with any extra items";
            RuleChoiceDef myRule2 = allySpawnType.AddChoice("0", 1, false);

            myRule2.spritePath       = "Textures/MiscIcons/texRuleBonusStartingMoney";
            myRule2.tooltipNameToken = "Item Ratio";
            myRule2.tooltipBodyToken = "Allies will gain extra items based on how many their owner has (Ratio editable below)";
            allySpawnType.MakeNewestChoiceDefault();
            RuleChoiceDef myRule3 = allySpawnType.AddChoice("0", 2, false);

            myRule3.spritePath       = "Textures/MiscIcons/texRuleBonusStartingMoney";
            myRule3.tooltipNameToken = "Direct Copy";
            myRule3.tooltipBodyToken = "Allies will have a direct copy of their owner's items, not including equipment";
            RuleChoiceDef myRule4 = allySpawnType.AddChoice("0", 2, false);

            myRule4.spritePath       = "Textures/MiscIcons/texRuleBonusStartingMoney";
            myRule4.tooltipNameToken = "Direct Copy+";
            myRule4.tooltipBodyToken = "Allies will have a direct copy of their owner's items, Including equipment";

            addRule.Invoke(null, new object[] { allySpawnType });

            RuleDef allyItemRatio = new RuleDef("FloodWarning.allyItemRatio", "Guaranteed");

            for (float o = 0; o <= 20; o++)
            {
                float         myNum   = o / 10;
                RuleChoiceDef myRule5 = allyItemRatio.AddChoice("0", myNum, false);
                myRule5.spritePath       = "Textures/MiscIcons/texRuleBonusStartingMoney";
                myRule5.tooltipNameToken = "" + myNum * 10 + " to 10";
                myRule5.tooltipBodyToken = "Allies will spawn with " + myNum + "x the items their owner has";
                if (myNum == 0.4f)
                {
                    allyItemRatio.MakeNewestChoiceDefault();
                }
            }
            addRule.Invoke(null, new object[] { allyItemRatio });

            On.RoR2.SummonMasterBehavior.OpenSummon += (orig, self, activator) =>
            {
                GameObject      gameObject = UnityEngine.Object.Instantiate <GameObject>(self.masterPrefab, self.transform.position, self.transform.rotation);
                CharacterBody   component  = activator.GetComponent <CharacterBody>();
                CharacterMaster master     = component.master;
                CharacterMaster component2 = gameObject.GetComponent <CharacterMaster>();
                component2.teamIndex = TeamComponent.GetObjectTeam(component.gameObject);
                Inventory component3 = gameObject.GetComponent <Inventory>();
                giveItems(component3, master.inventory, (int)(Run.instance.ruleBook.GetRuleChoice(RuleCatalog.FindRuleDef("FloodWarning.allySpawnType")).extraData));
                NetworkServer.Spawn(gameObject);
                component2.SpawnBody(component2.bodyPrefab, self.transform.position + Vector3.up * 0.8f, self.transform.rotation);
                AIOwnership component4 = gameObject.GetComponent <AIOwnership>();
                if (component4 && component && master)
                {
                    component4.ownerMaster = master;
                }
                BaseAI component5 = gameObject.GetComponent <BaseAI>();
                if (component5)
                {
                    component5.leader.gameObject = activator.gameObject;
                }
                UnityEngine.Object.Destroy(self.gameObject);
            };

            On.RoR2.EquipmentSlot.SummonMaster += (orig, self, masterObjectPrefab, position) =>
            {
                GameObject      gameObject = UnityEngine.Object.Instantiate <GameObject>(masterObjectPrefab, position, self.transform.rotation);
                CharacterBody   component  = self.GetComponent <CharacterBody>();
                CharacterMaster master     = component.master;
                CharacterMaster component2 = gameObject.GetComponent <CharacterMaster>();
                component2.teamIndex = TeamComponent.GetObjectTeam(component.gameObject);
                Inventory component3 = gameObject.GetComponent <Inventory>();
                giveItems(component3, master.inventory, (int)(Run.instance.ruleBook.GetRuleChoice(RuleCatalog.FindRuleDef("FloodWarning.allySpawnType")).extraData));
                NetworkServer.Spawn(gameObject);
                component2.SpawnBody(component2.bodyPrefab, position, self.transform.rotation);
                AIOwnership component4 = gameObject.GetComponent <AIOwnership>();
                if (component4 && component && master)
                {
                    component4.ownerMaster = master;
                }
                BaseAI component5 = gameObject.GetComponent <BaseAI>();
                if (component5)
                {
                    component5.leader.gameObject = self.gameObject;
                }
                return(component2);
            };

            //    On.RoR2.CharacterBody.UpdateBeetleGuardAllies += (orig, self) =>
            //    {
            //        if (NetworkServer.active)
            //        {
            //            int num = self.inventory ? self.inventory.GetItemCount(ItemIndex.BeetleGland) : 0;
            //            if (num > 0 && self.master.GetDeployableCount(DeployableSlot.BeetleGuardAlly) < num)
            //            {
            //                self.SetFieldValue("guardResummonCooldown", self.GetFieldValue<float>("guardResummonCooldown") - Time.fixedDeltaTime);

            //                if (self.GetFieldValue<float>("guardResummonCooldown") <= 0f)
            //                {
            //                    self.SetFieldValue("guardResummonCooldown", 30f);
            //                    GameObject gameObject = DirectorCore.instance.TrySpawnObject((SpawnCard)Resources.Load("SpawnCards/CharacterSpawnCards/cscBeetleGuardAlly"), new DirectorPlacementRule
            //                    {
            //                        placementMode = DirectorPlacementRule.PlacementMode.Approximate,
            //                        minDistance = 3f,
            //                        maxDistance = 40f,
            //                        spawnOnTarget = self.transform
            //                    }, RoR2Application.rng);
            //                    if (gameObject)
            //                    {
            //                        CharacterMaster component = gameObject.GetComponent<CharacterMaster>();

            //                        Inventory inventory = gameObject.GetComponent<Inventory>();

            //                        inventory.CopyItemsFrom(self.inventory);
            //                        giveItems(inventory, self.inventory, (int)(Run.instance.ruleBook.GetRuleChoice(RuleCatalog.FindRuleDef("FloodWarning.allySpawnType")).extraData));

            //                        AIOwnership component2 = gameObject.GetComponent<AIOwnership>();
            //                        BaseAI component3 = gameObject.GetComponent<BaseAI>();
            //                        if (component)
            //                        {
            //                            component.teamIndex = TeamComponent.GetObjectTeam(self.gameObject);
            //                            component.inventory.GiveItem(ItemIndex.BoostDamage, 30);
            //                            component.inventory.GiveItem(ItemIndex.BoostHp, 10);
            //                            GameObject bodyObject = component.GetBodyObject();
            //                            if (bodyObject)
            //                            {
            //                                Deployable component4 = bodyObject.GetComponent<Deployable>();
            //                                self.master.AddDeployable(component4, DeployableSlot.BeetleGuardAlly);
            //                            }
            //                        }
            //                        if (component2)
            //                        {
            //                            component2.ownerMaster = self.master;
            //                        }
            //                        if (component3)
            //                        {
            //                            component3.leader.gameObject = self.gameObject;
            //                        }
            //                    }
            //                }
            //            }
            //        }

            //    };
        }
        // Token: 0x06000088 RID: 136 RVA: 0x00004224 File Offset: 0x00002424
        public static void Postfix()
        {
            //	Log.Message("GenerateImpliedDefs_PreResolve");

            PawnGroupKindDef pawnGroupKindDef = new PawnGroupKindDef();

            pawnGroupKindDef.defName     = "Hive_OgsOld_ExtraHives";
            pawnGroupKindDef.workerClass = typeof(PawnGroupKindWorker_Normal);
            DefGenerator.AddImpliedDef <PawnGroupKindDef>(pawnGroupKindDef);

            pawnGroupKindDef             = new PawnGroupKindDef();
            pawnGroupKindDef.defName     = "Tunneler_OgsOld_ExtraHives";
            pawnGroupKindDef.workerClass = typeof(PawnGroupKindWorker_Normal);
            DefGenerator.AddImpliedDef <PawnGroupKindDef>(pawnGroupKindDef);

            PawnsArrivalModeDef pawnsArrivalModeDef = new PawnsArrivalModeDef();

            pawnsArrivalModeDef.defName        = "EdgeTunnelIn_OgsOld_ExtraHives";
            pawnsArrivalModeDef.textEnemy      = "A group of {0} from {1} have tunneled in nearby.";
            pawnsArrivalModeDef.textFriendly   = "A group of friendly {0} from {1} have tunneled in nearby.";
            pawnsArrivalModeDef.textWillArrive = "{0_pawnsPluralDef} will tunnel in.";
            pawnsArrivalModeDef.workerClass    = typeof(OgsOld_ExtraHives.PawnsArrivalModeWorker_EdgeTunnel);

            /*
             * pawnsArrivalModeDef.selectionWeightCurve = new SimpleCurve();
             * pawnsArrivalModeDef.selectionWeightCurve.Add(new CurvePoint(300f,0f));
             * pawnsArrivalModeDef.selectionWeightCurve.Add(new CurvePoint(700f,0.3f));
             */
            DefGenerator.AddImpliedDef <PawnsArrivalModeDef>(pawnsArrivalModeDef);

            pawnsArrivalModeDef                = new PawnsArrivalModeDef();
            pawnsArrivalModeDef.defName        = "EdgeTunnelInGroups_OgsOld_ExtraHives";
            pawnsArrivalModeDef.textEnemy      = "Several separate groups of {0} from {1} have tunneled in nearby.";
            pawnsArrivalModeDef.textFriendly   = "Several separate groups of friendly {0} from {1} have tunneled in nearby.";
            pawnsArrivalModeDef.textWillArrive = "Several separate groups of {0_pawnsPluralDef} will tunnel in.";
            pawnsArrivalModeDef.workerClass    = typeof(OgsOld_ExtraHives.PawnsArrivalModeWorker_EdgeTunnelGroups);

            /*
             * pawnsArrivalModeDef.selectionWeightCurve = new SimpleCurve();
             * pawnsArrivalModeDef.selectionWeightCurve.Add(new CurvePoint(100f, 0f));
             * pawnsArrivalModeDef.selectionWeightCurve.Add(new CurvePoint(300f, 0.2f));
             * pawnsArrivalModeDef.selectionWeightCurve.Add(new CurvePoint(700f, 0.5f));
             * pawnsArrivalModeDef.pointsFactorCurve = new SimpleCurve();
             * pawnsArrivalModeDef.pointsFactorCurve.Add(new CurvePoint(0f, 0.9f));
             */
            DefGenerator.AddImpliedDef <PawnsArrivalModeDef>(pawnsArrivalModeDef);

            pawnsArrivalModeDef                = new PawnsArrivalModeDef();
            pawnsArrivalModeDef.defName        = "CenterTunnelIn_OgsOld_ExtraHives";
            pawnsArrivalModeDef.textEnemy      = "A group of {0} from {1} have tunneled in right on top of you!";
            pawnsArrivalModeDef.textFriendly   = "A group of friendly {0} from {1} have tunneled in right on top of you!";
            pawnsArrivalModeDef.textWillArrive = "{0_pawnsPluralDef} will tunnel in right on top of you.";
            pawnsArrivalModeDef.workerClass    = typeof(OgsOld_ExtraHives.PawnsArrivalModeWorker_CenterTunnel);

            /*
             * pawnsArrivalModeDef.selectionWeightCurve = new SimpleCurve();
             * pawnsArrivalModeDef.selectionWeightCurve.Add(new CurvePoint(300f, 0.0f));
             * pawnsArrivalModeDef.selectionWeightCurve.Add(new CurvePoint(1000f, 3.5f));
             * pawnsArrivalModeDef.pointsFactorCurve = new SimpleCurve();
             * pawnsArrivalModeDef.pointsFactorCurve.Add(new CurvePoint(0f, 0.75f));
             * pawnsArrivalModeDef.pointsFactorCurve.Add(new CurvePoint(5000f, 0.5f));
             */
            DefGenerator.AddImpliedDef <PawnsArrivalModeDef>(pawnsArrivalModeDef);

            pawnsArrivalModeDef                = new PawnsArrivalModeDef();
            pawnsArrivalModeDef.defName        = "RandomTunnelIn_OgsOld_ExtraHives";
            pawnsArrivalModeDef.textEnemy      = "A group of {0} from {1} have tunneled in. They are scattered all over the area!";
            pawnsArrivalModeDef.textFriendly   = "A group of friendly {0} from {1} have tunneled in. They are scattered all over the area!";
            pawnsArrivalModeDef.textWillArrive = "{0_pawnsPluralDef} will tunnel in.";
            pawnsArrivalModeDef.workerClass    = typeof(OgsOld_ExtraHives.PawnsArrivalModeWorker_RandomTunnel);

            /*
             * pawnsArrivalModeDef.selectionWeightCurve = new SimpleCurve();
             * pawnsArrivalModeDef.selectionWeightCurve.Add(new CurvePoint(300f, 0f));
             * pawnsArrivalModeDef.selectionWeightCurve.Add(new CurvePoint(1000f, 1.9f));
             * pawnsArrivalModeDef.pointsFactorCurve = new SimpleCurve();
             * pawnsArrivalModeDef.pointsFactorCurve.Add(new CurvePoint(0f, 0.7f));
             * pawnsArrivalModeDef.pointsFactorCurve.Add(new CurvePoint(5000f, 0.45f));
             */
            DefGenerator.AddImpliedDef <PawnsArrivalModeDef>(pawnsArrivalModeDef);

            ThingDef thingDef = new ThingDef();

            thingDef.defName                   = "InfestedMeteoriteIncoming_OgsOld_ExtraHives";
            thingDef.category                  = ThingCategory.Ethereal;
            thingDef.thingClass                = typeof(Skyfaller);
            thingDef.useHitPoints              = false;
            thingDef.drawOffscreen             = true;
            thingDef.tickerType                = TickerType.Normal;
            thingDef.altitudeLayer             = AltitudeLayer.Skyfaller;
            thingDef.drawerType                = DrawerType.RealtimeOnly;
            thingDef.skyfaller                 = new SkyfallerProperties();
            thingDef.label                     = "meteorite (incoming)";
            thingDef.size                      = new IntVec2(3, 3);
            thingDef.graphicData               = new GraphicData();
            thingDef.graphicData.texPath       = "Things/Skyfaller/Meteorite";
            thingDef.graphicData.graphicClass  = typeof(Graphic_Single);
            thingDef.graphicData.shaderType    = ShaderTypeDefOf.Transparent;
            thingDef.graphicData.drawSize      = new Vector2(10, 10);
            thingDef.skyfaller.shadowSize      = new Vector2(3, 3);
            thingDef.skyfaller.explosionRadius = 4;
            thingDef.skyfaller.explosionDamage = DamageDefOf.Bomb;
            thingDef.skyfaller.rotateGraphicTowardsDirection = true;
            thingDef.skyfaller.speed = 1.2f;
            DefGenerator.AddImpliedDef <ThingDef>(thingDef);

            thingDef               = new ThingDef();
            thingDef.defName       = "Tunneler_OgsOld_ExtraHives";
            thingDef.category      = ThingCategory.Ethereal;
            thingDef.thingClass    = typeof(OgsOld_ExtraHives.TunnelRaidSpawner);
            thingDef.useHitPoints  = false;
            thingDef.drawOffscreen = true;
            thingDef.alwaysFlee    = true;
            thingDef.tickerType    = TickerType.Normal;
            thingDef.altitudeLayer = AltitudeLayer.Skyfaller;
            thingDef.drawerType    = DrawerType.RealtimeOnly;
            thingDef.label         = "tunnel (incoming)";
            thingDef.size          = new IntVec2(1, 1);
            DefGenerator.AddImpliedDef <ThingDef>(thingDef);



            //PawnsArrivalModeDef

            /*
             * thingDef = new ThingDef();
             * thingDef.defName = "Hive_OgsOld_ExtraHives";
             * thingDef.category = ThingCategory.Ethereal;
             * thingDef.thingClass = typeof(OgsOld_ExtraHives.TunnelRaidSpawner);
             * thingDef.useHitPoints = false;
             * thingDef.drawOffscreen = true;
             * thingDef.alwaysFlee = true;
             * thingDef.tickerType = TickerType.Normal;
             * thingDef.altitudeLayer = AltitudeLayer.Skyfaller;
             * thingDef.drawerType = DrawerType.RealtimeOnly;
             * thingDef.label = "tunnel (incoming)";
             * thingDef.size = new IntVec2(3,3);
             * DefGenerator.AddImpliedDef<ThingDef>(thingDef);
             *
             */

            //RuleDef

            RuleDef ruleDef;

            ruleDef           = new RuleDef();
            ruleDef.defName   = "OgsOld_ExtraHives_HiveBaseMaker";
            ruleDef.symbol    = "OgsOld_ExtraHives_HiveBaseMaker";
            ruleDef.resolvers = new List <SymbolResolver>();
            ruleDef.resolvers.Add(new OgsOld_ExtraHives.GenStuff.SymbolResolver_Hivebase());
            DefGenerator.AddImpliedDef <RuleDef>(ruleDef);

            ruleDef           = new RuleDef();
            ruleDef.defName   = "OgsOld_ExtraHives_HiveMoundMaker";
            ruleDef.symbol    = "OgsOld_ExtraHives_HiveMoundMaker";
            ruleDef.resolvers = new List <SymbolResolver>();
            ruleDef.resolvers.Add(new OgsOld_ExtraHives.GenStuff.SymbolResolver_HiveBaseMoundMaker());
            DefGenerator.AddImpliedDef <RuleDef>(ruleDef);

            ruleDef           = new RuleDef();
            ruleDef.defName   = "OgsOld_ExtraHives_HiveClearChamber";
            ruleDef.symbol    = "OgsOld_ExtraHives_HiveClearChamber";
            ruleDef.resolvers = new List <SymbolResolver>();
            ruleDef.resolvers.Add(new OgsOld_ExtraHives.GenStuff.SymbolResolver_ClearChamber());
            DefGenerator.AddImpliedDef <RuleDef>(ruleDef);

            ruleDef           = new RuleDef();
            ruleDef.defName   = "OgsOld_ExtraHives_HiveInterals";
            ruleDef.symbol    = "OgsOld_ExtraHives_HiveInterals";
            ruleDef.resolvers = new List <SymbolResolver>();
            ruleDef.resolvers.Add(new OgsOld_ExtraHives.GenStuff.SymbolResolver_HiveInternals());
            DefGenerator.AddImpliedDef <RuleDef>(ruleDef);

            ruleDef           = new RuleDef();
            ruleDef.defName   = "OgsOld_ExtraHives_HiveOutdoorLighting";
            ruleDef.symbol    = "OgsOld_ExtraHives_HiveOutdoorLighting";
            ruleDef.resolvers = new List <SymbolResolver>();
            ruleDef.resolvers.Add(new OgsOld_ExtraHives.GenStuff.SymbolResolver_OutdoorLightingHivebase());
            DefGenerator.AddImpliedDef <RuleDef>(ruleDef);

            ruleDef           = new RuleDef();
            ruleDef.defName   = "OgsOld_ExtraHives_HiveRandomCorpse";
            ruleDef.symbol    = "OgsOld_ExtraHives_HiveRandomCorpse";
            ruleDef.resolvers = new List <SymbolResolver>();
            ruleDef.resolvers.Add(new OgsOld_ExtraHives.GenStuff.SymbolResolver_RandomCorpse());
            DefGenerator.AddImpliedDef <RuleDef>(ruleDef);

            ruleDef           = new RuleDef();
            ruleDef.defName   = "OgsOld_ExtraHives_HiveRandomDamage";
            ruleDef.symbol    = "OgsOld_ExtraHives_HiveRandomDamage";
            ruleDef.resolvers = new List <SymbolResolver>();
            ruleDef.resolvers.Add(new OgsOld_ExtraHives.GenStuff.SymbolResolver_RandomDamage());
            DefGenerator.AddImpliedDef <RuleDef>(ruleDef);

            ruleDef           = new RuleDef();
            ruleDef.defName   = "OgsOld_ExtraHives_HiveRandomHives";
            ruleDef.symbol    = "OgsOld_ExtraHives_HiveRandomHives";
            ruleDef.resolvers = new List <SymbolResolver>();
            ruleDef.resolvers.Add(new OgsOld_ExtraHives.GenStuff.SymbolResolver_RandomHives());
            DefGenerator.AddImpliedDef <RuleDef>(ruleDef);

            ruleDef           = new RuleDef();
            ruleDef.defName   = "OgsOld_ExtraHives_PawnGroup";
            ruleDef.symbol    = "OgsOld_ExtraHives_PawnGroup";
            ruleDef.resolvers = new List <SymbolResolver>();
            ruleDef.resolvers.Add(new OgsOld_ExtraHives.GenStuff.SymbolResolver_PawnHiveGroup());
            DefGenerator.AddImpliedDef <RuleDef>(ruleDef);

            ruleDef           = new RuleDef();
            ruleDef.defName   = "OgsOld_ExtraHives_Pawn";
            ruleDef.symbol    = "OgsOld_ExtraHives_Pawn";
            ruleDef.resolvers = new List <SymbolResolver>();
            ruleDef.resolvers.Add(new OgsOld_ExtraHives.GenStuff.SymbolResolver_SingleHivePawn());
            DefGenerator.AddImpliedDef <RuleDef>(ruleDef);
        }
예제 #24
0
 protected void On(RuleUpdated @event)
 {
     RuleDef = RuleDef.Update(@event.Trigger).Update(@event.Action);
 }
예제 #25
0
        private RuleChoiceDef PreGameRuleVoteController_GetDefaultChoice(On.RoR2.PreGameRuleVoteController.orig_GetDefaultChoice orig, PreGameRuleVoteController self, RuleDef ruleDef)
        {
            int choice = PreGameController.instance.readOnlyRuleBook.GetRuleChoiceIndex(ruleDef);

            if (!ruleDef.category.isHidden)
            {
                string catagory = ruleDef.category.displayToken;
                string name     = ruleDef.globalName;
                choice = configfile.Wrap(catagory, name, null, choice).Value;
            }

            return(ruleDef.choices[choice]);
        }
예제 #26
0
        public static bool RunEnemyEdits()
        {
            var addRule     = typeof(RuleCatalog).GetMethod("AddRule", BindingFlags.Static | BindingFlags.NonPublic, null, new Type[] { typeof(RuleDef) }, null);
            var addCategory = typeof(RuleCatalog).GetMethod("AddCategory", BindingFlags.Static | BindingFlags.NonPublic, null, new Type[] { typeof(string), typeof(Color), typeof(string), typeof(Func <bool>) }, null);



            addCategory.Invoke(null, new object[] { "Enemy Editor", new Color(94 / 255, 82 / 255, 30 / 255, byte.MaxValue), "", new Func <bool>(() => false) });

            RuleDef eliteSpawnCost = new RuleDef("FloodWarning.EliteCost", "Guaranteed");

            for (float o = 0; o <= 10; o++)
            {
                float         myNum  = o;
                RuleChoiceDef myRule = eliteSpawnCost.AddChoice("0", myNum, false);
                myRule.spritePath       = "Textures/MiscIcons/texRuleBonusStartingMoney";
                myRule.tooltipNameToken = "" + myNum + "x elite cost";
                myRule.tooltipBodyToken = "If the game is able to spawn " + myNum + " Non-Elite enemies this tick, it will try to spawn 1 elite instead";
                if (myNum == 5)
                {
                    eliteSpawnCost.MakeNewestChoiceDefault();
                }
            }
            addRule.Invoke(null, new object[] { eliteSpawnCost });

            //On.RoR2.CombatDirector.AttemptSpawnOnTarget += (orig, self, spawnTarget) =>
            //{
            //    if (orig(self, spawnTarget) == false && Run.instance.difficultyCoefficient > 15f)
            //    {
            //    GameObject gameObject = UnityEngine.Object.Instantiate<GameObject>(self.lastAttemptedMonsterCard.spawnCard.prefab, self.transform.position, self.transform.rotation);
            //        CharacterMaster component2 = gameObject.GetComponent<CharacterMaster>();
            //        component2.teamIndex = TeamIndex.Monster;
            //        Inventory component3 = gameObject.GetComponent<Inventory>();
            //        NetworkServer.Spawn(gameObject);
            //        component2.SpawnBody(component2.bodyPrefab, self.transform.position + Vector3.up * 0.8f, self.transform.rotation);
            //        for (int i = 0; i < Run.instance.difficultyCoefficient - 15f;i++)
            //        {
            //            component3.GiveItem(Run.instance.availableTier1DropList[Run.instance.spawnRng.RangeInt(0, Run.instance.availableTier1DropList.Count)].itemIndex, 1);
            //        }
            //    }
            //    return true;

            //};

            On.RoR2.CombatDirector.Awake += (orig, self) =>
            {
                Harmony.AccessTools.Field(Harmony.AccessTools.TypeByName("RoR2.CombatDirector"), "eliteMultiplierCost").SetValue(self, (float)(Run.instance.ruleBook.GetRuleChoice(RuleCatalog.FindRuleDef("FloodWarning.EliteCost")).extraData));
                orig(self);
            };


            //On.RoR2.CombatDirector.SetNextSpawnAsBoss += (orig, self) =>
            //{
            //    Harmony.AccessTools.Field(Harmony.AccessTools.TypeByName("RoR2.CombatDirector"), "currentActiveEliteIndex").SetValue(self, (EliteIndex)Run.instance.spawnRng.RangeInt(0, (int)EliteIndex.Count));
            //    orig(self);
            //};
            //On.RoR2.CombatDirector.OverrideCurrentMonsterCard += (orig, self,card) =>
            //{
            //    Harmony.AccessTools.Field(Harmony.AccessTools.TypeByName("RoR2.CombatDirector"), "currentActiveEliteIndex").SetValue(self, (EliteIndex)Run.instance.spawnRng.RangeInt(0, (int)EliteIndex.Count));
            //    orig(self,card);
            //};
            return(true);
        }
예제 #27
0
        public static bool RunSizeManager()
        {
            var addRule     = typeof(RuleCatalog).GetMethod("AddRule", BindingFlags.Static | BindingFlags.NonPublic, null, new Type[] { typeof(RuleDef) }, null);
            var addCategory = typeof(RuleCatalog).GetMethod("AddCategory", BindingFlags.Static | BindingFlags.NonPublic, null, new Type[] { typeof(string), typeof(Color), typeof(string), typeof(Func <bool>) }, null);



            var myvar = addCategory.Invoke(null, new object[] { "Entity Sizes", new Color(94 / 255, 82 / 255, 30 / 255, byte.MaxValue), "", new Func <bool>(() => false) });

            RuleDef SpawnPlayerRule = new RuleDef("FloodWarning.PlayerSize", "Guaranteed");

            SpawnPlayerRule.defaultChoiceIndex = 8;
            for (float o = 1; o <= 50; o++)
            {
                float         myNum  = o / 10;
                RuleChoiceDef myRule = SpawnPlayerRule.AddChoice("0", myNum, false);
                myRule.spritePath       = "Textures/MiscIcons/texRuleBonusStartingMoney";
                myRule.tooltipNameToken = "" + myNum + "x size for Players";
                myRule.tooltipBodyToken = "When a Player spawns in your world, they will be " + myNum + "x the size";
            }
            addRule.Invoke(null, new object[] { SpawnPlayerRule });
            RuleDef SpawnAllyRule = new RuleDef("FloodWarning.AllySize", "Guaranteed");

            SpawnAllyRule.defaultChoiceIndex = 6;
            for (float o = 1; o <= 50; o++)
            {
                float         myNum  = o / 10;
                RuleChoiceDef myRule = SpawnAllyRule.AddChoice("0", myNum, false);
                myRule.spritePath       = "Textures/MiscIcons/texRuleBonusStartingMoney";
                myRule.tooltipNameToken = "" + myNum + "x size for Allies";
                myRule.tooltipBodyToken = "When an Ally (Drone, Turret) spawns in your world, they will be " + myNum + "x the size";
            }
            addRule.Invoke(null, new object[] { SpawnAllyRule });
            RuleDef SpawnNeutralRule = new RuleDef("FloodWarning.NeutralSize", "Guaranteed");

            SpawnNeutralRule.defaultChoiceIndex = 10;
            for (float o = 1; o <= 50; o++)
            {
                float         myNum  = o / 10;
                RuleChoiceDef myRule = SpawnNeutralRule.AddChoice("0", myNum, false);
                myRule.spritePath       = "Textures/MiscIcons/texRuleBonusStartingMoney";
                myRule.tooltipNameToken = "" + myNum + "x size for Neutral Entities";
                myRule.tooltipBodyToken = "When a Neutral Entity (Newt) spawns in your world, they will be " + myNum + "x the size";
            }
            addRule.Invoke(null, new object[] { SpawnNeutralRule });

            RuleDef SpawnBossRule = new RuleDef("FloodWarning.BossSize", "Guaranteed");

            SpawnBossRule.defaultChoiceIndex = 11;
            for (float o = 1; o <= 50; o++)
            {
                float         myNum  = o / 10;
                RuleChoiceDef myRule = SpawnBossRule.AddChoice("0", myNum, false);
                myRule.spritePath       = "Textures/MiscIcons/texRuleBonusStartingMoney";
                myRule.tooltipNameToken = "" + myNum + "x size for Boss";
                myRule.tooltipBodyToken = "When a Boss spawns in your world, they will be " + myNum + "x the size";
            }
            addRule.Invoke(null, new object[] { SpawnBossRule });

            RuleDef SpawnChampionRule = new RuleDef("FloodWarning.ChampionSize", "Guaranteed");

            SpawnChampionRule.defaultChoiceIndex = 15;
            for (float o = 1; o <= 50; o++)
            {
                float         myNum  = o / 10;
                RuleChoiceDef myRule = SpawnChampionRule.AddChoice("0", myNum, false);
                myRule.spritePath       = "Textures/MiscIcons/texRuleBonusStartingMoney";
                myRule.tooltipNameToken = "" + myNum + "x size for Teleporter Bosses (Champions)";
                myRule.tooltipBodyToken = "When a Teleporter Boss (Champion) spawns in your world, they will be " + myNum + "x the size";
            }
            addRule.Invoke(null, new object[] { SpawnChampionRule });

            RuleDef SpawnEliteRule = new RuleDef("FloodWarning.EliteSize", "Guaranteed");

            SpawnEliteRule.defaultChoiceIndex = 13;
            for (float o = 1; o <= 50; o++)
            {
                float         myNum  = o / 10;
                RuleChoiceDef myRule = SpawnEliteRule.AddChoice("0", myNum, false);
                myRule.spritePath       = "Textures/MiscIcons/texRuleBonusStartingMoney";
                myRule.tooltipNameToken = "" + myNum + "x size for Elites";
                myRule.tooltipBodyToken = "When an Elite spawns in your world, they will be " + myNum + "x the size";
            }
            addRule.Invoke(null, new object[] { SpawnEliteRule });

            RuleDef SpawnMonsterRule = new RuleDef("FloodWarning.MonsterSize", "Guaranteed");

            SpawnMonsterRule.defaultChoiceIndex = 9;
            for (float o = 1; o <= 50; o++)
            {
                float         myNum  = o / 10;
                RuleChoiceDef myRule = SpawnMonsterRule.AddChoice("0", myNum, false);
                myRule.spritePath       = "Textures/MiscIcons/texRuleBonusStartingMoney";
                myRule.tooltipNameToken = "" + myNum + "x size for Non-Elite, Non-Boss Monsters";
                myRule.tooltipBodyToken = "Whenever ANY enemy spawns in your world, they will be " + myNum + "x the size";
            }
            addRule.Invoke(null, new object[] { SpawnMonsterRule });

            On.RoR2.CharacterMaster.OnBodyStart += (orig, self, body) =>
            {
                orig(self, body);
                var   tf          = body.modelLocator.modelTransform.localScale;
                float scaleFactor = 1f;
                if (body.isChampion)
                {
                    scaleFactor *= (float)Run.instance.ruleBook.GetRuleChoice(RuleCatalog.FindRuleDef("FloodWarning.ChampionSize")).extraData;
                }

                if (body.isBoss)
                {
                    scaleFactor *= (float)Run.instance.ruleBook.GetRuleChoice(RuleCatalog.FindRuleDef("FloodWarning.BossSize")).extraData;
                }

                if (body.isElite)
                {
                    scaleFactor *= (float)Run.instance.ruleBook.GetRuleChoice(RuleCatalog.FindRuleDef("FloodWarning.EliteSize")).extraData;
                }
                if (body.GetComponent <TeamComponent>().teamIndex == TeamIndex.Monster)
                {
                    scaleFactor *= (float)Run.instance.ruleBook.GetRuleChoice(RuleCatalog.FindRuleDef("FloodWarning.MonsterSize")).extraData;
                }
                if (body.GetComponent <TeamComponent>().teamIndex == TeamIndex.Player && !body.isPlayerControlled)
                {
                    scaleFactor *= (float)Run.instance.ruleBook.GetRuleChoice(RuleCatalog.FindRuleDef("FloodWarning.AllySize")).extraData;
                }
                if (body.GetComponent <TeamComponent>().teamIndex == TeamIndex.Neutral)
                {
                    scaleFactor *= (float)Run.instance.ruleBook.GetRuleChoice(RuleCatalog.FindRuleDef("FloodWarning.NeutralSize")).extraData;
                }

                if (body.isPlayerControlled)
                {
                    scaleFactor *= (float)Run.instance.ruleBook.GetRuleChoice(RuleCatalog.FindRuleDef("FloodWarning.PlayerSize")).extraData;
                }
                body.modelLocator.modelTransform.localScale = new Vector3(tf.x * scaleFactor, tf.y * scaleFactor, tf.z * scaleFactor);
            };
            return(true);
        }
예제 #28
0
        public void Awake()//Code that runs when the game starts
        {
            var addRule     = typeof(RuleCatalog).GetMethod("AddRule", BindingFlags.Static | BindingFlags.NonPublic, null, new Type[] { typeof(RuleDef) }, null);
            var addCategory = typeof(RuleCatalog).GetMethod("AddCategory", BindingFlags.Static | BindingFlags.NonPublic, null, new Type[] { typeof(string), typeof(Color), typeof(string), typeof(Func <bool>) }, null);

            var myvar = addCategory.Invoke(null, new object[] { "Entity Sizes", new Color(94 / 255, 82 / 255, 30 / 255, byte.MaxValue), "", new Func <bool>(() => false) });



            RuleDef SpawnPlayerRule = new RuleDef("FloodWarning.PlayerSize", "Guaranteed");

            SpawnPlayerRule.defaultChoiceIndex = 8;
            for (float o = 1; o <= 50; o++)
            {
                float         myNum  = o / 10;
                RuleChoiceDef myRule = SpawnPlayerRule.AddChoice("0", myNum, false);
                myRule.spritePath       = "Textures/MiscIcons/texRuleBonusStartingMoney";
                myRule.tooltipNameToken = "" + myNum + "x size for Players";
                myRule.tooltipBodyToken = "When a Player spawns in your world, they will be " + myNum + "x the size";
            }
            addRule.Invoke(null, new object[] { SpawnPlayerRule });
            RuleDef SpawnAllyRule = new RuleDef("FloodWarning.AllySize", "Guaranteed");

            SpawnAllyRule.defaultChoiceIndex = 6;
            for (float o = 1; o <= 50; o++)
            {
                float         myNum  = o / 10;
                RuleChoiceDef myRule = SpawnAllyRule.AddChoice("0", myNum, false);
                myRule.spritePath       = "Textures/MiscIcons/texRuleBonusStartingMoney";
                myRule.tooltipNameToken = "" + myNum + "x size for Allies";
                myRule.tooltipBodyToken = "When an Ally (Drone, Turret) spawns in your world, they will be " + myNum + "x the size";
            }
            addRule.Invoke(null, new object[] { SpawnAllyRule });
            RuleDef SpawnNeutralRule = new RuleDef("FloodWarning.NeutralSize", "Guaranteed");

            SpawnNeutralRule.defaultChoiceIndex = 10;
            for (float o = 1; o <= 50; o++)
            {
                float         myNum  = o / 10;
                RuleChoiceDef myRule = SpawnNeutralRule.AddChoice("0", myNum, false);
                myRule.spritePath       = "Textures/MiscIcons/texRuleBonusStartingMoney";
                myRule.tooltipNameToken = "" + myNum + "x size for Neutral Entities";
                myRule.tooltipBodyToken = "When a Neutral Entity (Newt) spawns in your world, they will be " + myNum + "x the size";
            }
            addRule.Invoke(null, new object[] { SpawnNeutralRule });

            RuleDef SpawnBossRule = new RuleDef("FloodWarning.BossSize", "Guaranteed");

            SpawnBossRule.defaultChoiceIndex = 11;
            for (float o = 1; o <= 50; o++)
            {
                float         myNum  = o / 10;
                RuleChoiceDef myRule = SpawnBossRule.AddChoice("0", myNum, false);
                myRule.spritePath       = "Textures/MiscIcons/texRuleBonusStartingMoney";
                myRule.tooltipNameToken = "" + myNum + "x size for Boss";
                myRule.tooltipBodyToken = "When a Boss spawns in your world, they will be " + myNum + "x the size";
            }
            addRule.Invoke(null, new object[] { SpawnBossRule });

            RuleDef SpawnChampionRule = new RuleDef("FloodWarning.ChampionSize", "Guaranteed");

            SpawnChampionRule.defaultChoiceIndex = 15;
            for (float o = 1; o <= 50; o++)
            {
                float         myNum  = o / 10;
                RuleChoiceDef myRule = SpawnChampionRule.AddChoice("0", myNum, false);
                myRule.spritePath       = "Textures/MiscIcons/texRuleBonusStartingMoney";
                myRule.tooltipNameToken = "" + myNum + "x size for Teleporter Bosses (Champions)";
                myRule.tooltipBodyToken = "When a Teleporter Boss (Champion) spawns in your world, they will be " + myNum + "x the size";
            }
            addRule.Invoke(null, new object[] { SpawnChampionRule });

            RuleDef SpawnEliteRule = new RuleDef("FloodWarning.EliteSize", "Guaranteed");

            SpawnEliteRule.defaultChoiceIndex = 13;
            for (float o = 1; o <= 50; o++)
            {
                float         myNum  = o / 10;
                RuleChoiceDef myRule = SpawnEliteRule.AddChoice("0", myNum, false);
                myRule.spritePath       = "Textures/MiscIcons/texRuleBonusStartingMoney";
                myRule.tooltipNameToken = "" + myNum + "x size for Elites";
                myRule.tooltipBodyToken = "When an Elite spawns in your world, they will be " + myNum + "x the size";
            }
            addRule.Invoke(null, new object[] { SpawnEliteRule });

            RuleDef SpawnMonsterRule = new RuleDef("FloodWarning.MonsterSize", "Guaranteed");

            SpawnMonsterRule.defaultChoiceIndex = 9;
            for (float o = 1; o <= 50; o++)
            {
                float         myNum  = o / 10;
                RuleChoiceDef myRule = SpawnMonsterRule.AddChoice("0", myNum, false);
                myRule.spritePath       = "Textures/MiscIcons/texRuleBonusStartingMoney";
                myRule.tooltipNameToken = "" + myNum + "x size for Non-Elite, Non-Boss Monsters";
                myRule.tooltipBodyToken = "Whenever ANY enemy spawns in your world, they will be " + myNum + "x the size";
            }
            addRule.Invoke(null, new object[] { SpawnMonsterRule });

            List <RuleDef>       allRuleDefs    = (List <RuleDef>)Harmony.AccessTools.Field(Harmony.AccessTools.TypeByName("RuleCatalog"), "allRuleDefs").GetValue(null);
            List <RuleChoiceDef> allChoicesDefs = (List <RuleChoiceDef>)Harmony.AccessTools.Field(Harmony.AccessTools.TypeByName("RuleCatalog"), "allChoicesDefs").GetValue(null);

            for (int k = 0; k < allRuleDefs.Count; k++)
            {
                RuleDef ruleDef = allRuleDefs[k];
                ruleDef.globalIndex = k;
                for (int j = 0; j < ruleDef.choices.Count; j++)
                {
                    RuleChoiceDef ruleChoiceDef6 = ruleDef.choices[j];
                    ruleChoiceDef6.localIndex  = j;
                    ruleChoiceDef6.globalIndex = allChoicesDefs.Count;
                    allChoicesDefs.Add(ruleChoiceDef6);
                }
            }

            On.RoR2.UI.RuleChoiceController.OnClick += (orig, self) =>
            {
                RuleChoiceDef myChoiceDef = (RuleChoiceDef)Harmony.AccessTools.Field(Harmony.AccessTools.TypeByName("RoR2.UI.RuleChoiceController"), "currentChoiceDef").GetValue(self);
                myChoiceDef.ruleDef.defaultChoiceIndex = myChoiceDef.localIndex;
                orig(self);
            };

            Harmony.AccessTools.Field(Harmony.AccessTools.TypeByName("RuleCatalog"), "allRuleDefs").SetValue(null, allRuleDefs);
            Harmony.AccessTools.Field(Harmony.AccessTools.TypeByName("RuleCatalog"), "allChoicesDefs").SetValue(null, allChoicesDefs);
            RuleCatalog.availability.MakeAvailable();

            On.RoR2.CharacterMaster.OnBodyStart += (orig, self, body) =>
            {
                orig(self, body);
                var   tf          = body.modelLocator.modelTransform.localScale;
                float scaleFactor = 1f;
                if (body.isChampion)
                {
                    scaleFactor *= (float)Run.instance.ruleBook.GetRuleChoice(RuleCatalog.FindRuleDef("FloodWarning.ChampionSize")).extraData;
                }

                if (body.isBoss)
                {
                    scaleFactor *= (float)Run.instance.ruleBook.GetRuleChoice(RuleCatalog.FindRuleDef("FloodWarning.BossSize")).extraData;
                }

                if (body.isElite)
                {
                    scaleFactor *= (float)Run.instance.ruleBook.GetRuleChoice(RuleCatalog.FindRuleDef("FloodWarning.EliteSize")).extraData;
                }
                if (body.GetComponent <TeamComponent>().teamIndex == TeamIndex.Monster)
                {
                    scaleFactor *= (float)Run.instance.ruleBook.GetRuleChoice(RuleCatalog.FindRuleDef("FloodWarning.MonsterSize")).extraData;
                }
                if (body.GetComponent <TeamComponent>().teamIndex == TeamIndex.Player && !body.isPlayerControlled)
                {
                    scaleFactor *= (float)Run.instance.ruleBook.GetRuleChoice(RuleCatalog.FindRuleDef("FloodWarning.AllySize")).extraData;
                }
                if (body.GetComponent <TeamComponent>().teamIndex == TeamIndex.Neutral)
                {
                    scaleFactor *= (float)Run.instance.ruleBook.GetRuleChoice(RuleCatalog.FindRuleDef("FloodWarning.NeutralSize")).extraData;
                }

                if (body.isPlayerControlled)
                {
                    scaleFactor *= (float)Run.instance.ruleBook.GetRuleChoice(RuleCatalog.FindRuleDef("FloodWarning.PlayerSize")).extraData;
                }
                body.modelLocator.modelTransform.localScale = new Vector3(tf.x * scaleFactor, tf.y * scaleFactor, tf.z * scaleFactor);
            };
        }
예제 #29
0
        public void Awake()//Code that runs when the game starts
        {
            string[] interactables     = { "iscBrokenDrone1", "iscBrokenDrone2", "iscBrokenMegaDrone", "iscBrokenMissileDrone", "iscBrokenTurret1", "iscBarrel1", "iscEquipmentBarrel", "iscLockbox", "iscChest1", "iscChest1Stealthed", "iscChest2", "iscGoldChest", "iscTripleShop", "iscTripleShopLarge", "iscDuplicator", "iscDuplicatorLarge", "iscDuplicatorMilitary", "iscShrineCombat", "iscShrineBoss", "iscShrineBlood", "iscShrineChance", "iscShrineHealing", "iscShrineRestack", "iscShrineGoldshoresAccess", "iscRadarTower", "iscTeleporter", "iscShopPortal", "iscMSPortal", "iscGoldshoresPortal", "iscGoldshoresBeacon" };
            string[] interactableNames = { "Gunner Drone", "Healing Drone", "Prototype Drone", "Missile Drone", "Broken Turret", "Barrel", "Equipment Barrel", "Rusty Lockbox", "Chest", "Stealthed Chest", "Large Chest", "Legendary Chest", "Triple Shop", "Triple Shop (Red and Green)", "3D Printer", "Large Printer (Green)", "Mili-tech Printer (Red)", "Shrine of Combat", "Shrine of the Mountain", "Shrine of Blood", "Shrine of Chance", "Shrine of the Forest", "Shrine of Order", "Gold Shrine", "Radar", "Teleporter", "Blue Portal", "Celestial Portal", "Gold Portal", "Halycon Beacon" };

            var addRule     = typeof(RuleCatalog).GetMethod("AddRule", BindingFlags.Static | BindingFlags.NonPublic, null, new Type[] { typeof(RuleDef) }, null);
            var addCategory = typeof(RuleCatalog).GetMethod("AddCategory", BindingFlags.Static | BindingFlags.NonPublic, null, new Type[] { typeof(string), typeof(Color), typeof(string), typeof(Func <bool>) }, null);


            addCategory.Invoke(null, new object[] { "Interactables", new Color(219 / 255, 182 / 255, 19 / 255, byte.MaxValue), "", new Func <bool>(() => false) });
            RuleDef iscruleDef3 = new RuleDef("FloodWarning.InteractableScale", "Total interactable scale");

            for (int i = 0; i < 12; i++)
            {
                float myNum = (float)(Math.Pow(2f, i)) / 4f;
                if (i == 0)
                {
                    RuleChoiceDef tempRule = iscruleDef3.AddChoice("0", 0f, false);
                    tempRule.spritePath       = "Textures/MiscIcons/texRuleBonusStartingMoney";
                    tempRule.tooltipNameToken = "" + 0f + "x Interactable spawns";
                    tempRule.tooltipBodyToken = "" + 0f + "x The amount of interactables (Shrines, Chests, Buyable drones and turrets) will appear in the world";
                }

                RuleChoiceDef myRule = iscruleDef3.AddChoice("0", myNum, false);
                if (myNum == 1)
                {
                    iscruleDef3.MakeNewestChoiceDefault();
                }
                myRule.spritePath       = "Textures/MiscIcons/texRuleBonusStartingMoney";
                myRule.tooltipNameToken = "" + myNum + "x Interactable spawns";
                myRule.tooltipBodyToken = "" + myNum + "x The amount of interactables (Shrines, Chests, Buyable drones and turrets) will appear in the world";
            }
            addRule.Invoke(null, new object[] { iscruleDef3 });

            addCategory.Invoke(null, new object[] { "Weighted Selections", new Color(94 / 255, 82 / 255, 30 / 255, byte.MaxValue), "", new Func <bool>(() => false) });
            for (int i = 0; i < interactables.Length; i++)
            {
                RuleDef ChanceRule = new RuleDef("FloodWarning." + interactables[i] + "Chance", "Chance");

                for (int o = 0; o < 8; o++)
                {
                    float myNum = (float)(Math.Pow(2f, o)) / 4f;
                    if (o == 0)
                    {
                        RuleChoiceDef tempRule = ChanceRule.AddChoice("0", 0f, false);
                        tempRule.spritePath       = "Textures/MiscIcons/texRuleBonusStartingMoney";
                        tempRule.tooltipNameToken = "0x Chance of " + interactableNames[i];
                        tempRule.tooltipBodyToken = "0x Chance that a given spawned interactable will be of type '" + interactableNames[i] + "'";
                        switch (interactables[i])
                        {
                        case "iscBrokenDrone1":
                            tempRule.spritePath = "Textures/MiscIcons/texRuleBonusStartingMoney";
                            break;

                        case "iscBrokenDrone2":
                            tempRule.spritePath = "Textures/MiscIcons/texRuleBonusStartingMoney";
                            break;

                        case "iscBrokenMegaDrone":
                            tempRule.spritePath = "Textures/MiscIcons/texRuleBonusStartingMoney";
                            break;

                        case "iscBrokenMissileDrone":
                            tempRule.spritePath = "Textures/MiscIcons/texRuleBonusStartingMoney";
                            break;

                        case "iscBrokenTurret1":
                            tempRule.spritePath = "Textures/MiscIcons/texRuleBonusStartingMoney";
                            break;

                        case "iscBarrel1":
                            tempRule.spritePath = "Textures/MiscIcons/texRuleBonusStartingMoney";
                            break;

                        case "iscEquipmentBarrel":
                            tempRule.spritePath = "Textures/MiscIcons/texRuleBonusStartingMoney";
                            break;

                        case "iscLockbox":
                            tempRule.spritePath = "Textures/MiscIcons/texRuleBonusStartingMoney";
                            break;

                        case "iscChest1":
                            tempRule.spritePath = "Textures/MiscIcons/texRuleBonusStartingMoney";
                            break;

                        case "iscChest1Stealthed":
                            tempRule.spritePath = "Textures/MiscIcons/texRuleBonusStartingMoney";
                            break;

                        case "iscChest2":
                            tempRule.spritePath = "Textures/MiscIcons/texRuleBonusStartingMoney";
                            break;

                        case "iscGoldChest":
                            tempRule.spritePath = "Textures/MiscIcons/texRuleBonusStartingMoney";
                            break;

                        case "iscTripleShop":
                            tempRule.spritePath = "Textures/MiscIcons/texRuleBonusStartingMoney";
                            break;

                        case "iscTripleShopLarge":
                            tempRule.spritePath = "Textures/MiscIcons/texRuleBonusStartingMoney";
                            break;

                        case "iscDuplicator":
                            tempRule.spritePath = "Textures/MiscIcons/texRuleBonusStartingMoney";
                            break;

                        case "iscDuplicatorLarge":
                            tempRule.spritePath = "Textures/MiscIcons/texRuleBonusStartingMoney";
                            break;

                        case "iscDuplicatorMilitary":
                            tempRule.spritePath = "Textures/MiscIcons/texRuleBonusStartingMoney";
                            break;

                        case "iscShrineCombat":
                            tempRule.spritePath = "Textures/shrinesymbols/texshrinecombatsymbol";
                            break;

                        case "iscShrineBoss":
                            tempRule.spritePath = "Textures/shrinesymbols/texshrinebosssymbole";
                            break;

                        case "iscShrineBlood":
                            tempRule.spritePath = "Textures/shrinesymbols/texshrinebloodsymbol";
                            break;

                        case "iscShrineChance":
                            tempRule.spritePath = "Textures/shrinesymbols/texshrinechancesymbol";
                            break;

                        case "iscShrineHealing":
                            tempRule.spritePath = "Textures/shrinesymbols/texshrinehealingsymbol";
                            break;

                        case "iscShrineRestack":
                            tempRule.spritePath = "Textures/shrinesymbols/texshrinerestacksymbol";
                            break;

                        case "iscShrineGoldshoresAccess":
                            tempRule.spritePath = "Textures/MiscIcons/texRuleBonusStartingMoney";
                            break;

                        case "iscRadarTower":
                            tempRule.spritePath = "Textures/MiscIcons/texRuleBonusStartingMoney";
                            break;

                        case "iscTeleporter":
                            tempRule.spritePath = "Textures/MiscIcons/texRuleBonusStartingMoney";
                            break;

                        case "iscShopPortal":
                            tempRule.spritePath = "Textures/MiscIcons/texRuleBonusStartingMoney";
                            break;

                        case "iscMSPortal":
                            tempRule.spritePath = "Textures/MiscIcons/texRuleBonusStartingMoney";
                            break;

                        case "iscGoldshoresPortal":
                            tempRule.spritePath = "Textures/MiscIcons/texRuleBonusStartingMoney";
                            break;

                        case "iscGoldshoresBeacon":
                            tempRule.spritePath = "Textures/MiscIcons/texRuleBonusStartingMoney";
                            break;
                        }
                    }
                    RuleChoiceDef myRule = ChanceRule.AddChoice("0", myNum, false);
                    if (myNum == 1)
                    {
                        ChanceRule.MakeNewestChoiceDefault();
                    }

                    myRule.spritePath       = "Textures/MiscIcons/texRuleBonusStartingMoney";
                    myRule.tooltipNameToken = "" + myNum + "x Chance of " + interactableNames[i];
                    myRule.tooltipBodyToken = "" + myNum + "x Chance that a given spawned interactable will be of type '" + interactableNames[i] + "'";
                    switch (interactables[i])
                    {
                    case "iscBrokenDrone1":
                        myRule.spritePath = "Textures/MiscIcons/texRuleBonusStartingMoney";
                        break;

                    case "iscBrokenDrone2":
                        myRule.spritePath = "Textures/MiscIcons/texRuleBonusStartingMoney";
                        break;

                    case "iscBrokenMegaDrone":
                        myRule.spritePath = "Textures/MiscIcons/texRuleBonusStartingMoney";
                        break;

                    case "iscBrokenMissileDrone":
                        myRule.spritePath = "Textures/MiscIcons/texRuleBonusStartingMoney";
                        break;

                    case "iscBrokenTurret1":
                        myRule.spritePath = "Textures/MiscIcons/texRuleBonusStartingMoney";
                        break;

                    case "iscBarrel1":
                        myRule.spritePath = "Textures/MiscIcons/texRuleBonusStartingMoney";
                        break;

                    case "iscEquipmentBarrel":
                        myRule.spritePath = "Textures/MiscIcons/texRuleBonusStartingMoney";
                        break;

                    case "iscLockbox":
                        myRule.spritePath = "Textures/MiscIcons/texRuleBonusStartingMoney";
                        break;

                    case "iscChest1":
                        myRule.spritePath = "Textures/MiscIcons/texRuleBonusStartingMoney";
                        break;

                    case "iscChest1Stealthed":
                        myRule.spritePath = "Textures/MiscIcons/texRuleBonusStartingMoney";
                        break;

                    case "iscChest2":
                        myRule.spritePath = "Textures/MiscIcons/texRuleBonusStartingMoney";
                        break;

                    case "iscGoldChest":
                        myRule.spritePath = "Textures/MiscIcons/texRuleBonusStartingMoney";
                        break;

                    case "iscTripleShop":
                        myRule.spritePath = "Textures/MiscIcons/texRuleBonusStartingMoney";
                        break;

                    case "iscTripleShopLarge":
                        myRule.spritePath = "Textures/MiscIcons/texRuleBonusStartingMoney";
                        break;

                    case "iscDuplicator":
                        myRule.spritePath = "Textures/MiscIcons/texRuleBonusStartingMoney";
                        break;

                    case "iscDuplicatorLarge":
                        myRule.spritePath = "Textures/MiscIcons/texRuleBonusStartingMoney";
                        break;

                    case "iscDuplicatorMilitary":
                        myRule.spritePath = "Textures/MiscIcons/texRuleBonusStartingMoney";
                        break;

                    case "iscShrineCombat":
                        myRule.spritePath = "Textures/shrinesymbols/texshrinecombatsymbol";
                        break;

                    case "iscShrineBoss":
                        myRule.spritePath = "Textures/shrinesymbols/texshrinebosssymbole";
                        break;

                    case "iscShrineBlood":
                        myRule.spritePath = "Textures/shrinesymbols/texshrinebloodsymbol";
                        break;

                    case "iscShrineChance":
                        myRule.spritePath = "Textures/shrinesymbols/texshrinechancesymbol";
                        break;

                    case "iscShrineHealing":
                        myRule.spritePath = "Textures/shrinesymbols/texshrinehealingsymbol";
                        break;

                    case "iscShrineRestack":
                        myRule.spritePath = "Textures/shrinesymbols/texshrinerestacksymbol";
                        break;

                    case "iscShrineGoldshoresAccess":
                        myRule.spritePath = "Textures/MiscIcons/texRuleBonusStartingMoney";
                        break;

                    case "iscRadarTower":
                        myRule.spritePath = "Textures/MiscIcons/texRuleBonusStartingMoney";
                        break;

                    case "iscTeleporter":
                        myRule.spritePath = "Textures/MiscIcons/texRuleBonusStartingMoney";
                        break;

                    case "iscShopPortal":
                        myRule.spritePath = "Textures/MiscIcons/texRuleBonusStartingMoney";
                        break;

                    case "iscMSPortal":
                        myRule.spritePath = "Textures/MiscIcons/texRuleBonusStartingMoney";
                        break;

                    case "iscGoldshoresPortal":
                        myRule.spritePath = "Textures/MiscIcons/texRuleBonusStartingMoney";
                        break;

                    case "iscGoldshoresBeacon":
                        myRule.spritePath = "Textures/MiscIcons/texRuleBonusStartingMoney";
                        break;
                    }
                }
                addRule.Invoke(null, new object[] { ChanceRule });
            }

            addCategory.Invoke(null, new object[] { "Guarantees", new Color(94 / 255, 82 / 255, 30 / 255, byte.MaxValue), "", new Func <bool>(() => false) });
            for (int i = 0; i < interactables.Length; i++)
            {
                RuleDef GuaranteeRule = new RuleDef("FloodWarning." + interactables[i] + "Guaranteed", "Guaranteed");

                for (int o = 0; o < 8; o++)
                {
                    float myNum = (float)Math.Pow(2f, o);
                    if (o == 0)
                    {
                        RuleChoiceDef tempRule = GuaranteeRule.AddChoice("0", 0f, false);
                        tempRule.spritePath       = "Textures/MiscIcons/texRuleBonusStartingMoney";
                        tempRule.tooltipNameToken = "0 Guaranteed " + interactableNames[i];
                        tempRule.tooltipBodyToken = "No Guaranteee that any " + interactableNames[i] + " will spawn";
                        switch (interactables[i])
                        {
                        case "iscBrokenDrone1":
                            tempRule.spritePath = "Textures/MiscIcons/texRuleBonusStartingMoney";
                            break;

                        case "iscBrokenDrone2":
                            tempRule.spritePath = "Textures/MiscIcons/texRuleBonusStartingMoney";
                            break;

                        case "iscBrokenMegaDrone":
                            tempRule.spritePath = "Textures/MiscIcons/texRuleBonusStartingMoney";
                            break;

                        case "iscBrokenMissileDrone":
                            tempRule.spritePath = "Textures/MiscIcons/texRuleBonusStartingMoney";
                            break;

                        case "iscBrokenTurret1":
                            tempRule.spritePath = "Textures/MiscIcons/texRuleBonusStartingMoney";
                            break;

                        case "iscBarrel1":
                            tempRule.spritePath = "Textures/MiscIcons/texRuleBonusStartingMoney";
                            break;

                        case "iscEquipmentBarrel":
                            tempRule.spritePath = "Textures/MiscIcons/texRuleBonusStartingMoney";
                            break;

                        case "iscLockbox":
                            tempRule.spritePath = "Textures/MiscIcons/texRuleBonusStartingMoney";
                            break;

                        case "iscChest1":
                            tempRule.spritePath = "Textures/MiscIcons/texRuleBonusStartingMoney";
                            break;

                        case "iscChest1Stealthed":
                            tempRule.spritePath = "Textures/MiscIcons/texRuleBonusStartingMoney";
                            break;

                        case "iscChest2":
                            tempRule.spritePath = "Textures/MiscIcons/texRuleBonusStartingMoney";
                            break;

                        case "iscGoldChest":
                            tempRule.spritePath = "Textures/MiscIcons/texRuleBonusStartingMoney";
                            break;

                        case "iscTripleShop":
                            tempRule.spritePath = "Textures/MiscIcons/texRuleBonusStartingMoney";
                            break;

                        case "iscTripleShopLarge":
                            tempRule.spritePath = "Textures/MiscIcons/texRuleBonusStartingMoney";
                            break;

                        case "iscDuplicator":
                            tempRule.spritePath = "Textures/MiscIcons/texRuleBonusStartingMoney";
                            break;

                        case "iscDuplicatorLarge":
                            tempRule.spritePath = "Textures/MiscIcons/texRuleBonusStartingMoney";
                            break;

                        case "iscDuplicatorMilitary":
                            tempRule.spritePath = "Textures/MiscIcons/texRuleBonusStartingMoney";
                            break;

                        case "iscShrineCombat":
                            tempRule.spritePath = "Textures/shrinesymbols/texshrinecombatsymbol";
                            break;

                        case "iscShrineBoss":
                            tempRule.spritePath = "Textures/shrinesymbols/texshrinebosssymbole";
                            break;

                        case "iscShrineBlood":
                            tempRule.spritePath = "Textures/shrinesymbols/texshrinebloodsymbol";
                            break;

                        case "iscShrineChance":
                            tempRule.spritePath = "Textures/shrinesymbols/texshrinechancesymbol";
                            break;

                        case "iscShrineHealing":
                            tempRule.spritePath = "Textures/shrinesymbols/texshrinehealingsymbol";
                            break;

                        case "iscShrineRestack":
                            tempRule.spritePath = "Textures/shrinesymbols/texshrinerestacksymbol";
                            break;

                        case "iscShrineGoldshoresAccess":
                            tempRule.spritePath = "Textures/MiscIcons/texRuleBonusStartingMoney";
                            break;

                        case "iscRadarTower":
                            tempRule.spritePath = "Textures/MiscIcons/texRuleBonusStartingMoney";
                            break;

                        case "iscTeleporter":
                            tempRule.spritePath = "Textures/MiscIcons/texRuleBonusStartingMoney";
                            break;

                        case "iscShopPortal":
                            tempRule.spritePath = "Textures/MiscIcons/texRuleBonusStartingMoney";
                            break;

                        case "iscMSPortal":
                            tempRule.spritePath = "Textures/MiscIcons/texRuleBonusStartingMoney";
                            break;

                        case "iscGoldshoresPortal":
                            tempRule.spritePath = "Textures/MiscIcons/texRuleBonusStartingMoney";
                            break;

                        case "iscGoldshoresBeacon":
                            tempRule.spritePath = "Textures/MiscIcons/texRuleBonusStartingMoney";
                            break;
                        }
                    }
                    RuleChoiceDef myRule = GuaranteeRule.AddChoice("0", myNum, false);
                    if (myNum == 0)
                    {
                        GuaranteeRule.MakeNewestChoiceDefault();
                    }
                    myRule.spritePath       = "Textures/MiscIcons/texRuleBonusStartingMoney";
                    myRule.tooltipNameToken = "" + myNum + " Guaranteed " + interactableNames[i];
                    myRule.tooltipBodyToken = "" + myNum + " " + interactableNames[i] + "(s) Will always spawn in your world.";
                    switch (interactables[i])
                    {
                    case "iscBrokenDrone1":
                        myRule.spritePath = "Textures/MiscIcons/texRuleBonusStartingMoney";
                        break;

                    case "iscBrokenDrone2":
                        myRule.spritePath = "Textures/MiscIcons/texRuleBonusStartingMoney";
                        break;

                    case "iscBrokenMegaDrone":
                        myRule.spritePath = "Textures/MiscIcons/texRuleBonusStartingMoney";
                        break;

                    case "iscBrokenMissileDrone":
                        myRule.spritePath = "Textures/MiscIcons/texRuleBonusStartingMoney";
                        break;

                    case "iscBrokenTurret1":
                        myRule.spritePath = "Textures/MiscIcons/texRuleBonusStartingMoney";
                        break;

                    case "iscBarrel1":
                        myRule.spritePath = "Textures/MiscIcons/texRuleBonusStartingMoney";
                        break;

                    case "iscEquipmentBarrel":
                        myRule.spritePath = "Textures/MiscIcons/texRuleBonusStartingMoney";
                        break;

                    case "iscLockbox":
                        myRule.spritePath = "Textures/MiscIcons/texRuleBonusStartingMoney";
                        break;

                    case "iscChest1":
                        myRule.spritePath = "Textures/MiscIcons/texRuleBonusStartingMoney";
                        break;

                    case "iscChest1Stealthed":
                        myRule.spritePath = "Textures/MiscIcons/texRuleBonusStartingMoney";
                        break;

                    case "iscChest2":
                        myRule.spritePath = "Textures/MiscIcons/texRuleBonusStartingMoney";
                        break;

                    case "iscGoldChest":
                        myRule.spritePath = "Textures/MiscIcons/texRuleBonusStartingMoney";
                        break;

                    case "iscTripleShop":
                        myRule.spritePath = "Textures/MiscIcons/texRuleBonusStartingMoney";
                        break;

                    case "iscTripleShopLarge":
                        myRule.spritePath = "Textures/MiscIcons/texRuleBonusStartingMoney";
                        break;

                    case "iscDuplicator":
                        myRule.spritePath = "Textures/MiscIcons/texRuleBonusStartingMoney";
                        break;

                    case "iscDuplicatorLarge":
                        myRule.spritePath = "Textures/MiscIcons/texRuleBonusStartingMoney";
                        break;

                    case "iscDuplicatorMilitary":
                        myRule.spritePath = "Textures/MiscIcons/texRuleBonusStartingMoney";
                        break;

                    case "iscShrineCombat":
                        myRule.spritePath = "Textures/shrinesymbols/texshrinecombatsymbol";
                        break;

                    case "iscShrineBoss":
                        myRule.spritePath = "Textures/shrinesymbols/texshrinebosssymbole";
                        break;

                    case "iscShrineBlood":
                        myRule.spritePath = "Textures/shrinesymbols/texshrinebloodsymbol";
                        break;

                    case "iscShrineChance":
                        myRule.spritePath = "Textures/shrinesymbols/texshrinechancesymbol";
                        break;

                    case "iscShrineHealing":
                        myRule.spritePath = "Textures/shrinesymbols/texshrinehealingsymbol";
                        break;

                    case "iscShrineRestack":
                        myRule.spritePath = "Textures/shrinesymbols/texshrinerestacksymbol";
                        break;

                    case "iscShrineGoldshoresAccess":
                        myRule.spritePath = "Textures/MiscIcons/texRuleBonusStartingMoney";
                        break;

                    case "iscRadarTower":
                        myRule.spritePath = "Textures/MiscIcons/texRuleBonusStartingMoney";
                        break;

                    case "iscTeleporter":
                        myRule.spritePath = "Textures/MiscIcons/texRuleBonusStartingMoney";
                        break;

                    case "iscShopPortal":
                        myRule.spritePath = "Textures/MiscIcons/texRuleBonusStartingMoney";
                        break;

                    case "iscMSPortal":
                        myRule.spritePath = "Textures/MiscIcons/texRuleBonusStartingMoney";
                        break;

                    case "iscGoldshoresPortal":
                        myRule.spritePath = "Textures/MiscIcons/texRuleBonusStartingMoney";
                        break;

                    case "iscGoldshoresBeacon":
                        myRule.spritePath = "Textures/MiscIcons/texRuleBonusStartingMoney";
                        break;
                    }
                }
                addRule.Invoke(null, new object[] { GuaranteeRule });
            }


            bool gotCategory = false;
            DirectorCardCategorySelection myCategorySelection = new DirectorCardCategorySelection();

            Debug.Log("IGNORE THE ABOVE WARNING, THIS IS INTENDED");


            On.RoR2.ClassicStageInfo.GenerateDirectorCardWeightedSelection += (orig, self, categorySelection) =>
            {
                if (!gotCategory)
                {
                    myCategorySelection = categorySelection;
                    gotCategory         = true;
                }

                foreach (DirectorCardCategorySelection.Category category in myCategorySelection.categories)
                {
                    Debug.Log(category.name);

                    float num = myCategorySelection.SumAllWeightsInCategory(category);
                    foreach (DirectorCard directorCard in category.cards)
                    {
                        for (int i = 0; i < interactables.Length; i++)
                        {
                            if (directorCard.spawnCard.name.ToString() == interactables[i])
                            {
                                Debug.Log("Editing weight of " + interactables[i]);
                                directorCard.selectionWeight *= (int)((float)Run.instance.ruleBook.GetRuleChoice(RuleCatalog.FindRuleDef("FloodWarning." + interactables[i] + "Chance")).extraData);
                            }
                        }
                    }
                }

                return(orig(self, categorySelection));
            };

            On.RoR2.SceneDirector.PlaceTeleporter += (orig, self) =>
            {
                int currentCredits = (int)Harmony.AccessTools.Field(Harmony.AccessTools.TypeByName("RoR2.SceneDirector"), "interactableCredit").GetValue(self);
                Harmony.AccessTools.Field(Harmony.AccessTools.TypeByName("RoR2.SceneDirector"), "interactableCredit").SetValue(self, (int)(currentCredits * (float)Run.instance.ruleBook.GetRuleChoice(RuleCatalog.FindRuleDef("FloodWarning.InteractableScale")).extraData));

                orig(self);

                Xoroshiro128Plus rng        = new Xoroshiro128Plus((ulong)Run.instance.stageRng.nextUint);;
                DirectorCore     myDirector = (DirectorCore)Harmony.AccessTools.Field(Harmony.AccessTools.TypeByName("RoR2.SceneDirector"), "directorCore").GetValue(self);
                for (int i = 0; i < interactables.Length; i++)
                {
                    for (int o = 0; o < (float)Run.instance.ruleBook.GetRuleChoice(RuleCatalog.FindRuleDef("FloodWarning." + interactables[i] + "Guaranteed")).extraData; o++)
                    {
                        GameObject myGameObject = myDirector.TrySpawnObject(Resources.Load <SpawnCard>((string)("SpawnCards/InteractableSpawnCard/" + interactables[i])), new DirectorPlacementRule
                        {
                            placementMode = DirectorPlacementRule.PlacementMode.Random
                        }, rng);

                        if (myGameObject.GetComponent <PurchaseInteraction>())
                        {
                            myGameObject.GetComponent <PurchaseInteraction>().cost = Run.instance.GetDifficultyScaledCost(myGameObject.GetComponent <PurchaseInteraction>().cost);
                        }
                    }
                }
            };
        }
예제 #30
0
 public LobbyRule()
 {
     _ruleDef = new RuleDef(GlobalNameSequence(), "R2API_RULE");
 }