Пример #1
0
 // Token: 0x06001787 RID: 6023 RVA: 0x0006F864 File Offset: 0x0006DA64
 public override void OverrideRuleChoices(RuleChoiceMask mustInclude, RuleChoiceMask mustExclude)
 {
     base.OverrideRuleChoices(mustInclude, mustExclude);
     base.ForceChoice(mustInclude, mustExclude, "Difficulty.Normal");
     base.ForceChoice(mustInclude, mustExclude, "Misc.StartingMoney.50");
     base.ForceChoice(mustInclude, mustExclude, "Misc.StageOrder.Random");
     base.ForceChoice(mustInclude, mustExclude, "Misc.KeepMoneyBetweenStages.Off");
     for (ArtifactIndex artifactIndex = ArtifactIndex.Command; artifactIndex < ArtifactIndex.Count; artifactIndex++)
     {
         RuleDef       ruleDef       = RuleCatalog.FindRuleDef(artifactIndex.ToString());
         RuleChoiceDef ruleChoiceDef = (ruleDef != null) ? ruleDef.FindChoice("Off") : null;
         if (ruleChoiceDef != null)
         {
             base.ForceChoice(mustInclude, mustExclude, ruleChoiceDef);
         }
     }
     for (ItemIndex itemIndex = ItemIndex.Syringe; itemIndex < ItemIndex.Count; itemIndex++)
     {
         RuleDef       ruleDef2       = RuleCatalog.FindRuleDef("Items." + itemIndex.ToString());
         RuleChoiceDef ruleChoiceDef2 = (ruleDef2 != null) ? ruleDef2.FindChoice("On") : null;
         if (ruleChoiceDef2 != null)
         {
             base.ForceChoice(mustInclude, mustExclude, ruleChoiceDef2);
         }
     }
     for (EquipmentIndex equipmentIndex = EquipmentIndex.CommandMissile; equipmentIndex < EquipmentIndex.Count; equipmentIndex++)
     {
         RuleDef       ruleDef3       = RuleCatalog.FindRuleDef("Equipment." + equipmentIndex.ToString());
         RuleChoiceDef ruleChoiceDef3 = (ruleDef3 != null) ? ruleDef3.FindChoice("On") : null;
         if (ruleChoiceDef3 != null)
         {
             base.ForceChoice(mustInclude, mustExclude, ruleChoiceDef3);
         }
     }
 }
Пример #2
0
        public static RuleDef FromArtifact(ArtifactIndex artifactIndex)
        {
            var artifactDef = ArtifactCatalog.GetArtifactDef(artifactIndex);
            var ruleDef     = new RuleDef($"Artifacts.{artifactIndex}", artifactDef.nameToken);

            var ruleChoiceDef = ruleDef.AddChoice("On");

            ruleChoiceDef.spritePath       = artifactDef.smallIconSelectedPath;
            ruleChoiceDef.tooltipBodyToken = artifactDef.descriptionToken;
            ruleChoiceDef.unlockableName   = artifactDef.unlockableName;
            ruleChoiceDef.artifactIndex    = artifactIndex;
            ruleChoiceDef.tooltipNameColor = new Color32(74, 50, 149, byte.MaxValue);
            ruleChoiceDef.tooltipNameToken = $"{artifactDef.nameToken} On";

            var ruleChoiceDef2 = ruleDef.AddChoice("Off");

            ruleChoiceDef2.spritePath      = artifactDef.smallIconDeselectedPath;
            ruleChoiceDef2.materialPath    = "Materials/UI/matRuleChoiceOff";
            ruleChoiceDef.tooltipBodyToken = artifactDef.descriptionToken;
            ruleChoiceDef.tooltipNameColor = new Color32(74, 50, 149, byte.MaxValue);
            ruleChoiceDef.tooltipNameToken = $"{artifactDef.nameToken} Off";

            ruleDef.MakeNewestChoiceDefault();

            return(ruleDef);
        }
Пример #3
0
 // Token: 0x0600106B RID: 4203 RVA: 0x00048280 File Offset: 0x00046480
 private void SetVotesFromRuleBookForSinglePlayer()
 {
     for (int i = 0; i < this.votes.Length; i++)
     {
         RuleDef ruleDef = RuleCatalog.GetRuleDef(i);
         this.votes[i].choiceValue = this.GetDefaultChoice(ruleDef).localIndex;
     }
     base.SetDirtyBit(2U);
 }
