Example #1
0
        //Thanks to XeoNovaDan
        public static void DisplayYieldInfo(PlantProperties __instance, ref IEnumerable <StatDrawEntry> __result)
        {
            ThingDef harvestedThingDef = Traverse.Create(__instance).Field("harvestedThingDef").GetValue <ThingDef>();
            float    harvestYield      = Traverse.Create(__instance).Field("harvestYield").GetValue <float>();

            if (harvestedThingDef == null)
            {
                return;
            }

            string harvestedThingDefLabel = harvestedThingDef.label;

            string extendedYieldInfo = string.Format("M4_HarvestYieldThingDetailInit".Translate(), harvestedThingDefLabel) + "\n\n";
            float  thingMarketValue  = harvestedThingDef.GetStatValueAbstract(StatDefOf.MarketValue, null);

            extendedYieldInfo += StatDefOf.MarketValue.label.CapitalizeFirst() + ": " + thingMarketValue.ToString();
            if (harvestedThingDef.IsNutritionGivingIngestible)
            {
                float         thingNutrition     = harvestedThingDef.GetStatValueAbstract(StatDefOf.Nutrition, null);
                FoodTypeFlags thingNutritionType = harvestedThingDef.ingestible.foodType;
                IDictionary <FoodTypeFlags, string> nutritionTypeToReportString = new Dictionary <FoodTypeFlags, string>()
                {
                    { FoodTypeFlags.VegetableOrFruit, "FoodTypeFlags_VegetableOrFruit" }, { FoodTypeFlags.Meat, "FoodTypeFlags_Meat" }, { FoodTypeFlags.Seed, "FoodTypeFlags_Seed" }
                };
                string nutritionTypeReportString = nutritionTypeToReportString.TryGetValue(thingNutritionType, out nutritionTypeReportString) ? nutritionTypeReportString : "StatsReport_OtherStats";
                extendedYieldInfo += "\n" + StatDefOf.Nutrition.label.CapitalizeFirst() + ": " + thingNutrition.ToString() +
                                     " (" + nutritionTypeReportString.Translate() + ")";
            }

            if (harvestYield > 0)
            {
                StatDrawEntry statDrawEntry = new StatDrawEntry(StatCategoryDefOf.Basics, "M4_HarvestYieldThing".Translate(), harvestedThingDef.label.CapitalizeFirst(), 0, extendedYieldInfo);
                __result = __result.Add(statDrawEntry);
            }
        }
Example #2
0
        static FoodPreferability GetAdjustedPreferability(Pawn pawn, [NotNull] Thing food)
        {
            var rawPref = food.def.ingestible?.preferability;

            if (rawPref == null)
            {
                return(FoodPreferability.Undefined);
            }
            var           rPrefVal    = rawPref.Value;
            FoodTypeFlags plantOrTree = FoodTypeFlags.Plant | FoodTypeFlags.Tree;

            if ((food.def.ingestible.foodType & plantOrTree) != 0 && (pawn.RaceProps.foodType & plantOrTree) != 0)
            {
                var nx = ((int)rPrefVal) + 1;  //make plants appear better then they actually are
                nx       = Mathf.Clamp(nx, 0, 9);
                rPrefVal = (FoodPreferability)nx;
            }
            else if (pawn.RaceProps.foodType == FoodTypeFlags.CarnivoreAnimalStrict &&
                     (food.def.ingestible.foodType & FoodTypeFlags.CarnivoreAnimalStrict) != 0)
            {
                var nx = ((int)rPrefVal) + 2; //make meat appear better then they actually are for strict carnivorous
                nx       = Mathf.Clamp(nx, 0, 9);
                rPrefVal = (FoodPreferability)nx;
            }

            return(rPrefVal);
        }
Example #3
0
        public static bool IsColdDrink(ThingDef def)
        {
            var ing = def.ingestible;

            if (ing != null)
            {
                if (ing.ingestCommandString != null && ing.ingestCommandString.ToLower().Contains("drink"))
                {
                    return(true);
                }
                if (ing.nurseable == true)
                {
                    return(true);
                }

                FoodTypeFlags ft     = ing.foodType;
                FoodTypeFlags filter = FoodTypeFlags.Liquor | FoodTypeFlags.Fluid;
                if ((ft & filter) != FoodTypeFlags.None)
                {
                    return(true);
                }
                CompProperties_Drug drugCompProp = def.GetCompProperties <CompProperties_Drug>();
                if (drugCompProp != null && (drugCompProp.chemical == ChemicalDefOf.Alcohol || drugCompProp.chemical != DefDatabase <ChemicalDef> .GetNamed("RC2_Caffeine", false)))
                {
                    return(true);
                }
            }
            return(false);
        }
