Esempio n. 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);
         }
     }
 }
Esempio n. 2
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);
        }
Esempio n. 3
0
 // Token: 0x170002E1 RID: 737
 public bool this[RuleChoiceDef choiceDef]
 {
     get
     {
         return(base[choiceDef.globalIndex]);
     }
     set
     {
         base[choiceDef.globalIndex] = value;
     }
 }
Esempio n. 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);
        }
Esempio n. 5
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);
 }
        // Token: 0x060018D1 RID: 6353 RVA: 0x0006AD0C File Offset: 0x00068F0C
        public RuleChoiceDef AddChoice(string choiceName, object extraData = null, bool excludeByDefault = false)
        {
            RuleChoiceDef ruleChoiceDef = new RuleChoiceDef();

            ruleChoiceDef.ruleDef          = this;
            ruleChoiceDef.localName        = choiceName;
            ruleChoiceDef.globalName       = this.globalName + "." + choiceName;
            ruleChoiceDef.localIndex       = this.choices.Count;
            ruleChoiceDef.extraData        = extraData;
            ruleChoiceDef.excludeByDefault = excludeByDefault;
            this.choices.Add(ruleChoiceDef);
            return(ruleChoiceDef);
        }
Esempio n. 7
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);
        }
Esempio n. 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);
        }
Esempio n. 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);
        }
Esempio n. 10
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);
        }
Esempio n. 12
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);
 }
Esempio n. 13
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: 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);
        }
Esempio n. 17
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));
        }
Esempio n. 19
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;
        }
Esempio n. 20
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();
        }
Esempio n. 21
0
 // Token: 0x0600106E RID: 4206 RVA: 0x000483DF File Offset: 0x000465DF
 public bool IsChoiceVoted(RuleChoiceDef ruleChoiceDef)
 {
     return(this.votes[ruleChoiceDef.ruleDef.globalIndex].choiceValue == ruleChoiceDef.localIndex);
 }
Esempio n. 22
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();
        }
Esempio n. 23
0
 // Token: 0x06001895 RID: 6293 RVA: 0x00069E6A File Offset: 0x0006806A
 public void ApplyChoice(RuleChoiceDef choiceDef)
 {
     this.ruleValues[choiceDef.ruleDef.globalIndex] = (byte)choiceDef.localIndex;
 }
        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();
        }