Пример #4
0
        // Token: 0x06001034 RID: 4148 RVA: 0x00047468 File Offset: 0x00045668
        private void TestRuleValues()
        {
            RuleBook ruleBook = new RuleBook();

            ruleBook.Copy(this.networkRuleBookComponent.ruleBook);
            RuleDef       ruleDef   = RuleCatalog.GetRuleDef(UnityEngine.Random.Range(0, RuleCatalog.ruleCount));
            RuleChoiceDef choiceDef = ruleDef.choices[UnityEngine.Random.Range(0, ruleDef.choices.Count)];

            ruleBook.ApplyChoice(choiceDef);
            this.networkRuleBookComponent.SetRuleBook(ruleBook);
            base.Invoke("TestRuleValues", 0.5f);
        }
Пример #5
0
 public void EnforceValidRuleChoices()
 {
     if (!NetworkServer.active)
     {
         Debug.LogWarning("[Server] function 'System.Void RoR2.PreGameController::EnforceValidRuleChoices()' called on client");
         return;
     }
     this.ruleBookBuffer.Copy(this.readOnlyRuleBook);
     for (int i = 0; i < RuleCatalog.ruleCount; i++)
     {
         if (!this.resolvedRuleChoiceMask[this.ruleBookBuffer.GetRuleChoice(i)])
         {
             RuleDef       ruleDef   = RuleCatalog.GetRuleDef(i);
             RuleChoiceDef choiceDef = ruleDef.choices[ruleDef.defaultChoiceIndex];
             int           num       = 0;
             int           j         = 0;
             int           count     = ruleDef.choices.Count;
             while (j < count)
             {
                 if (this.resolvedRuleChoiceMask[ruleDef.choices[j]])
                 {
                     num++;
                 }
                 j++;
             }
             if (this.resolvedRuleChoiceMask[choiceDef] || num == 0)
             {
                 this.ruleBookBuffer.ApplyChoice(choiceDef);
             }
             else
             {
                 int k      = 0;
                 int count2 = ruleDef.choices.Count;
                 while (k < count2)
                 {
                     if (this.resolvedRuleChoiceMask[ruleDef.choices[k]])
                     {
                         this.ruleBookBuffer.ApplyChoice(ruleDef.choices[k]);
                         break;
                     }
                     k++;
                 }
             }
         }
     }
     this.networkRuleBookComponent.SetRuleBook(this.ruleBookBuffer);
     this.UpdatePersistentRulebook();
 }
        // Token: 0x060018D5 RID: 6357 RVA: 0x0006ADF4 File Offset: 0x00068FF4
        public static RuleDef FromDifficulty()
        {
            RuleDef ruleDef = new RuleDef("Difficulty", "RULE_NAME_DIFFICULTY");

            for (DifficultyIndex difficultyIndex = DifficultyIndex.Easy; difficultyIndex < DifficultyIndex.Count; difficultyIndex++)
            {
                DifficultyDef difficultyDef = DifficultyCatalog.GetDifficultyDef(difficultyIndex);
                RuleChoiceDef ruleChoiceDef = ruleDef.AddChoice(difficultyIndex.ToString(), null, false);
                ruleChoiceDef.spritePath       = difficultyDef.iconPath;
                ruleChoiceDef.tooltipNameToken = difficultyDef.nameToken;
                ruleChoiceDef.tooltipNameColor = difficultyDef.color;
                ruleChoiceDef.tooltipBodyToken = difficultyDef.descriptionToken;
                ruleChoiceDef.difficultyIndex  = difficultyIndex;
            }
            ruleDef.defaultChoiceIndex = 1;
            return(ruleDef);
        }
Пример #7
0
 // Token: 0x060018A3 RID: 6307 RVA: 0x0006A124 File Offset: 0x00068324
 public static void ToXml(XElement element, RuleBook src)
 {
     byte[] array = src.ruleValues;
     RuleBook.< > c__DisplayClass28_0 CS$ < > 8__locals1;
     CS$ < > 8__locals1.choiceNamesBuffer = new string[array.Length];
     CS$ < > 8__locals1.choiceNamesCount  = 0;
     for (int i = 0; i < array.Length; i++)
     {
         RuleDef ruleDef = RuleCatalog.GetRuleDef(i);
         byte    b       = array[i];
         if ((ulong)b < (ulong)((long)ruleDef.choices.Count))
         {
             RuleBook.< ToXml > g__AddChoice | 28_0 (ruleDef.choices[(int)b].globalName, ref CS$ < > 8__locals1);
         }
     }
     element.Value = string.Join(" ", CS$ < > 8__locals1.choiceNamesBuffer, 0, CS$ < > 8__locals1.choiceNamesCount);
 }