Example #4
0
        private static bool PrepareToIngestToilsPrefix(JobDriver __instance, Toil chewToil, ref IEnumerable <Toil> __result) //TODO figure out how to turn this into a transpiler patch
        {
            Thing thing = __instance.job.targetA.Thing;

            if (RaceGenerator.TryGetMorphOfRace(__instance.pawn.def, out MorphDef def))
            {
                if (thing.def.ingestible == null)
                {
                    return(true);
                }

                FoodTypeFlags flg = thing.def.ingestible.foodType & (FoodTypeFlags.Tree | FoodTypeFlags.Plant);
                if (flg != 0)
                {
                    __result = new[]
                    {
                        ReserveFoodIfWillIngestWholeStack(__instance),
                        Toils_Goto.GotoThing(TargetIndex.A, PathEndMode.Touch)
                    };

                    return(false);
                }
            }
            else if (__instance.pawn.IsSapientFormerHuman())
            {
                if (thing.def.ingestible == null)
                {
                    return(true);
                }
            }

            return(true);
        }
Example #5
0
        public IngestiblePropertiesStats(IngestibleProperties p)
        {
            this.maxNumToIngestAtOnce = p.maxNumToIngestAtOnce;
            this.baseIngestTicks      = p.baseIngestTicks;
            this.chairSearchRadius    = p.chairSearchRadius;
            this.useEatingSpeedStat   = p.useEatingSpeedStat;
            //this.ingestCommandString = p.ingestCommandString;
            //this.ingestReportString = p.ingestReportString;
            //this.ingestReportStringEat = p.ingestReportStringEat;
            this.ingestHoldUsesTable = p.ingestHoldUsesTable;
            this.foodType            = p.foodType;
            this.joy           = p.joy;
            this.preferability = p.preferability;
            this.nurseable     = p.nurseable;
            this.optimalityOffsetHumanlikes     = p.optimalityOffsetHumanlikes;
            this.optimalityOffsetFeedingAnimals = p.optimalityOffsetFeedingAnimals;
            this.drugCategory = p.drugCategory;

            if (p.ingestHoldOffsetStanding != null)
            {
                this.ingestHoldOffsetStanding = new HoldOffsetSetStats(p.ingestHoldOffsetStanding);
            }

            //Util.AssignDefStat(p.parent, out this.parent);
            Util.AssignDefStat(p.joyKind, out this.joyKind);
            Util.AssignDefStat(p.sourceDef, out this.sourceDef);
            Util.AssignDefStat(p.tasteThought, out this.tasteThought);
            Util.AssignDefStat(p.specialThoughtDirect, out this.specialThoughtDirect);
            Util.AssignDefStat(p.specialThoughtAsIngredient, out this.specialThoughtAsIngredient);
            Util.AssignDefStat(p.ingestEffect, out this.ingestEffect);
            Util.AssignDefStat(p.ingestEffectEat, out this.ingestEffectEat);
            Util.AssignDefStat(p.ingestSound, out this.ingestSound);
        }
 public bool Eats(FoodTypeFlags food)
 {
     if (!this.EatsFood)
     {
         return(false);
     }
     return((this.foodType & food) != FoodTypeFlags.None);
 }
Example #7
0
 public bool Eats(FoodTypeFlags food)
 {
     if (!EatsFood)
     {
         return(false);
     }
     return((foodType & food) != 0);
 }
Example #8
0
        public static bool IsNonPerishable(ThingDef def)
        {
            var ing = def.ingestible;

            if (ing != null)
            {
                FoodTypeFlags types = FoodTypeFlags.Meal | FoodTypeFlags.Processed;
                if ((ing.foodType & types) != FoodTypeFlags.None)
                {
                    CompProperties_Rottable rot = def.GetCompProperties <CompProperties_Rottable>();
                    if (rot == null || rot.daysToRotStart > 25)
                    {
                        return(true);
                    }
                }
            }
            return(false);
        }
