// Token: 0x060024EE RID: 9454 RVA: 0x000A0FB8 File Offset: 0x0009F1B8
 private void SetData(RuleChoiceMask choiceAvailability, RuleBook ruleBook)
 {
     if (choiceAvailability.Equals(this.cachedRuleChoiceMask) && ruleBook.Equals(this.cachedRuleBook))
     {
         return;
     }
     this.cachedRuleChoiceMask.Copy(choiceAvailability);
     this.cachedRuleBook.Copy(ruleBook);
     for (int i = 0; i < RuleCatalog.categoryCount; i++)
     {
         this.categoryControllers[i].SetData(RuleCatalog.GetCategoryDef(i), this.cachedRuleChoiceMask, this.cachedRuleBook);
         this.categoryControllers[i].gameObject.SetActive(!this.categoryControllers[i].shouldHide);
     }
 }
        private void PreGameRuleVoteController_SetVote(On.RoR2.PreGameRuleVoteController.orig_SetVote orig, PreGameRuleVoteController self, int ruleIndex, int choiceValue)
        {
            var ruledef = RuleCatalog.GetRuleDef(ruleIndex);

            if (!ruledef.category.isHidden)
            {
                if (choiceValue >= 0)
                {
                    string catagorie = ruledef.category.displayToken;
                    string name      = ruledef.globalName;
                    configfile.Wrap(catagorie, name, null, choiceValue).Value = choiceValue;
                }
            }

            orig(self, ruleIndex, choiceValue);
        }
Beispiel #3
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);
        }
Beispiel #4
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);
            };
        }
Beispiel #5
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);
                        }
                    }
                }
            };
        }
Beispiel #6
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);
        }
Beispiel #7
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;
            //                        }
            //                    }
            //                }
            //            }
            //        }

            //    };
        }
Beispiel #8
0
        public static void giveItems(Inventory summonInventory, Inventory playerInventory, int GiveRule)
        {
            if (GiveRule == 1)
            {
                float tier1Count   = 0;
                float tier2Count   = 0;
                float tier3Count   = 0;
                float tier4Count   = 0;
                bool  hasEquipment = false;
                foreach (ItemIndex index in ItemCatalog.tier1ItemList)
                {
                    tier1Count += playerInventory.GetItemCount(index);
                }
                foreach (ItemIndex index in ItemCatalog.tier2ItemList)
                {
                    tier2Count += playerInventory.GetItemCount(index);
                }
                foreach (ItemIndex index in ItemCatalog.tier3ItemList)
                {
                    tier3Count += playerInventory.GetItemCount(index);
                }
                foreach (ItemIndex index in ItemCatalog.lunarItemList)
                {
                    tier4Count += playerInventory.GetItemCount(index);
                }

                tier1Count *= (float)(Run.instance.ruleBook.GetRuleChoice(RuleCatalog.FindRuleDef("FloodWarning.allyItemRatio")).extraData);
                tier2Count *= (float)(Run.instance.ruleBook.GetRuleChoice(RuleCatalog.FindRuleDef("FloodWarning.allyItemRatio")).extraData);
                tier3Count *= (float)(Run.instance.ruleBook.GetRuleChoice(RuleCatalog.FindRuleDef("FloodWarning.allyItemRatio")).extraData);
                tier4Count *= (float)(Run.instance.ruleBook.GetRuleChoice(RuleCatalog.FindRuleDef("FloodWarning.allyItemRatio")).extraData);

                hasEquipment = (new System.Random().Next(0, 100) < 100 * (float)(Run.instance.ruleBook.GetRuleChoice(RuleCatalog.FindRuleDef("FloodWarning.allyItemRatio")).extraData) && (playerInventory.GetEquipmentIndex() != EquipmentIndex.None));

                for (int i = 0; i < tier1Count; i++)
                {
                    summonInventory.GiveItem(ItemCatalog.tier1ItemList[Run.instance.runRNG.RangeInt(0, ItemCatalog.tier1ItemList.Count)], 1);
                }
                for (int i = 0; i < tier2Count; i++)
                {
                    summonInventory.GiveItem(ItemCatalog.tier2ItemList[Run.instance.runRNG.RangeInt(0, ItemCatalog.tier2ItemList.Count)], 1);
                }
                for (int i = 0; i < tier3Count; i++)
                {
                    summonInventory.GiveItem(ItemCatalog.tier3ItemList[Run.instance.runRNG.RangeInt(0, ItemCatalog.tier3ItemList.Count)], 1);
                }
                for (int i = 0; i < tier4Count; i++)
                {
                    summonInventory.GiveItem(ItemCatalog.lunarItemList[Run.instance.runRNG.RangeInt(0, ItemCatalog.lunarItemList.Count)], 1);
                }
                if (hasEquipment)
                {
                    summonInventory.SetEquipmentIndex(Run.instance.availableEquipmentDropList[Run.instance.runRNG.RangeInt(0, Run.instance.availableEquipmentDropList.Count)].equipmentIndex);
                    summonInventory.GiveItem(ItemIndex.AutoCastEquipment, 1);
                }
            }
            if (GiveRule == 2)
            {
                summonInventory.CopyItemsFrom(playerInventory);
            }
            if (GiveRule == 3)
            {
                if (playerInventory.GetEquipmentIndex() != EquipmentIndex.DroneBackup)
                {
                    summonInventory.CopyEquipmentFrom(playerInventory);
                    summonInventory.GiveItem(ItemIndex.AutoCastEquipment, 1);
                }
            }
            summonInventory.ResetItem(ItemIndex.TreasureCache);
            summonInventory.ResetItem(ItemIndex.Feather);
            summonInventory.ResetItem(ItemIndex.Firework);
            summonInventory.ResetItem(ItemIndex.Talisman);
            summonInventory.ResetItem(ItemIndex.SprintArmor);
            summonInventory.ResetItem(ItemIndex.JumpBoost);
            summonInventory.ResetItem(ItemIndex.GoldOnHit);
            summonInventory.ResetItem(ItemIndex.WardOnLevel);
            summonInventory.ResetItem(ItemIndex.BeetleGland);
            summonInventory.ResetItem(ItemIndex.CrippleWardOnLevel);
            summonInventory.ResetItem(ItemIndex.ExtraLife);
        }
Beispiel #9
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);
        }
Beispiel #10
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);
            };
        }
Beispiel #11
0
 //Returns the chosen value of the given rule, cast to type T, used as GetVar<T>
 public static T GetVar <T>(string modName, string ruleName)
 {
     return((T)Run.instance.ruleBook.GetRuleChoice(RuleCatalog.FindRuleDef(modName + "." + ruleName)).extraData);
 }