Пример #8
0
        // Token: 0x060015BF RID: 5567 RVA: 0x0005CB68 File Offset: 0x0005AD68
        public override void OverrideRuleChoices(RuleChoiceMask mustInclude, RuleChoiceMask mustExclude)
        {
            base.OverrideRuleChoices(mustInclude, mustExclude);
            base.ForceChoice(mustInclude, mustExclude, "Difficulty.Normal");
            base.ForceChoice(mustInclude, mustExclude, "Misc.StartingMoney.50");
            base.ForceChoice(mustInclude, mustExclude, "Misc.StageOrder.Random");
            base.ForceChoice(mustInclude, mustExclude, "Misc.KeepMoneyBetweenStages.Off");
            for (ArtifactIndex artifactIndex = ArtifactIndex.Command; artifactIndex < ArtifactIndex.Count; artifactIndex++)
            {
                RuleDef       ruleDef       = RuleCatalog.FindRuleDef(artifactIndex.ToString());
                RuleChoiceDef ruleChoiceDef = (ruleDef != null) ? ruleDef.FindChoice("Off") : null;
                if (ruleChoiceDef != null)
                {
                    base.ForceChoice(mustInclude, mustExclude, ruleChoiceDef);
                }
            }
            ItemIndex itemIndex = ItemIndex.Syringe;
            ItemIndex itemCount = (ItemIndex)ItemCatalog.itemCount;

            while (itemIndex < itemCount)
            {
                ItemDef       itemDef        = ItemCatalog.GetItemDef(itemIndex);
                RuleDef       ruleDef2       = RuleCatalog.FindRuleDef("Items." + itemDef.name);
                RuleChoiceDef ruleChoiceDef2 = (ruleDef2 != null) ? ruleDef2.FindChoice("On") : null;
                if (ruleChoiceDef2 != null)
                {
                    base.ForceChoice(mustInclude, mustExclude, ruleChoiceDef2);
                }
                itemIndex++;
            }
            EquipmentIndex equipmentIndex = EquipmentIndex.CommandMissile;
            EquipmentIndex equipmentCount = (EquipmentIndex)EquipmentCatalog.equipmentCount;

            while (equipmentIndex < equipmentCount)
            {
                EquipmentDef  equipmentDef   = EquipmentCatalog.GetEquipmentDef(equipmentIndex);
                RuleDef       ruleDef3       = RuleCatalog.FindRuleDef("Equipment." + equipmentDef.name);
                RuleChoiceDef ruleChoiceDef3 = (ruleDef3 != null) ? ruleDef3.FindChoice("On") : null;
                if (ruleChoiceDef3 != null)
                {
                    base.ForceChoice(mustInclude, mustExclude, ruleChoiceDef3);
                }
                equipmentIndex++;
            }
        }
 // Token: 0x060018C4 RID: 6340 RVA: 0x0006A588 File Offset: 0x00068788
 private static void AddRule(RuleDef ruleDef)
 {
     if (RuleCatalog.allCategoryDefs.Count > 0)
     {
         ruleDef.category = RuleCatalog.allCategoryDefs[RuleCatalog.allCategoryDefs.Count - 1];
         RuleCatalog.allCategoryDefs[RuleCatalog.allCategoryDefs.Count - 1].children.Add(ruleDef);
     }
     RuleCatalog.allRuleDefs.Add(ruleDef);
     if (RuleCatalog.highestLocalChoiceCount < ruleDef.choices.Count)
     {
         RuleCatalog.highestLocalChoiceCount = ruleDef.choices.Count;
     }
     RuleCatalog.ruleDefsByGlobalName[ruleDef.globalName] = ruleDef;
     foreach (RuleChoiceDef ruleChoiceDef in ruleDef.choices)
     {
         RuleCatalog.ruleChoiceDefsByGlobalName[ruleChoiceDef.globalName] = ruleChoiceDef;
     }
 }
        // Token: 0x060018D7 RID: 6359 RVA: 0x0006AF18 File Offset: 0x00069118
        public static RuleDef FromItem(ItemIndex itemIndex)
        {
            ItemDef       itemDef       = ItemCatalog.GetItemDef(itemIndex);
            RuleDef       ruleDef       = new RuleDef("Items." + itemIndex.ToString(), itemDef.nameToken);
            RuleChoiceDef ruleChoiceDef = ruleDef.AddChoice("On", null, false);

            ruleChoiceDef.spritePath       = itemDef.pickupIconPath;
            ruleChoiceDef.tooltipNameToken = itemDef.nameToken;
            ruleChoiceDef.unlockableName   = itemDef.unlockableName;
            ruleChoiceDef.itemIndex        = itemIndex;
            ruleDef.MakeNewestChoiceDefault();
            RuleChoiceDef ruleChoiceDef2 = ruleDef.AddChoice("Off", null, false);

            ruleChoiceDef2.spritePath       = itemDef.pickupIconPath;
            ruleChoiceDef2.materialPath     = "Materials/UI/matRuleChoiceOff";
            ruleChoiceDef2.tooltipNameToken = null;
            return(ruleDef);
        }
        // Token: 0x060018D6 RID: 6358 RVA: 0x0006AE78 File Offset: 0x00069078
        public static RuleDef FromArtifact(ArtifactIndex artifactIndex)
        {
            ArtifactDef   artifactDef   = ArtifactCatalog.GetArtifactDef(artifactIndex);
            RuleDef       ruleDef       = new RuleDef("Artifacts." + artifactIndex.ToString(), artifactDef.nameToken);
            RuleChoiceDef ruleChoiceDef = ruleDef.AddChoice("On", null, false);

            ruleChoiceDef.spritePath       = artifactDef.smallIconSelectedPath;
            ruleChoiceDef.tooltipBodyToken = artifactDef.descriptionToken;
            ruleChoiceDef.unlockableName   = artifactDef.unlockableName;
            ruleChoiceDef.artifactIndex    = artifactIndex;
            RuleChoiceDef ruleChoiceDef2 = ruleDef.AddChoice("Off", null, false);

            ruleChoiceDef2.spritePath       = artifactDef.smallIconDeselectedPath;
            ruleChoiceDef2.materialPath     = "Materials/UI/matRuleChoiceOff";
            ruleChoiceDef2.tooltipBodyToken = null;
            ruleDef.MakeNewestChoiceDefault();
            return(ruleDef);
        }
        // Token: 0x060018D8 RID: 6360 RVA: 0x0006AFB8 File Offset: 0x000691B8
        public static RuleDef FromEquipment(EquipmentIndex equipmentIndex)
        {
            EquipmentDef  equipmentDef  = EquipmentCatalog.GetEquipmentDef(equipmentIndex);
            RuleDef       ruleDef       = new RuleDef("Equipment." + equipmentIndex.ToString(), equipmentDef.nameToken);
            RuleChoiceDef ruleChoiceDef = ruleDef.AddChoice("On", null, false);

            ruleChoiceDef.spritePath              = equipmentDef.pickupIconPath;
            ruleChoiceDef.tooltipBodyToken        = equipmentDef.nameToken;
            ruleChoiceDef.unlockableName          = equipmentDef.unlockableName;
            ruleChoiceDef.equipmentIndex          = equipmentIndex;
            ruleChoiceDef.availableInMultiPlayer  = equipmentDef.appearsInMultiPlayer;
            ruleChoiceDef.availableInSinglePlayer = equipmentDef.appearsInSinglePlayer;
            ruleDef.MakeNewestChoiceDefault();
            RuleChoiceDef ruleChoiceDef2 = ruleDef.AddChoice("Off", null, false);

            ruleChoiceDef2.spritePath       = equipmentDef.pickupIconPath;
            ruleChoiceDef2.materialPath     = "Materials/UI/matRuleChoiceOff";
            ruleChoiceDef2.tooltipBodyToken = null;
            return(ruleDef);
        }
        private static void CCRulesDump(ConCommandArgs args)
        {
            List <string> list  = new List <string>();
            List <string> list2 = new List <string>();

            for (int i = 0; i < RuleCatalog.ruleCount; i++)
            {
                RuleDef ruleDef = RuleCatalog.GetRuleDef(i);
                for (int j = 0; j < ruleDef.choices.Count; j++)
                {
                    RuleChoiceDef ruleChoiceDef = ruleDef.choices[j];
                    string        item          = string.Format("  {{localChoiceIndex={0} globalChoiceIndex={1} localName={2}}}", ruleChoiceDef.localIndex, ruleChoiceDef.globalIndex, ruleChoiceDef.localName);
                    list2.Add(item);
                }
                string str = string.Join("\n", list2);
                list2.Clear();
                string str2 = string.Format("[{0}] {1} defaultChoiceIndex={2}\n", i, ruleDef.globalName, ruleDef.defaultChoiceIndex);
                list.Add(str2 + str);
            }
            Debug.Log(string.Join("\n", list));
        }
