Exemple #1
0
        public static IEnumerable <ThingDef> GetAllowedThingDefs(ThingSetMakerParams parms)
        {
            TechLevel?techLevel2          = parms.techLevel;
            TechLevel techLevel           = techLevel2.HasValue ? techLevel2.Value : TechLevel.Undefined;
            IEnumerable <ThingDef> source = parms.filter.AllowedThingDefs;

            if (techLevel != 0)
            {
                source = from x in source
                         where (int)x.techLevel <= (int)techLevel
                         select x;
            }
            return(source.Where(delegate(ThingDef x)
            {
                if (!CanGenerate(x))
                {
                    goto IL_007e;
                }
                float?maxThingMarketValue = parms.maxThingMarketValue;
                if (maxThingMarketValue.HasValue)
                {
                    float?maxThingMarketValue2 = parms.maxThingMarketValue;
                    if (!maxThingMarketValue2.HasValue || !(x.BaseMarketValue <= maxThingMarketValue2.GetValueOrDefault()))
                    {
                        goto IL_007e;
                    }
                }
                int result = (parms.validator == null || parms.validator(x)) ? 1 : 0;
                goto IL_007f;
                IL_007e:
                result = 0;
                goto IL_007f;
                IL_007f:
                return (byte)result != 0;
            }));
        }
        public static IEnumerable <ThingDef> GetAllowedThingDefs(ThingSetMakerParams parms)
        {
            TechLevel techLevel           = parms.techLevel ?? TechLevel.Undefined;
            IEnumerable <ThingDef> source = parms.filter.AllowedThingDefs;

            if (techLevel != 0)
            {
                source = source.Where((ThingDef x) => (int)x.techLevel <= (int)techLevel);
            }
            RoyalTitleDef highestTitle = null;

            if (parms.makingFaction != null && parms.makingFaction.def.HasRoyalTitles)
            {
                foreach (Pawn allMapsCaravansAndTravelingTransportPods_Alive_Colonist in PawnsFinder.AllMapsCaravansAndTravelingTransportPods_Alive_Colonists)
                {
                    RoyalTitleDef royalTitleDef = ((allMapsCaravansAndTravelingTransportPods_Alive_Colonist.royalty != null) ? allMapsCaravansAndTravelingTransportPods_Alive_Colonist.royalty.GetCurrentTitle(parms.makingFaction) : null);
                    if (royalTitleDef != null && (highestTitle == null || royalTitleDef.seniority > highestTitle.seniority))
                    {
                        highestTitle = royalTitleDef;
                    }
                }
            }
            source = source.Where(delegate(ThingDef x)
            {
                CompProperties_Techprint compProperties = x.GetCompProperties <CompProperties_Techprint>();
                if (compProperties != null)
                {
                    if (parms.makingFaction != null && !compProperties.project.heldByFactionCategoryTags.Contains(parms.makingFaction.def.categoryTag))
                    {
                        return(false);
                    }
                    if (compProperties.project.IsFinished || compProperties.project.TechprintRequirementMet)
                    {
                        return(false);
                    }
                }
                if (parms.makingFaction != null && parms.makingFaction.def.HasRoyalTitles)
                {
                    RoyalTitleDef minTitleToUse = ThingRequiringRoyalPermissionUtility.GetMinTitleToUse(x, parms.makingFaction);
                    if (minTitleToUse != null && (highestTitle == null || highestTitle.seniority < minTitleToUse.seniority))
                    {
                        return(false);
                    }
                }
                return(true);
            });
            return(source.Where((ThingDef x) => CanGenerate(x) && (!parms.maxThingMarketValue.HasValue || x.BaseMarketValue <= parms.maxThingMarketValue) && (parms.validator == null || parms.validator(x))));
        }