Ejemplo n.º 1
0
        /// <summary>
        /// Sets the `isUpgrade` and `upgrade` fields for the given trait.
        /// </summary>
        private static void RegisterUpgrades(Type traitType, BMTraitInfo traitInfo)
        {
            TraitUnlock unlock           = traitInfo.TraitBuilder.Unlock;
            BMTraitInfo upgradeTraitInfo = GetTraitInfo(traitInfo.Upgrade);

            unlock.SetUpgrade(
                upgradeDowngradeDict.ContainsKey(traitType),
                upgradeTraitInfo?.Name
                );
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Sets the recommendations for the given trait
        /// </summary>
        private static void RegisterRecommendations(Type traitType, BMTraitInfo traitInfo)
        {
            TraitUnlock      unlock          = traitInfo.TraitBuilder.Unlock;
            HashSet <string> recommendations = new HashSet <string>();

            if (traitInfo.Recommendations.Count > 0)
            {
                foreach (string recommendTrait in traitInfo.Recommendations
                         .Select(type => GetTraitInfo(type)?.Name)
                         .Where(name => name != null))
                {
                    recommendations.Add(recommendTrait);
                }
            }

            // TODO recommend vanilla traits

            unlock.SetRecommendations(recommendations);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Sets the cancellations for the given trait.
        /// </summary>
        private static void RegisterCancellations(Type traitType, BMTraitInfo traitInfo)
        {
            TraitUnlock      unlock        = traitInfo.TraitBuilder.Unlock;
            HashSet <string> cancellations = new HashSet <string>();

            // cancel all traits in this conflictGroup
            if (traitInfo.ConflictGroups.Count > 0)
            {
                foreach (string cancelTrait in traitInfo.ConflictGroups
                         .SelectMany(group => conflictGroupDict[group])
                         .Where(type => type != traitType)                        // prevent trait from cancelling itself
                         .Select(GetTraitInfo)
                         .Where(info => info != null)
                         .Select(info => info.Name))
                {
                    cancellations.Add(cancelTrait);
                }
            }

            // make sure this trait cancels any downgrade-traits
            if (upgradeDowngradeDict.ContainsKey(traitType))
            {
                foreach (string cancelTrait in upgradeDowngradeDict[traitType]
                         .Select(type => GetTraitInfo(type)?.Name)
                         .Where(name => name != null))
                {
                    cancellations.Add(cancelTrait);
                }
            }

            // make sure this trait cancels the upgrade trait
            if (traitInfo.Upgrade != null && registeredTraits.ContainsKey(traitInfo.Upgrade))
            {
                cancellations.Add(registeredTraits[traitInfo.Upgrade].Name);
            }

            // TODO conflicts with vanilla traits

            unlock.SetCancellations(cancellations);
        }