예제 #1
0
        private void RecalculateModifierAvailability()
        {
            if (!NetworkServer.active)
            {
                Debug.LogWarning("[Server] function 'System.Void RoR2.PreGameController::RecalculateModifierAvailability()' called on client");
                return;
            }
            for (int i = 0; i < RuleCatalog.choiceCount; i++)
            {
                RuleChoiceDef choiceDef = RuleCatalog.GetChoiceDef(i);
                bool          flag      = string.IsNullOrEmpty(choiceDef.unlockableName);
                if (!flag)
                {
                    UnlockableDef unlockableDef = UnlockableCatalog.GetUnlockableDef(choiceDef.unlockableName);
                    if (unlockableDef != null)
                    {
                        flag = PreGameController.AnyUserHasUnlockable(unlockableDef);
                    }
                }
                this.unlockedChoiceMask[i] = flag;
            }
            this.ResolveChoiceMask();
            Action <PreGameController> action = PreGameController.onServerRecalculatedModifierAvailability;

            if (action == null)
            {
                return;
            }
            action(this);
        }
예제 #2
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);
         }
     }
 }
예제 #3
0
 private static void Init()
 {
     RuleBook.defaultValues = new byte[RuleCatalog.ruleCount];
     for (int i = 0; i < RuleCatalog.ruleCount; i++)
     {
         RuleBook.defaultValues[i] = (byte)RuleCatalog.GetRuleDef(i).defaultChoiceIndex;
     }
 }
예제 #4
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);
 }
예제 #5
0
 // Token: 0x06001970 RID: 6512 RVA: 0x00079A38 File Offset: 0x00077C38
 static RuleBook()
 {
     RuleCatalog.availability.CallWhenAvailable(delegate
     {
         RuleBook.defaultValues = new byte[RuleCatalog.ruleCount];
         for (int i = 0; i < RuleCatalog.ruleCount; i++)
         {
             RuleBook.defaultValues[i] = (byte)RuleCatalog.GetRuleDef(i).defaultChoiceIndex;
         }
     });
 }
예제 #6
0
 // Token: 0x0600189F RID: 6303 RVA: 0x00069FD0 File Offset: 0x000681D0
 public DifficultyIndex FindDifficulty()
 {
     for (int i = 0; i < this.ruleValues.Length; i++)
     {
         RuleChoiceDef ruleChoiceDef = RuleCatalog.GetRuleDef(i).choices[(int)this.ruleValues[i]];
         if (ruleChoiceDef.difficultyIndex != DifficultyIndex.Invalid)
         {
             return(ruleChoiceDef.difficultyIndex);
         }
     }
     return(DifficultyIndex.Invalid);
 }
예제 #7
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);
        }
예제 #8
0
        // Token: 0x060018A1 RID: 6305 RVA: 0x0006A074 File Offset: 0x00068274
        public ItemMask GenerateItemMask()
        {
            ItemMask result = default(ItemMask);

            for (int i = 0; i < this.ruleValues.Length; i++)
            {
                RuleChoiceDef ruleChoiceDef = RuleCatalog.GetRuleDef(i).choices[(int)this.ruleValues[i]];
                if (ruleChoiceDef.itemIndex != ItemIndex.None)
                {
                    result.AddItem(ruleChoiceDef.itemIndex);
                }
            }
            return(result);
        }
예제 #9
0
        // Token: 0x060018A2 RID: 6306 RVA: 0x0006A0CC File Offset: 0x000682CC
        public EquipmentMask GenerateEquipmentMask()
        {
            EquipmentMask result = default(EquipmentMask);

            for (int i = 0; i < this.ruleValues.Length; i++)
            {
                RuleChoiceDef ruleChoiceDef = RuleCatalog.GetRuleDef(i).choices[(int)this.ruleValues[i]];
                if (ruleChoiceDef.equipmentIndex != EquipmentIndex.None)
                {
                    result.AddEquipment(ruleChoiceDef.equipmentIndex);
                }
            }
            return(result);
        }
예제 #10
0
        // Token: 0x060018A0 RID: 6304 RVA: 0x0006A01C File Offset: 0x0006821C
        public ArtifactMask GenerateArtifactMask()
        {
            ArtifactMask result = default(ArtifactMask);

            for (int i = 0; i < this.ruleValues.Length; i++)
            {
                RuleChoiceDef ruleChoiceDef = RuleCatalog.GetRuleDef(i).choices[(int)this.ruleValues[i]];
                if (ruleChoiceDef.artifactIndex != ArtifactIndex.None)
                {
                    result.AddArtifact(ruleChoiceDef.artifactIndex);
                }
            }
            return(result);
        }
예제 #11
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();
 }
예제 #12
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);
 }
