Пример #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
        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);
        }
Пример #3
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;
        }
Пример #4
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();
        }