Example #9
0
        // There might be a cleaner way to do what looks like a deep neural network.
        private static FoodCategory _DetermineFoodCategory(ThingDef def)
        {
            var array = Enum.GetValues(typeof(FoodCategory));

            var CategoryScores = new Dictionary <FoodCategory, float>(array.Length);

            foreach (FoodCategory entry in array)
            {
                CategoryScores.Add(entry, 0f);
            }

            if (def == ThingDefOf.NutrientPasteDispenser)
            {
                return(FoodCategory.MealAwful);
            }

            if (def.race != null)
            {
                CategoryScores[FoodCategory.Hunt] = float.MaxValue;
            }

            if (def.ingestible != null)
            {
                if (def.ingestible.nutrition <= 0f || def.IsDrug)
                {
                    CategoryScores[FoodCategory.Ignore] = float.MaxValue;
                }

                FoodPreferability foodPref = def.ingestible.preferability;
                FoodTypeFlags     foodType = def.ingestible.foodType;

                string defName = def.defName;

                switch (foodPref)
                {
                case FoodPreferability.MealFine:
                    CategoryScores[FoodCategory.MealFine] += 100f;
                    break;

                case FoodPreferability.MealAwful:
                    CategoryScores[FoodCategory.MealAwful] += 100f;
                    break;

                case FoodPreferability.MealSimple:
                    CategoryScores[FoodCategory.MealSimple] += 100f;
                    break;

                case FoodPreferability.MealLavish:
                    CategoryScores[FoodCategory.MealLavish] += 100f;
                    break;
                }

                if (!def.HasComp(typeof(CompRottable)) && (foodType & FoodTypeFlags.Meal) != 0)
                {
                    CategoryScores[FoodCategory.MealSurvival] += 150f;
                }

                if ((foodType & FoodTypeFlags.Kibble) != 0)
                {
                    CategoryScores[FoodCategory.Kibble] += 200f;
                }

                if ((foodType & FoodTypeFlags.AnimalProduct) != 0)
                {
                    if (def.GetCompProperties <CompProperties_Hatcher>() != null)
                    {
                        CategoryScores[FoodCategory.FertEggs] += 500f;
                    }

                    //return WMFoodPref.Null;
                }

                if (def.ingestible.joyKind == JoyKindDefOf.Gluttonous && def.ingestible.joy >= 0.05f)
                {
                    CategoryScores[FoodCategory.Luxury] += 500f;
                }

                if ((foodType & FoodTypeFlags.Tree) != 0)
                {
                    CategoryScores[FoodCategory.Tree] += 500f;
                }

                if ((foodType & FoodTypeFlags.Plant) != 0)
                {
                    if (def.plant == null)
                    {
                        CategoryScores[FoodCategory.Hay] += 100f;
                    }
                    else
                    {
                        if (def.plant.sowTags != null && def.plant.sowTags.Any())
                        {
                            CategoryScores[FoodCategory.Plant] += 100f;
                        }
                        else
                        {
                            CategoryScores[FoodCategory.Grass] += 50f;
                        }

                        if (def.plant.harvestedThingDef != null)
                        {
                            CategoryScores[FoodCategory.Plant] += 200f;
                        }

                        if (def.plant.reproduces)
                        {
                            CategoryScores[FoodCategory.Grass] += 100f;
                        }
                    }
                }

                if (RimWorld.FoodUtility.IsHumanlikeMeat(def))
                {
                    CategoryScores[FoodCategory.RawHuman]        += 50f;
                    CategoryScores[FoodCategory.HumanlikeCorpse] += 50f;
                }

                if (def.IsCorpse)
                {
                    CategoryScores[FoodCategory.Corpse]          += 80f;
                    CategoryScores[FoodCategory.HumanlikeCorpse] += 50f;
                    CategoryScores[FoodCategory.InsectCorpse]    += 50f;

                    if (def.FirstThingCategory == ThingCategoryDefOf.CorpsesInsect)
                    {
                        CategoryScores[FoodCategory.InsectCorpse] += 50f;
                    }

                    if (def.ingestible.sourceDef.race.IsMechanoid)
                    {
                        CategoryScores[FoodCategory.Ignore] = float.MaxValue;
                    }
                }

                if (def.ingestible.tasteThought != null && def.ingestible.tasteThought.stages.All((ThoughtStage arg) => arg.baseMoodEffect < 0))
                {
                    //if (def == ThingDef.Named("Megaspider_Meat"))
                    if (def.ingestible.tasteThought == ThoughtDefOf.AteInsectMeatDirect)
                    {
                        CategoryScores[FoodCategory.InsectCorpse] += 50f;
                        CategoryScores[FoodCategory.RawInsect]    += 50f;
                    }
                    CategoryScores[FoodCategory.RawHuman] += 20f;
                    CategoryScores[FoodCategory.RawBad]   += 50f;
                }

                if ((def.ingestible.tasteThought == null || def.ingestible.tasteThought.stages.All((ThoughtStage arg) => arg.baseMoodEffect >= 0)))
                {
                    CategoryScores[FoodCategory.RawTasty] += 20f;
                }

                //if ((foodType & FoodTypeFlags.AnimalProduct) != 0)

                //	CategoryScores[FoodCategory.AnimalProduct] += 30f;

                if (foodPref == FoodPreferability.NeverForNutrition || def.IsDrug)
                {
                    CategoryScores[FoodCategory.Ignore] = float.MaxValue;
                }
            }

            // non ingestible corpse ?
            //if (def.IsCorpse)
            //	return FoodCategory.Ignore;

            var winner = CategoryScores.MaxBy(arg => arg.Value);

            var similar = CategoryScores.Where(arg => Mathf.Abs(arg.Value - winner.Value) < 10f);

            if (similar.Count() > 1)
            {
                Log.Warning("I'm not sure if " + def + " belongs to " + winner + " since others have similar scores: " + String.Join(" ; ", similar.Select(arg => arg.ToString()).ToArray()));
            }
            return(winner.Key);
        }
        public static string ToHumanString(this FoodTypeFlags ft)
        {
            string text = "";

            if ((ft & FoodTypeFlags.VegetableOrFruit) != 0)
            {
                text += "FoodTypeFlags_VegetableOrFruit".Translate();
            }
            if ((ft & FoodTypeFlags.Meat) != 0)
            {
                if (text.Length > 0)
                {
                    text += ", ";
                }
                text += "FoodTypeFlags_Meat".Translate();
            }
            if ((ft & FoodTypeFlags.Corpse) != 0)
            {
                if (text.Length > 0)
                {
                    text += ", ";
                }
                text += "FoodTypeFlags_Corpse".Translate();
            }
            if ((ft & FoodTypeFlags.Seed) != 0)
            {
                if (text.Length > 0)
                {
                    text += ", ";
                }
                text += "FoodTypeFlags_Seed".Translate();
            }
            if ((ft & FoodTypeFlags.AnimalProduct) != 0)
            {
                if (text.Length > 0)
                {
                    text += ", ";
                }
                text += "FoodTypeFlags_AnimalProduct".Translate();
            }
            if ((ft & FoodTypeFlags.Plant) != 0)
            {
                if (text.Length > 0)
                {
                    text += ", ";
                }
                text += "FoodTypeFlags_Plant".Translate();
            }
            if ((ft & FoodTypeFlags.Tree) != 0)
            {
                if (text.Length > 0)
                {
                    text += ", ";
                }
                text += "FoodTypeFlags_Tree".Translate();
            }
            if ((ft & FoodTypeFlags.Meal) != 0)
            {
                if (text.Length > 0)
                {
                    text += ", ";
                }
                text += "FoodTypeFlags_Meal".Translate();
            }
            if ((ft & FoodTypeFlags.Processed) != 0)
            {
                if (text.Length > 0)
                {
                    text += ", ";
                }
                text += "FoodTypeFlags_Processed".Translate();
            }
            if ((ft & FoodTypeFlags.Liquor) != 0)
            {
                if (text.Length > 0)
                {
                    text += ", ";
                }
                text += "FoodTypeFlags_Liquor".Translate();
            }
            if ((ft & FoodTypeFlags.Kibble) != 0)
            {
                if (text.Length > 0)
                {
                    text += ", ";
                }
                text += "FoodTypeFlags_Kibble".Translate();
            }
            return(text);
        }
