コード例 #1
0
        public static List <Pair <Def, string> > GetUnlockDefsAndDescs(this ResearchProjectDef research)
        {
            if (_unlocksCache.ContainsKey(research))
            {
                return(_unlocksCache[research]);
            }

            var unlocks = new List <Pair <Def, string> >();

            unlocks.AddRange(research.GetThingsUnlocked()
                             .Where(d => d.IconTexture() != null)
                             .Select(d => new Pair <Def, string>(d, "Fluffy.ResearchTree.AllowsBuildingX".Translate(d.LabelCap))));
            unlocks.AddRange(research.GetTerrainUnlocked()
                             .Where(d => d.IconTexture() != null)
                             .Select(d => new Pair <Def, string>(d, "Fluffy.ResearchTree.AllowsBuildingX".Translate(d.LabelCap))));
            unlocks.AddRange(research.GetRecipesUnlocked()
                             .Where(d => d.IconTexture() != null)
                             .Select(d => new Pair <Def, string>(d, "Fluffy.ResearchTree.AllowsCraftingX".Translate(d.LabelCap))));
            unlocks.AddRange(research.GetPlantsUnlocked()
                             .Where(d => d.IconTexture() != null)
                             .Select(d => new Pair <Def, string>(d, "Fluffy.ResearchTree.AllowsPlantingX".Translate(d.LabelCap))));

            // get unlocks for all descendant research, and remove duplicates.
            var descendantUnlocks = research.Descendants().SelectMany(c => c.GetUnlockDefsAndDescs().Select(u => u.First)).ToList();

            unlocks = unlocks.Where(u => !descendantUnlocks.Contains(u.First)).ToList();

            _unlocksCache.Add(research, unlocks);
            return(unlocks);
        }
コード例 #2
0
        public static List <Pair <Def, string> > GetUnlockDefsAndDescs(this ResearchProjectDef research)
        {
            if (_unlocksCache.ContainsKey(research.shortHash))
            {
                return(_unlocksCache [research.shortHash]);
            }

            List <Pair <Def, string> > unlocks = new List <Pair <Def, string> > ();

            // dumps recipes/plants unlocked, because of the peculiar way CCL helpdefs are done.
            List <ThingDef> dump = new List <ThingDef> ();

            unlocks.AddRange(research.GetThingsUnlocked()
                             .Where(d => d.IconTexture() != null)
                             .Select(d => new Pair <Def, string> (d, "AllowsBuildingX".Translate(d.LabelCap))));
            unlocks.AddRange(research.GetTerrainUnlocked()
                             .Where(d => d.IconTexture() != null)
                             .Select(d => new Pair <Def, string> (d, "AllowsBuildingX".Translate(d.LabelCap))));
            unlocks.AddRange(research.GetRecipesUnlocked(ref dump)
                             .Where(d => d.IconTexture() != null)
                             .Select(d => new Pair <Def, string> (d, "AllowsCraftingX".Translate(d.LabelCap))));
            string sowTags = string.Join(" and ", research.GetSowTagsUnlocked(ref dump).ToArray());

            unlocks.AddRange(dump.Where(d => d.IconTexture() != null)
                             .Select(d => new Pair <Def, string> (d, "AllowsSowingXinY".Translate(d.LabelCap, sowTags))));

            _unlocksCache.Add(research.shortHash, unlocks);
            return(unlocks);
        }
コード例 #3
0
        public static List <Pair <Def, string> > GetUnlockDefsAndDescs(this ResearchProjectDef research)
        {
            if (_unlocksCache.ContainsKey(research))
            {
                return(_unlocksCache[research]);
            }

            var unlocks = new List <Pair <Def, string> >();

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

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

            unlocks.AddRange(research.GetRecipesUnlocked()
                             .Where(d => d.IconTexture() != null)
                             .Select(d => new Pair <Def, string>(d, ResourceBank.String.AllowsCraftingX(d.LabelCap))));

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



            _unlocksCache.Add(research, unlocks);
            return(unlocks);
        }
コード例 #4
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);
        }
コード例 #5
0
        public static List <Pair <Def, string> > GetUnlockDefsAndDescs(this ResearchProjectDef research, bool dedupe = true)
        {
            if (_unlocksCache.ContainsKey(research))
            {
                return(_unlocksCache[research]);
            }

            var unlocks = new List <Pair <Def, string> >();

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

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

            unlocks.AddRange(research.GetRecipesUnlocked()
                             .Where(d => d.IconTexture() != null)
                             .Select(d => new Pair <Def, string>(d, ResourceBank.String.AllowsCraftingX(d.LabelCap))));

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



            // get unlocks for all descendant research, and remove duplicates.
            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();
            }

            _unlocksCache.Add(research, unlocks);
            return(unlocks);
        }