Пример #14
0
 // Token: 0x06001899 RID: 6297 RVA: 0x00069EB8 File Offset: 0x000680B8
 public RuleChoiceDef GetRuleChoice(RuleDef ruleDef)
 {
     return(ruleDef.choices[(int)this.ruleValues[ruleDef.globalIndex]]);
 }
Пример #15
0
 // Token: 0x06001897 RID: 6295 RVA: 0x00069E8F File Offset: 0x0006808F
 public int GetRuleChoiceIndex(RuleDef ruleDef)
 {
     return((int)this.ruleValues[ruleDef.globalIndex]);
 }
        private static void Init()
        {
            RuleCatalog.AddCategory("RULE_HEADER_DIFFICULTY", new Color32(28, 99, 150, byte.MaxValue));
            RuleCatalog.AddRule(RuleDef.FromDifficulty());
            RuleCatalog.AddCategory("RULE_HEADER_ARTIFACTS", new Color32(74, 50, 149, byte.MaxValue), "RULE_ARTIFACTS_EMPTY_TIP", new Func <bool>(RuleCatalog.HiddenTestFalse));
            for (ArtifactIndex artifactIndex = ArtifactIndex.Command; artifactIndex < ArtifactIndex.Count; artifactIndex++)
            {
                RuleCatalog.AddRule(RuleDef.FromArtifact(artifactIndex));
            }
            RuleCatalog.AddCategory("RULE_HEADER_ITEMS", new Color32(147, 225, 128, byte.MaxValue), null, new Func <bool>(RuleCatalog.HiddenTestItemsConvar));
            List <ItemIndex> list      = new List <ItemIndex>();
            ItemIndex        itemIndex = ItemIndex.Syringe;
            ItemIndex        itemCount = (ItemIndex)ItemCatalog.itemCount;

            while (itemIndex < itemCount)
            {
                list.Add(itemIndex);
                itemIndex++;
            }
            foreach (ItemIndex itemIndex2 in from i in list
                     where ItemCatalog.GetItemDef(i).inDroppableTier
                     orderby ItemCatalog.GetItemDef(i).tier
                     select i)
            {
                RuleCatalog.AddRule(RuleDef.FromItem(itemIndex2));
            }
            RuleCatalog.AddCategory("RULE_HEADER_EQUIPMENT", new Color32(byte.MaxValue, 128, 0, byte.MaxValue), null, new Func <bool>(RuleCatalog.HiddenTestItemsConvar));
            List <EquipmentIndex> list2          = new List <EquipmentIndex>();
            EquipmentIndex        equipmentIndex = EquipmentIndex.CommandMissile;
            EquipmentIndex        equipmentCount = (EquipmentIndex)EquipmentCatalog.equipmentCount;

            while (equipmentIndex < equipmentCount)
            {
                list2.Add(equipmentIndex);
                equipmentIndex++;
            }
            foreach (EquipmentIndex equipmentIndex2 in from i in list2
                     where EquipmentCatalog.GetEquipmentDef(i).canDrop
                     select i)
            {
                RuleCatalog.AddRule(RuleDef.FromEquipment(equipmentIndex2));
            }
            RuleCatalog.AddCategory("RULE_HEADER_MISC", new Color32(192, 192, 192, byte.MaxValue), null, new Func <bool>(RuleCatalog.HiddenTestFalse));
            RuleDef       ruleDef       = new RuleDef("Misc.StartingMoney", "RULE_MISC_STARTING_MONEY");
            RuleChoiceDef ruleChoiceDef = ruleDef.AddChoice("0", 0U, true);

            ruleChoiceDef.tooltipNameToken = "RULE_STARTINGMONEY_CHOICE_0_NAME";
            ruleChoiceDef.tooltipBodyToken = "RULE_STARTINGMONEY_CHOICE_0_DESC";
            ruleChoiceDef.tooltipNameColor = ColorCatalog.GetColor(ColorCatalog.ColorIndex.LunarCoin);
            RuleChoiceDef ruleChoiceDef2 = ruleDef.AddChoice("15", 15U, true);

            ruleChoiceDef2.tooltipNameToken = "RULE_STARTINGMONEY_CHOICE_15_NAME";
            ruleChoiceDef2.tooltipBodyToken = "RULE_STARTINGMONEY_CHOICE_15_DESC";
            ruleChoiceDef2.tooltipNameColor = ColorCatalog.GetColor(ColorCatalog.ColorIndex.LunarCoin);
            ruleDef.MakeNewestChoiceDefault();
            RuleChoiceDef ruleChoiceDef3 = ruleDef.AddChoice("50", 50U, true);

            ruleChoiceDef3.tooltipNameToken = "RULE_STARTINGMONEY_CHOICE_50_NAME";
            ruleChoiceDef3.tooltipBodyToken = "RULE_STARTINGMONEY_CHOICE_50_DESC";
            ruleChoiceDef3.spritePath       = "Textures/MiscIcons/texRuleBonusStartingMoney";
            ruleChoiceDef3.tooltipNameColor = ColorCatalog.GetColor(ColorCatalog.ColorIndex.LunarCoin);
            RuleCatalog.AddRule(ruleDef);
            RuleDef       ruleDef2       = new RuleDef("Misc.StageOrder", "RULE_MISC_STAGE_ORDER");
            RuleChoiceDef ruleChoiceDef4 = ruleDef2.AddChoice("Normal", StageOrder.Normal, true);

            ruleChoiceDef4.tooltipNameToken = "RULE_STAGEORDER_CHOICE_NORMAL_NAME";
            ruleChoiceDef4.tooltipBodyToken = "RULE_STAGEORDER_CHOICE_NORMAL_DESC";
            ruleChoiceDef4.tooltipNameColor = ColorCatalog.GetColor(ColorCatalog.ColorIndex.LunarCoin);
            ruleDef2.MakeNewestChoiceDefault();
            RuleChoiceDef ruleChoiceDef5 = ruleDef2.AddChoice("Random", StageOrder.Random, true);

            ruleChoiceDef5.tooltipNameToken = "RULE_STAGEORDER_CHOICE_RANDOM_NAME";
            ruleChoiceDef5.tooltipBodyToken = "RULE_STAGEORDER_CHOICE_RANDOM_DESC";
            ruleChoiceDef5.spritePath       = "Textures/MiscIcons/texRuleMapIsRandom";
            ruleChoiceDef5.tooltipNameColor = ColorCatalog.GetColor(ColorCatalog.ColorIndex.LunarCoin);
            RuleCatalog.AddRule(ruleDef2);
            RuleDef ruleDef3 = new RuleDef("Misc.KeepMoneyBetweenStages", "RULE_MISC_KEEP_MONEY_BETWEEN_STAGES");

            ruleDef3.AddChoice("On", true, true).tooltipBodyToken   = "RULE_KEEPMONEYBETWEENSTAGES_CHOICE_ON_DESC";
            ruleDef3.AddChoice("Off", false, true).tooltipBodyToken = "RULE_KEEPMONEYBETWEENSTAGES_CHOICE_OFF_DESC";
            ruleDef3.MakeNewestChoiceDefault();
            RuleCatalog.AddRule(ruleDef3);
            for (int k = 0; k < RuleCatalog.allRuleDefs.Count; k++)
            {
                RuleDef ruleDef4 = RuleCatalog.allRuleDefs[k];
                ruleDef4.globalIndex = k;
                for (int j = 0; j < ruleDef4.choices.Count; j++)
                {
                    RuleChoiceDef ruleChoiceDef6 = ruleDef4.choices[j];
                    ruleChoiceDef6.localIndex  = j;
                    ruleChoiceDef6.globalIndex = RuleCatalog.allChoicesDefs.Count;
                    RuleCatalog.allChoicesDefs.Add(ruleChoiceDef6);
                }
            }
            RuleCatalog.availability.MakeAvailable();
        }
