コード例 #1
0
        public static List <Pair <Def, string> > GetDirectUnlocks(this ResearchProjectDef research, bool dedupe = false)
        {
            var unlocks = new List <Pair <Def, string> >();

            unlocks.AddRange(research.GetThingsUnlocked()
                             .Select(d => new Pair <Def, string>(d, ResourceBank.String.AllowsBuildingX(d.LabelCap))));

            unlocks.AddRange(research.GetTerrainUnlocked()
                             .Select(d => new Pair <Def, string>(d, ResourceBank.String.AllowsBuildingX(d.LabelCap))));

            unlocks.AddRange(research.GetDirectRecipesUnlocked()
                             .Select(d => new Pair <Def, string>(d, ResourceBank.String.AllowsCraftingX(d.LabelCap))));

            unlocks.AddRange(research.GetPlantsUnlocked()
                             .Select(d => new Pair <Def, string>(d, ResourceBank.String.AllowsPlantingX(d.LabelCap))));

            var descendants = research.Descendants();

            if (dedupe && descendants.Any())
            {
                var descendantUnlocks = descendants
                                        .SelectMany(c => c.GetUnlockDefsAndDescs(false).Select(u => u.First))
                                        .Distinct()
                                        .ToList();
                unlocks = unlocks.Where(u => !descendantUnlocks.Contains(u.First)).ToList();
            }

            return(unlocks);
        }