예제 #13
0
 // Token: 0x060018A4 RID: 6308 RVA: 0x0006A1B0 File Offset: 0x000683B0
 public static bool FromXml(XElement element, ref RuleBook dest)
 {
     dest.SetToDefaults();
     string[] array = element.Value.Split(new char[]
     {
         ' '
     });
     for (int i = 0; i < array.Length; i++)
     {
         RuleChoiceDef ruleChoiceDef = RuleCatalog.FindChoiceDef(array[i]);
         if (ruleChoiceDef != null)
         {
             dest.ApplyChoice(ruleChoiceDef);
         }
     }
     return(true);
 }
예제 #14
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++;
            }
        }
예제 #15
0
        public void ApplyChoice(int ruleChoiceIndex)
        {
            if (!NetworkServer.active)
            {
                Debug.LogWarning("[Server] function 'System.Void RoR2.PreGameController::ApplyChoice(System.Int32)' called on client");
                return;
            }
            if (!this.resolvedRuleChoiceMask[ruleChoiceIndex])
            {
                return;
            }
            RuleChoiceDef choiceDef = RuleCatalog.GetChoiceDef(ruleChoiceIndex);

            if (this.readOnlyRuleBook.GetRuleChoice(choiceDef.ruleDef.globalIndex) == choiceDef)
            {
                return;
            }
            this.ruleBookBuffer.Copy(this.readOnlyRuleBook);
            this.ruleBookBuffer.ApplyChoice(choiceDef);
            this.networkRuleBookComponent.SetRuleBook(this.ruleBookBuffer);
        }
        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));
        }
예제 #17
0
        // Token: 0x0600102E RID: 4142 RVA: 0x00047134 File Offset: 0x00045334
        private void Awake()
        {
            this.networkRuleChoiceMaskComponent = base.GetComponent <NetworkRuleChoiceMask>();
            this.networkRuleBookComponent       = base.GetComponent <NetworkRuleBook>();
            this.ruleBookBuffer            = new RuleBook();
            this.serverAvailableChoiceMask = new RuleChoiceMask();
            this.unlockedChoiceMask        = new RuleChoiceMask();
            this.choiceMaskBuffer          = new RuleChoiceMask();
            if (NetworkServer.active)
            {
                this.NetworkgameModeIndex = GameModeCatalog.FindGameModeIndex(PreGameController.GameModeConVar.instance.GetString());
                this.runSeed = RoR2Application.rng.nextUlong;
            }
            bool isInSinglePlayer = RoR2Application.isInSinglePlayer;

            for (int i = 0; i < this.serverAvailableChoiceMask.length; i++)
            {
                RuleChoiceDef choiceDef = RuleCatalog.GetChoiceDef(i);
                this.serverAvailableChoiceMask[i] = (isInSinglePlayer ? choiceDef.availableInSinglePlayer : choiceDef.availableInMultiPlayer);
            }
            NetworkUser.OnPostNetworkUserStart += this.GenerateRuleVoteController;
        }
예제 #18
0
        private void ResolveChoiceMask()
        {
            if (!NetworkServer.active)
            {
                Debug.LogWarning("[Server] function 'System.Void RoR2.PreGameController::ResolveChoiceMask()' called on client");
                return;
            }
            RuleChoiceMask ruleChoiceMask          = new RuleChoiceMask();
            RuleChoiceMask ruleChoiceMask2         = new RuleChoiceMask();
            Run            gameModePrefabComponent = GameModeCatalog.GetGameModePrefabComponent(this.gameModeIndex);

            if (gameModePrefabComponent)
            {
                gameModePrefabComponent.OverrideRuleChoices(ruleChoiceMask, ruleChoiceMask2);
            }
            for (int i = 0; i < this.choiceMaskBuffer.length; i++)
            {
                RuleChoiceDef choiceDef = RuleCatalog.GetChoiceDef(i);
                this.choiceMaskBuffer[i] = (ruleChoiceMask[i] || (!ruleChoiceMask2[i] && this.serverAvailableChoiceMask[i] && this.unlockedChoiceMask[i] && !choiceDef.excludeByDefault));
            }
            this.networkRuleChoiceMaskComponent.SetRuleChoiceMask(this.choiceMaskBuffer);
            this.EnforceValidRuleChoices();
        }
        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();
        }
예제 #20
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();
        }
예제 #21
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();
        }
예제 #22
0
 // Token: 0x06001898 RID: 6296 RVA: 0x00069E9E File Offset: 0x0006809E
 public RuleChoiceDef GetRuleChoice(int ruleIndex)
 {
     return(RuleCatalog.GetRuleDef(ruleIndex).choices[(int)this.ruleValues[ruleIndex]]);
 }
 // Token: 0x060018C2 RID: 6338 RVA: 0x0006A535 File Offset: 0x00068735
 private static void AddCategory(string displayToken, Color color)
 {
     RuleCatalog.AddCategory(displayToken, color, null, new Func <bool>(RuleCatalog.HiddenTestFalse));
 }