private static ThingDef RandomRequiredDef()
        {
            int numMeats = (from x in PossibleСontentsDefs()
                            where x.IsMeat
                            select x).Count();
            int numLeathers = (from x in PossibleСontentsDefs()
                               where x.IsLeather
                               select x).Count();

            return(PossibleСontentsDefs().RandomElementByWeight((ThingDef d) => ThingSetMakerUtility.AdjustedBigCategoriesSelectionWeight(d, numMeats, numLeathers)));
        }
        public static ThingDef RandomPodContentsDef(bool mustBeResource = false)
        {
            IEnumerable <ThingDef> source = ThingSetMaker_BeeResourcePod.PossiblePodContentsDefs();

            if (mustBeResource)
            {
                source = from x in source
                         where x.stackLimit > 1
                         select x;
            }
            int numMeats = (from x in source
                            where x.IsMeat
                            select x).Count <ThingDef>();
            int numLeathers = (from x in source
                               where x.IsLeather
                               select x).Count <ThingDef>();

            return(source.RandomElementByWeight((ThingDef d) => ThingSetMakerUtility.AdjustedBigCategoriesSelectionWeight(d, numMeats, numLeathers)));
        }
Exemple #3
0
        private static ThingDef RandomPodContentsDef()
        {
            int numMeats = (from x in ThingSetMaker_Treasure.PossiblePodContentsDefs()
                            where x.IsMeat
                            select x).Count <ThingDef>();
            int numLeathers = (from x in ThingSetMaker_Treasure.PossiblePodContentsDefs()
                               where x.IsLeather
                               select x).Count <ThingDef>();

            return(ThingSetMaker_Treasure.PossiblePodContentsDefs().RandomElementByWeight((ThingDef d) => ThingSetMakerUtility.AdjustedBigCategoriesSelectionWeight(d, numMeats, numLeathers)));
        }