Exemple #1
0
        protected BaseTechGroupRequirementGroupUnlocked(double completion, TechGroup techGroup)
        {
            if (completion <= 0 ||
                completion > 1)
            {
                throw new ArgumentException(
                          "The completion argument must be >0 and <=1",
                          nameof(completion));
            }

            this.GroupNodesUnlockedPercent = completion;
            this.Group = techGroup;
        }
Exemple #2
0
        private static void SharedRebuildAllNodes()
        {
            if (Api.IsClient &&
                !PveSystem.ClientIsPveFlagReceived)
            {
                AvailableTechGroups = new TechGroup[0];
                return;
            }

            var isPvE = PveSystem.SharedIsPve(false);

            var allTechGroups = Api.FindProtoEntities <TechGroup>();

            foreach (var techGroup in allTechGroups)
            {
                SetupTimeGate(techGroup);

                techGroup.Nodes = techGroup.IsAvailable
                                      ? (IReadOnlyList <TechNode>)LazyAllNodesWithoutFiltering
                                  .Value
                                  .Where(n => n.Group == techGroup &&
                                         n.IsAvailable)
                                  .OrderBy(n => n.HierarchyLevel)
                                  .ThenBy(n => n.Order)
                                  .ThenBy(n => n.ShortId)
                                  .ToList()
                                      : new TechNode[0];

                var rootNodes = new List <TechNode>();
                foreach (var node in techGroup.Nodes)
                {
                    node.SharedResetCachedLearningPointsPrice();

                    if (node.IsRootNode)
                    {
                        rootNodes.Add(node);
                    }
                }

                techGroup.RootNodes = rootNodes;

                var requirements = new Requirements();
                techGroup.PrepareTechGroup(requirements);
                if (techGroup.LearningPointsPrice > 0)
                {
                    requirements.Insert(0, new TechGroupRequirementLearningPoints(techGroup.LearningPointsPrice));
                }

                if (!PveSystem.SharedIsPve(clientLogErrorIfDataIsNotYetAvailable: false) &&
                    techGroup.TimeGatePvP > 0)
                {
                    requirements.Add(new TechGroupRequirementTimeGate(techGroup.TimeGatePvP));
                }

                techGroup.GroupRequirements = requirements;

                Api.SafeInvoke(techGroup.NodesChanged);
            }

            AvailableTechGroups = allTechGroups.Where(t => t.IsAvailable).ToArray();
            Api.SafeInvoke(AvailableTechGroupsChanged);

            void SetupTimeGate(TechGroup techGroup)
            {
                if (isPvE)
                {
                    techGroup.TimeGatePvP = 0;
                    return;
                }

                if (techGroup.IsPrimary)
                {
                    techGroup.TimeGatePvP = techGroup.Tier switch
                    {
                        TechTier.Tier3 => TechConstants.PvpTechTimeGameTier3Basic,
                        TechTier.Tier4 => TechConstants.PvpTechTimeGameTier4Basic,
                        TechTier.Tier5 => TechConstants.PvpTechTimeGameTier5Basic,
                        _ => 0
                    };
                }
                else
                {
                    techGroup.TimeGatePvP = techGroup.Tier switch
                    {
                        TechTier.Tier3 => TechConstants.PvpTechTimeGameTier3Specialized,
                        TechTier.Tier4 => TechConstants.PvpTechTimeGameTier4Specialized,
                        TechTier.Tier5 => TechConstants.PvpTechTimeGameTier5Specialized,
                        _ => 0
                    };
                }
            }
        }