Пример #17
0
 // Token: 0x0600106A RID: 4202 RVA: 0x00048261 File Offset: 0x00046461
 private RuleChoiceDef GetDefaultChoice(RuleDef ruleDef)
 {
     return(ruleDef.choices[PreGameController.instance.readOnlyRuleBook.GetRuleChoiceIndex(ruleDef)]);
 }
Пример #18
0
        // Token: 0x06001065 RID: 4197 RVA: 0x00047FA8 File Offset: 0x000461A8
        private static void UpdateGameVotes()
        {
            int i           = 0;
            int choiceCount = RuleCatalog.choiceCount;

            while (i < choiceCount)
            {
                PreGameRuleVoteController.votesForEachChoice[i] = 0;
                i++;
            }
            int j         = 0;
            int ruleCount = RuleCatalog.ruleCount;

            while (j < ruleCount)
            {
                RuleDef ruleDef = RuleCatalog.GetRuleDef(j);
                int     count   = ruleDef.choices.Count;
                foreach (PreGameRuleVoteController preGameRuleVoteController in PreGameRuleVoteController.instancesList)
                {
                    PreGameRuleVoteController.Vote vote = preGameRuleVoteController.votes[j];
                    if (vote.hasVoted && vote.choiceValue < count)
                    {
                        RuleChoiceDef ruleChoiceDef = ruleDef.choices[vote.choiceValue];
                        PreGameRuleVoteController.votesForEachChoice[ruleChoiceDef.globalIndex]++;
                    }
                }
                j++;
            }
            if (NetworkServer.active)
            {
                int k          = 0;
                int ruleCount2 = RuleCatalog.ruleCount;
                while (k < ruleCount2)
                {
                    RuleDef ruleDef2 = RuleCatalog.GetRuleDef(k);
                    int     count2   = ruleDef2.choices.Count;
                    PreGameController.instance.readOnlyRuleBook.GetRuleChoiceIndex(ruleDef2);
                    int  ruleChoiceIndex = -1;
                    int  num             = 0;
                    bool flag            = false;
                    for (int l = 0; l < count2; l++)
                    {
                        RuleChoiceDef ruleChoiceDef2 = ruleDef2.choices[l];
                        int           num2           = PreGameRuleVoteController.votesForEachChoice[ruleChoiceDef2.globalIndex];
                        if (num2 == num)
                        {
                            flag = true;
                        }
                        else if (num2 > num)
                        {
                            ruleChoiceIndex = ruleChoiceDef2.globalIndex;
                            num             = num2;
                            flag            = false;
                        }
                    }
                    if (num == 0)
                    {
                        ruleChoiceIndex = ruleDef2.choices[ruleDef2.defaultChoiceIndex].globalIndex;
                    }
                    if (!flag || num == 0)
                    {
                        PreGameController.instance.ApplyChoice(ruleChoiceIndex);
                    }
                    k++;
                }
            }
            Action action = PreGameRuleVoteController.onVotesUpdated;

            if (action == null)
            {
                return;
            }
            action();
        }