Example #11
0
 public bool Eats(FoodTypeFlags food)
 {
     return(this.EatsFood && (this.foodType & food) != FoodTypeFlags.None);
 }
Example #12
0
 static FoodTypeFlags GenerateFoodFlags(FoodTypeFlags animalFlags)
 {
     animalFlags |= FoodTypeFlags.Meal; //make sure all hybrids can eat meals
                                        //need to figure out a way to let them graze but not pick up plants
     return(animalFlags);
 }
        private static FoodCategory _DetermineFoodCategory(ThingDef def)
        {
            // List Nutrient Paste Dispenser as an Awful meal source
            if (def == ThingDefOf.NutrientPasteDispenser)
            {
                return(FoodCategory.MealAwful);
            }

            // List all foods with a race as huntable
            if (def.race != null)
            {
                return(FoodCategory.Hunt);
            }

            if (def.ingestible != null)
            {
                //if food has no nutritional value or is a drug ignore it
                if (def.ingestible.CachedNutrition <= 0f || def.IsDrug)
                {
                    return(FoodCategory.Ignore);
                }

                FoodPreferability foodPref = def.ingestible.preferability;
                FoodTypeFlags     foodType = def.ingestible.foodType;

                if (foodPref == FoodPreferability.MealFine)
                {
                    return(FoodCategory.MealFine);
                }

                if (foodPref == FoodPreferability.MealAwful)
                {
                    return(FoodCategory.MealAwful);
                }

                //if (foodPref == FoodPreferability.MealSimple)
                //	return FoodCategory.MealSimple;

                if (foodPref == FoodPreferability.MealSimple)
                {
                    if (def.defName == "Pemmican" || def.defName == "MealSurvivalPack")
                    {
                        return(FoodCategory.MealSurvival);
                    }

                    return(FoodCategory.MealSimple);
                }

                if (foodPref == FoodPreferability.MealLavish)
                {
                    return(FoodCategory.MealLavish);
                }

                if ((foodType & FoodTypeFlags.Kibble) != 0)
                {
                    return(FoodCategory.Kibble);
                }

                if ((foodType & FoodTypeFlags.AnimalProduct) != 0)
                {
                    if (def.GetCompProperties <CompProperties_Hatcher>() != null)
                    {
                        return(FoodCategory.FertEggs);
                    }

                    //return WMFoodPref.Null;
                }

                if (def.ingestible.joyKind == JoyKindDefOf.Gluttonous && def.ingestible.joy >= 0.05f)
                {
                    return(FoodCategory.Luxury);
                }

                if ((foodType & FoodTypeFlags.Tree) != 0)
                {
                    return(FoodCategory.Tree);
                }

                if ((foodType & FoodTypeFlags.Plant) != 0)
                {
                    if (def == ThingDefOf.Hay)
                    {
                        return(FoodCategory.Hay);
                    }

                    if (def == ThingDef.Named("Plant_TallGrass") || def == ThingDef.Named("Plant_Grass"))
                    {
                        return(FoodCategory.Grass);
                    }

                    return(FoodCategory.Plant);
                }

                if (def.IsCorpse)
                {
                    if (RimWorld.FoodUtility.IsHumanlikeMeat(def))
                    {
                        return(FoodCategory.HumanlikeCorpse);
                    }

                    //TODO: Make more reliable
                    if (def.ingestible.sourceDef.race.Animal)
                    {
                        if (def.FirstThingCategory == ThingCategoryDefOf.CorpsesInsect)
                        {
                            return(FoodCategory.InsectCorpse);
                        }

                        return(FoodCategory.Corpse);
                    }

                    if (def.ingestible.sourceDef.race.IsMechanoid)
                    {
                        return(FoodCategory.Ignore);
                    }
                }

                if (def.ingestible.tasteThought != null && def.ingestible.tasteThought.stages.All((ThoughtStage arg) => arg.baseMoodEffect < 0))
                {
                    if (RimWorld.FoodUtility.IsHumanlikeMeat(def))
                    {
                        return(FoodCategory.RawHuman);
                    }

                    if (def == ThingDef.Named("Meat_Megaspider"))
                    {
                        //if (def.ingestible.tasteThought == ThoughtDefOf.AteInsectMeatAsIngredient)
                        return(FoodCategory.RawInsect);
                    }

                    return(FoodCategory.RawBad);
                }

                if ((def.ingestible.tasteThought == null || def.ingestible.tasteThought.stages.All((ThoughtStage arg) => arg.baseMoodEffect >= 0)))
                {
                    return(FoodCategory.RawTasty);
                }

                if ((foodType & FoodTypeFlags.AnimalProduct) != 0)
                {
                    return(FoodCategory.AnimalProduct);
                }

                if (foodPref == FoodPreferability.NeverForNutrition || def.IsDrug)
                {
                    return(FoodCategory.Ignore);
                }
            }

            // non ingestible corpse ?
            if (def.IsCorpse)
            {
                return(FoodCategory.Ignore);
            }

            return(FoodCategory.Null);
        }
        private static FoodCategory DetermineFoodCategory(ThingDef def)
        {
            if (def == null)
            {
                throw new ArgumentNullException(nameof(def));
            }

            // List all foods with a race as huntable
            if (def.race != null)
            {
                return(FoodCategory.Hunt);
            }

            if (def.ingestible != null)
            {
                // If food has no nutritional value or is a drug ignore it
                if (def.ingestible.CachedNutrition <= 0f || def.IsDrug)
                {
                    return(FoodCategory.Ignore);
                }

                FoodPreferability foodPref = def.ingestible.preferability;
                FoodTypeFlags     foodType = def.ingestible.foodType;

                if (foodPref == FoodPreferability.NeverForNutrition)
                {
                    return(FoodCategory.Ignore);
                }

                if (foodPref == FoodPreferability.MealFine)
                {
                    return(FoodCategory.MealFine);
                }

                if (foodPref == FoodPreferability.MealAwful)
                {
                    return(FoodCategory.MealAwful);
                }

                if (foodPref == FoodPreferability.MealSimple)
                {
                    return((def == ThingDefOf.MealSurvivalPack || def == ThingDefOf.Pemmican) ? FoodCategory.MealSurvival : FoodCategory.MealSimple);
                }

                if (foodPref == FoodPreferability.MealLavish)
                {
                    return(FoodCategory.MealLavish);
                }

                if ((foodType & FoodTypeFlags.Kibble) != 0)
                {
                    return(FoodCategory.Kibble);
                }

                if ((foodType & FoodTypeFlags.AnimalProduct) != 0)
                {
                    if (def.GetCompProperties <CompProperties_Hatcher>() != null)
                    {
                        return(FoodCategory.FertEggs);
                    }

                    return(FoodCategory.AnimalProduct);
                }

                if (def.ingestible.joyKind == JoyKindDefOf.Gluttonous && def.ingestible.joy >= 0.05f)
                {
                    return(FoodCategory.Luxury);
                }

                if ((foodType & FoodTypeFlags.Tree) != 0)
                {
                    return(FoodCategory.Tree);
                }

                if ((foodType & FoodTypeFlags.Plant) != 0)
                {
                    if (def == ThingDefOf.Hay)
                    {
                        return(FoodCategory.Hay);
                    }

                    if (def.plant != null && !def.plant.sowTags.NullOrEmpty())
                    {
                        return(FoodCategory.Plant);
                    }

                    if (def.thingCategories?.Contains(ThingCategoryDefOf.PlantMatter) ?? false)
                    {
                        return(FoodCategory.PlantMatter);
                    }

                    if (foodPref == FoodPreferability.DesperateOnly)
                    {
                        return(FoodCategory.Ignore);
                    }

                    return(FoodCategory.Grass);
                }

                if (def.IsCorpse)
                {
                    if (RimWorld.FoodUtility.IsHumanlikeMeat(def))
                    {
                        return(FoodCategory.HumanlikeCorpse);
                    }

                    if (def.FirstThingCategory == ThingCategoryDefOf.CorpsesInsect)
                    {
                        return(FoodCategory.InsectCorpse);
                    }

                    if (def.ingestible?.sourceDef?.race?.IsMechanoid ?? false)
                    {
                        return(FoodCategory.Ignore);
                    }

                    return(FoodCategory.Corpse);
                }

                if (def.ingestible.tasteThought != null && def.ingestible.tasteThought.stages.All((ThoughtStage arg) => arg.baseMoodEffect < 0))
                {
                    if (RimWorld.FoodUtility.IsHumanlikeMeat(def))
                    {
                        return(FoodCategory.RawHuman);
                    }

                    if (def == ThingDef.Named("Meat_Megaspider") || def.ingestible.tasteThought == ThoughtDefOf.AteInsectMeatAsIngredient)
                    {
                        return(FoodCategory.RawInsect);
                    }

                    return(FoodCategory.RawBad);
                }

                if ((def.ingestible.tasteThought == null || def.ingestible.tasteThought.stages.All((ThoughtStage arg) => arg.baseMoodEffect >= 0)))
                {
                    return(FoodCategory.RawTasty);
                }
            }

            // non ingestible corpse ?
            if (def.IsCorpse)
            {
                return(FoodCategory.Ignore);
            }

            return(FoodCategory.Null);
        }
