Exemple #1
0
        static void VoteControllerDeserialize(On.RoR2.VoteController.orig_OnDeserialize orig, VoteController self, NetworkReader reader, bool initialState)
        {
            orig(self, reader, initialState);
            if (reader.Position < reader.Length && !Run.instance)
            {
                if (TargetedRuleBook != null && TargetedRuleChoiceMask != null)
                {
                    byte[] ruleBookBytes       = TargetedRuleBook.GetFieldValue <byte[]>("ruleValues");
                    byte[] ruleChoiceMaskBytes = (byte[])TargetedRuleChoiceMask.GetType().BaseType.GetField("bytes", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(TargetedRuleChoiceMask);

                    for (int i = ruleBookBytes.Length - RegisteredVoteSelections.Count; i < ruleBookBytes.Length; i++)
                    {
                        ruleBookBytes[i] = reader.ReadByte();
                    }

                    int difference = ruleChoiceMaskBytes.Length - ((RuleCatalog.choiceCount - RegisteredVoteChoices.Count) + 7 >> 3);
                    for (int i = ruleChoiceMaskBytes.Length - difference; i < ruleChoiceMaskBytes.Length; i++)
                    {
                        ruleChoiceMaskBytes[i] = reader.ReadByte();
                    }

                    TargetedRuleBook       = null;
                    TargetedRuleChoiceMask = null;
                }
            }
        }
Exemple #2
0
        static void DisplayArtifacts(On.RoR2.PreGameController.orig_ResolveChoiceMask orig, PreGameController self)
        {
            RuleChoiceMask unlockedChoiceMask = R2API.Utils.Reflection.GetFieldValue <RuleChoiceMask>(self, "unlockedChoiceMask");

            for (int i = 0; i < RuleCatalog.choiceCount - 4; i++)
            {
                unlockedChoiceMask[i] = true;
                R2API.Utils.Reflection.SetFieldValue <RuleChoiceMask>(self, "unlockedChoiceMask", unlockedChoiceMask);
            }
            orig(self);
        }
Exemple #3
0
        static void RuleChoiceMaskDeserialize(On.RoR2.RuleChoiceMask.orig_Deserialize orig, RuleChoiceMask self, NetworkReader reader)
        {
            byte[] bytes      = (byte[])self.GetType().BaseType.GetField("bytes", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(self);
            int    difference = bytes.Length - ((RuleCatalog.choiceCount - RegisteredVoteChoices.Count) + 7 >> 3);

            for (int i = 0; i < bytes.Length - difference; i++)
            {
                bytes[i] = reader.ReadByte();
            }
            TargetedRuleChoiceMask = self;
        }
 // Token: 0x060024EE RID: 9454 RVA: 0x000A0FB8 File Offset: 0x0009F1B8
 private void SetData(RuleChoiceMask choiceAvailability, RuleBook ruleBook)
 {
     if (choiceAvailability.Equals(this.cachedRuleChoiceMask) && ruleBook.Equals(this.cachedRuleBook))
     {
         return;
     }
     this.cachedRuleChoiceMask.Copy(choiceAvailability);
     this.cachedRuleBook.Copy(ruleBook);
     for (int i = 0; i < RuleCatalog.categoryCount; i++)
     {
         this.categoryControllers[i].SetData(RuleCatalog.GetCategoryDef(i), this.cachedRuleChoiceMask, this.cachedRuleBook);
         this.categoryControllers[i].gameObject.SetActive(!this.categoryControllers[i].shouldHide);
     }
 }
Exemple #5
0
        // Token: 0x060024FD RID: 9469 RVA: 0x000A1408 File Offset: 0x0009F608
        public void SetData(RuleCategoryDef categoryDef, RuleChoiceMask availability, RuleBook ruleBook)
        {
            this.currentCategory = categoryDef;
            this.rulesToDisplay.Clear();
            List <RuleDef> children = categoryDef.children;

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

            for (int j = 0; j < this.rulesToDisplay.Count; j++)
            {
                RuleDef ruleDef2 = this.rulesToDisplay[j];
                list.Clear();
                foreach (RuleChoiceDef ruleChoiceDef2 in ruleDef2.choices)
                {
                    if (availability[ruleChoiceDef2.globalIndex])
                    {
                        list.Add(ruleChoiceDef2);
                    }
                }
                this.strips[j].GetComponent <RuleBookViewerStrip>().SetData(list, ruleBook.GetRuleChoiceIndex(ruleDef2));
            }
            if (this.headerObject)
            {
                this.headerObject.GetComponent <Image>().color = categoryDef.color;
                this.headerObject.GetComponentInChildren <LanguageTextMeshController>().token = categoryDef.displayToken;
            }
            this.SetTip(this.isEmpty ? categoryDef.emptyTipToken : null);
        }
Exemple #6
0
 private void RuleCategoryController_SetData(On.RoR2.UI.RuleCategoryController.orig_SetData orig, RoR2.UI.RuleCategoryController self, RuleCategoryDef categoryDef, RuleChoiceMask availability, RuleBook ruleBook)
 {
     if (categoryDef.displayToken == "RULE_HEADER_DIFFICULTY" && EDrule != null)
     {
         try
         {
             var localUser1 = LocalUserManager.GetFirstLocalUser();
             if (localUser1 != null)
             {
                 bool knowsED = AchievementManager.GetUserAchievementManager(localUser1).userProfile.HasAchievement("COMPLETE_MAINENDING_DILUVIAN");
                 if (knowsED)
                 {
                     Syzygy.Unlocked();
                 }
                 else
                 {
                     Syzygy.Locked();
                 }
                 EDrule.spritePath = assetString + Syzygy.def.IconPath;
                 ReloadLanguage();
             }
         }
         catch (Exception e)
         {
             Logger.LogWarning(e);
         }
     }
     orig(self, categoryDef, availability, ruleBook);
 }
Exemple #7
0
        static void RuleChoiceMaskSerialize(On.RoR2.RuleChoiceMask.orig_Serialize orig, RuleChoiceMask self, NetworkWriter writer)
        {
            byte[] bytes      = (byte[])self.GetType().BaseType.GetField("bytes", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(self);
            int    difference = bytes.Length - ((RuleCatalog.choiceCount - RegisteredVoteChoices.Count) + 7 >> 3);

            for (int i = 0; i < bytes.Length - difference; i++)
            {
                writer.Write(bytes[i]);
            }
            for (int i = bytes.Length - difference; i < bytes.Length; i++)
            {
                RuleChoiceMaskExtraBytes.Add(bytes[i]);
            }
        }
        internal static void RuleCategoryControllerSetData(On.RoR2.UI.RuleCategoryController.orig_SetData orig, RoR2.UI.RuleCategoryController self, RuleCategoryDef categoryDef, RuleChoiceMask availability, RuleBook ruleBook)
        {
            orig(self, categoryDef, availability, ruleBook);

            var stripContainer = self.transform.Find("StripContainer");

            if (!stripContainer.gameObject.activeInHierarchy)
            {
                return;
            }

            stripContainer.Find("FrameContainer").gameObject.SetActive(false);

            for (var i = 0; i < stripContainer.childCount; i++)
            {
                var child = stripContainer.GetChild(i);
                if (child.gameObject.activeSelf)
                {
                    SetupStripPrefab(child);
                }
            }
        }