Пример #19
0
        static patch_RuleCatalog()
        {
            allRuleDefs                = new List <RuleDef>();
            allChoicesDefs             = new List <RuleChoiceDef>();
            allCategoryDefs            = new List <RuleCategoryDef>();
            ruleDefsByGlobalName       = new Dictionary <string, RuleDef>();
            ruleChoiceDefsByGlobalName = new Dictionary <string, RuleChoiceDef>();
            ruleShowItems              = new BoolConVar("rule_show_items", ConVarFlags.None, "1",
                                                        "Whether or not to allow voting on items in the pregame rules.");
            RuleCatalog.AddCategory("RULE_HEADER_DIFFICULTY", new Color32(28, 99, 150, byte.MaxValue));
            RuleCatalog.AddRule(RuleDef.FromDifficulty());
            RuleCatalog.AddCategory("RULE_HEADER_ARTIFACTS", new Color32(74, 50, 149, byte.MaxValue), null,
                                    RuleCatalog.HiddenTestFalse);
            for (ArtifactIndex artifactIndex = 0; artifactIndex < ArtifactIndex.Count; artifactIndex++)
            {
                RuleCatalog.AddRule(RuleDef.FromArtifact(artifactIndex));
            }

            RuleCatalog.AddCategory("RULE_HEADER_ITEMS", new Color32(147, 225, 128, byte.MaxValue), null,
                                    RuleCatalog.HiddenTestItemsConvar);
            var list = new List <ItemIndex>();

            for (ItemIndex itemIndex = 0; itemIndex < ItemIndex.Count; itemIndex++)
            {
                list.Add(itemIndex);
            }

            foreach (var itemIndex2 in from i in list
                     where ItemCatalog.GetItemDef(i).inDroppableTier
                     orderby ItemCatalog.GetItemDef(i).tier
                     select i)
            {
                RuleCatalog.AddRule(RuleDef.FromItem(itemIndex2));
            }

            RuleCatalog.AddCategory("RULE_HEADER_EQUIPMENT", new Color32(byte.MaxValue, 128, 0, byte.MaxValue), null,
                                    RuleCatalog.HiddenTestItemsConvar);
            var list2 = new List <EquipmentIndex>();

            for (EquipmentIndex equipmentIndex = 0; equipmentIndex < EquipmentIndex.Count; equipmentIndex++)
            {
                list2.Add(equipmentIndex);
            }

            foreach (var equipmentIndex2 in from i in list2
                     where EquipmentCatalog.GetEquipmentDef(i).canDrop
                     select i)
            {
                RuleCatalog.AddRule(RuleDef.FromEquipment(equipmentIndex2));
            }

            RuleCatalog.AddCategory("RULE_HEADER_MISC", new Color32(192, 192, 192, byte.MaxValue), null,
                                    RuleCatalog.HiddenTestFalse);
            var ruleDef       = new RuleDef("Misc.StartingMoney", "RULE_MISC_STARTING_MONEY");
            var ruleChoiceDef = ruleDef.AddChoice("0", 0, true);

            ruleChoiceDef.tooltipNameToken = "RULE_STARTINGMONEY_CHOICE_0_NAME";
            ruleChoiceDef.tooltipBodyToken = "RULE_STARTINGMONEY_CHOICE_0_DESC";
            ruleChoiceDef.tooltipNameColor = ColorCatalog.GetColor(ColorCatalog.ColorIndex.LunarCoin);
            var ruleChoiceDef2 = ruleDef.AddChoice("15", 15, true);

            ruleChoiceDef2.tooltipNameToken = "RULE_STARTINGMONEY_CHOICE_15_NAME";
            ruleChoiceDef2.tooltipBodyToken = "RULE_STARTINGMONEY_CHOICE_15_DESC";
            ruleChoiceDef2.tooltipNameColor = ColorCatalog.GetColor(ColorCatalog.ColorIndex.LunarCoin);
            ruleDef.MakeNewestChoiceDefault();
            var ruleChoiceDef3 = ruleDef.AddChoice("50", 50, true);

            ruleChoiceDef3.tooltipNameToken = "RULE_STARTINGMONEY_CHOICE_50_NAME";
            ruleChoiceDef3.tooltipBodyToken = "RULE_STARTINGMONEY_CHOICE_50_DESC";
            ruleChoiceDef3.spritePath       = "Textures/MiscIcons/texRuleBonusStartingMoney";
            ruleChoiceDef3.tooltipNameColor = ColorCatalog.GetColor(ColorCatalog.ColorIndex.LunarCoin);
            RuleCatalog.AddRule(ruleDef);
            var ruleDef2       = new RuleDef("Misc.StageOrder", "RULE_MISC_STAGE_ORDER");
            var ruleChoiceDef4 = ruleDef2.AddChoice("Normal", 0, true);

            ruleChoiceDef4.tooltipNameToken = "RULE_STAGEORDER_CHOICE_NORMAL_NAME";
            ruleChoiceDef4.tooltipBodyToken = "RULE_STAGEORDER_CHOICE_NORMAL_DESC";
            ruleChoiceDef4.tooltipNameColor = ColorCatalog.GetColor(ColorCatalog.ColorIndex.LunarCoin);
            ruleDef2.MakeNewestChoiceDefault();
            var ruleChoiceDef5 = ruleDef2.AddChoice("Random", 1, true);

            ruleChoiceDef5.tooltipNameToken = "RULE_STAGEORDER_CHOICE_RANDOM_NAME";
            ruleChoiceDef5.tooltipBodyToken = "RULE_STAGEORDER_CHOICE_RANDOM_DESC";
            ruleChoiceDef5.spritePath       = "Textures/MiscIcons/texRuleMapIsRandom";
            ruleChoiceDef5.tooltipNameColor = ColorCatalog.GetColor(ColorCatalog.ColorIndex.LunarCoin);
            RuleCatalog.AddRule(ruleDef2);
            var ruleDef3 = new RuleDef("Misc.KeepMoneyBetweenStages", "RULE_MISC_KEEP_MONEY_BETWEEN_STAGES");

            ruleDef3.AddChoice("On", 1, true).tooltipBodyToken  = "RULE_KEEPMONEYBETWEENSTAGES_CHOICE_ON_DESC";
            ruleDef3.AddChoice("Off", 0, true).tooltipBodyToken = "RULE_KEEPMONEYBETWEENSTAGES_CHOICE_OFF_DESC";
            ruleDef3.MakeNewestChoiceDefault();
            RuleCatalog.AddRule(ruleDef3);
            for (var k = 0; k < RuleCatalog.allRuleDefs.Count; k++)
            {
                var ruleDef4 = RuleCatalog.allRuleDefs[k];
                ruleDef4.globalIndex = k;
                for (var j = 0; j < ruleDef4.choices.Count; j++)
                {
                    var ruleChoiceDef6 = ruleDef4.choices[j];
                    ruleChoiceDef6.localIndex  = j;
                    ruleChoiceDef6.globalIndex = RuleCatalog.allChoicesDefs.Count;
                    RuleCatalog.allChoicesDefs.Add(ruleChoiceDef6);
                }
            }

            RuleCatalog.availability.MakeAvailable();
        }