Example #15
0
        public RacePropertiesStats(RaceProperties p)
        {
            this.intelligence              = p.intelligence;
            this.hasGenders                = p.hasGenders;
            this.needsRest                 = p.needsRest;
            this.nameCategory              = p.nameCategory;
            this.foodType                  = p.foodType;
            this.makesFootprints           = p.makesFootprints;
            this.executionRange            = p.executionRange;
            this.lifeExpectancy            = p.lifeExpectancy;
            this.herdAnimal                = p.herdAnimal;
            this.packAnimal                = p.packAnimal;
            this.predator                  = p.predator;
            this.maxPreyBodySize           = p.maxPreyBodySize;
            this.wildness                  = p.wildness;
            this.petness                   = p.petness;
            this.nuzzleMtbHours            = p.nuzzleMtbHours;
            this.manhunterOnDamageChance   = p.manhunterOnDamageChance;
            this.manhunterOnTameFailChance = p.manhunterOnTameFailChance;
            this.canBePredatorPrey         = p.canBePredatorPrey;
            this.herdMigrationAllowed      = p.herdMigrationAllowed;
            this.gestationPeriodDays       = p.gestationPeriodDays;
            this.mateMtbHours              = p.mateMtbHours;
            this.nameOnTameChance          = p.nameOnTameChance;
            //this.nameOnNuzzleChance = p.nameOnNuzzleChance;
            this.baseBodySize    = p.baseBodySize;
            this.baseHealthScale = p.baseHealthScale;
            this.baseHungerRate  = p.baseHungerRate;
            this.meatLabel       = p.meatLabel;
            this.meatMarketValue = p.meatMarketValue;

            this.meatColor = new ColorStats(p.meatColor);
            if (p.specialShadowData != null)
            {
                this.specialShadowData = new ShadowDataStats(p.specialShadowData);
            }
            if (p.soundCallIntervalRange != null)
            {
                this.soundCallIntervalRange = new MinMaxIntStats(p.soundCallIntervalRange);
            }
            if (p.ageGenerationCurve != null)
            {
                this.ageGenerationCurve = new SimpleCurveStats(p.ageGenerationCurve);
            }
            if (p.litterSizeCurve != null)
            {
                this.litterSizeCurve = new SimpleCurveStats(p.litterSizeCurve);
            }

            Util.Populate(out this.wildBiomes, p.wildBiomes, (v) => new FloatValueDefStat <BiomeDef>(v.biome, v.commonality));
            Util.Populate(out this.lifeStageAges, p.lifeStageAges, (v) => new LifeStageAgeStats(v));
            Util.Populate(out this.untrainableTags, p.untrainableTags);
            Util.Populate(out this.trainableTags, p.trainableTags);

            Util.AssignDefStat(GetFleshType(p), out this.fleshType);
            Util.AssignDefStat(GetBloodDef(p), out this.bloodDef);
            Util.AssignDefStat(p.thinkTreeMain, out this.thinkTreeMain);
            Util.AssignDefStat(p.thinkTreeConstant, out this.thinkTreeConstant);
            Util.AssignDefStat(p.body, out this.body);
            Util.AssignDefStat(p.trainability, out this.trainability);
            Util.AssignDefStat(GetNameGenerator(p), out this.nameGenerator);
            Util.AssignDefStat(GetNameGeneratorFemale(p), out this.nameGeneratorFemale);
            Util.AssignDefStat(p.useMeatFrom, out this.useMeatFrom);
            Util.AssignDefStat(p.useLeatherFrom, out this.useLeatherFrom);
            Util.AssignDefStat(p.leatherDef, out this.leatherDef);
            Util.AssignDefStat(p.soundMeleeHitPawn, out this.soundMeleeHitPawn);
            Util.AssignDefStat(p.soundMeleeHitBuilding, out this.soundMeleeHitBuilding);
            Util.AssignDefStat(p.soundMeleeMiss, out this.soundMeleeMiss);
            Util.AssignDefStat(p.meatDef, out this.meatDef);
            Util.AssignDefStat(p.corpseDef, out this.corpseDef);

            this.hediffGiverSets = Util.CreateDefStatList(p.hediffGiverSets);
        }