static bool Prefix()
        {
            //return true;
            Type TPlant = typeof(Plant);
            IEnumerable <ThingDef> list = DefDatabase <ThingDef> .AllDefsListForReading.Where(x => (x.IsIngestible && !x.IsWithinCategory(ThingCategoryDefOf.Foods) /*(x.thingClass == TPlant || x.thingClass.IsSubclassOf(TPlant) || !x.IsWithinCategory(ThingCategoryDefOf.Foods))*/));

            foreach (var i in list)
            {
                if (i.plant != null && i.ingestible.foodType == FoodTypeFlags.Tree)
                {
                    if (i.thingCategories == null)
                    {
                        i.thingCategories = new List <ThingCategoryDef>();
                        DirectXmlCrossRefLoader.RegisterListWantsCrossRef(i.thingCategories, AnimalControlsDefOf.Trees.defName, i, null);
                    }
                    else if (i.thingCategories.Replace(AnimalControlsDefOf.Plants, AnimalControlsDefOf.Trees) == 0)
                    {
                        i.thingCategories.Add(AnimalControlsDefOf.Trees);
                    }
                }
                else if (i.plant != null && i.plant.Sowable)
                {
                    if (i.thingCategories == null)
                    {
                        i.thingCategories = new List <ThingCategoryDef>();
                        DirectXmlCrossRefLoader.RegisterListWantsCrossRef(i.thingCategories, AnimalControlsDefOf.Crops.defName, i, null);
                    }
                    else if (i.thingCategories.Replace(AnimalControlsDefOf.Plants, AnimalControlsDefOf.Crops) == 0)
                    {
                        i.thingCategories.Add(AnimalControlsDefOf.Crops);
                    }
                }
                else if (i.plant != null && i.ingestible.foodType == FoodTypeFlags.Plant)
                {
                    if (i.thingCategories == null)
                    {
                        i.thingCategories = new List <ThingCategoryDef>();
                        DirectXmlCrossRefLoader.RegisterListWantsCrossRef(i.thingCategories, AnimalControlsDefOf.Plants.defName, i, null);
                    }
                }
                //else
                //{
                //    if (i.thingCategories == null)
                //    {
                //        i.thingCategories = new List<ThingCategoryDef>();
                //        DirectXmlCrossRefLoader.RegisterListWantsCrossRef(i.thingCategories, AnimalControlsDefOf.OtherEdible.defName, i, null);
                //    }
                //    else
                //        i.thingCategories.Add(AnimalControlsDefOf.OtherEdible);
                //}
            }

            return(true);
        }
        public static IEnumerable <ThingDef> ImpliedLeatherDefs()
        {
            int numLeathers = DefDatabase <ThingDef> .AllDefs.Where(new Func <ThingDef, bool>(ThingDefGenerator_Leather.GeneratesLeather)).Count <ThingDef>();

            float eachLeatherCommonality = 1f / (float)numLeathers;

            foreach (ThingDef sourceDef in DefDatabase <ThingDef> .AllDefs.ToList <ThingDef>())
            {
                if (ThingDefGenerator_Leather.GeneratesLeather(sourceDef))
                {
                    if (sourceDef.race.useLeatherFrom == null)
                    {
                        ThingDef d = new ThingDef();
                        d.resourceReadoutPriority = ResourceCountPriority.Middle;
                        d.category    = ThingCategory.Item;
                        d.thingClass  = typeof(ThingWithComps);
                        d.graphicData = new GraphicData();
                        d.graphicData.graphicClass = typeof(Graphic_Single);
                        d.useHitPoints             = true;
                        d.selectable = true;
                        d.SetStatBaseValue(StatDefOf.MaxHitPoints, 100f);
                        d.altitudeLayer = AltitudeLayer.Item;
                        d.stackLimit    = 75;
                        d.comps.Add(new CompProperties_Forbiddable());
                        d.SetStatBaseValue(StatDefOf.Beauty, -20f);
                        d.SetStatBaseValue(StatDefOf.DeteriorationRate, 2f);
                        d.alwaysHaulable = true;
                        d.drawGUIOverlay = true;
                        d.rotatable      = false;
                        d.pathCost       = 15;
                        d.category       = ThingCategory.Item;
                        d.description    = "LeatherDesc".Translate(new object[]
                        {
                            sourceDef.label
                        });
                        d.useHitPoints = true;
                        d.SetStatBaseValue(StatDefOf.MaxHitPoints, 60f);
                        d.SetStatBaseValue(StatDefOf.MarketValue, sourceDef.race.leatherMarketValueFactor * 2.1f);
                        d.SetStatBaseValue(StatDefOf.Mass, 0.03f);
                        d.SetStatBaseValue(StatDefOf.Flammability, 1f);
                        if (d.thingCategories == null)
                        {
                            d.thingCategories = new List <ThingCategoryDef>();
                        }
                        DirectXmlCrossRefLoader.RegisterListWantsCrossRef <ThingCategoryDef>(d.thingCategories, "Leathers");
                        d.graphicData.texPath = "Things/Item/Resource/Cloth";
                        d.stuffProps          = new StuffProperties();
                        DirectXmlCrossRefLoader.RegisterListWantsCrossRef <StuffCategoryDef>(d.stuffProps.categories, "Leathery");
                        StatUtility.SetStatValueInList(ref d.stuffProps.statFactors, StatDefOf.MarketValue, 1.3f);
                        StatUtility.SetStatValueInList(ref d.stuffProps.statFactors, StatDefOf.ArmorRating_Blunt, 1.5f);
                        StatUtility.SetStatValueInList(ref d.stuffProps.statFactors, StatDefOf.ArmorRating_Sharp, 1.5f);
                        StatUtility.SetStatValueInList(ref d.stuffProps.statFactors, StatDefOf.ArmorRating_Heat, 1.7f);
                        StatUtility.SetStatValueInList(ref d.stuffProps.statFactors, StatDefOf.ArmorRating_Electric, 4f);
                        d.defName = sourceDef.defName + "_Leather";
                        if (!sourceDef.race.leatherLabel.NullOrEmpty())
                        {
                            d.label = sourceDef.race.leatherLabel;
                        }
                        else
                        {
                            d.label = "LeatherLabel".Translate(new object[]
                            {
                                sourceDef.label
                            });
                        }
                        d.stuffProps.color       = sourceDef.race.leatherColor;
                        d.graphicData.color      = sourceDef.race.leatherColor;
                        d.graphicData.colorTwo   = sourceDef.race.leatherColor;
                        d.stuffProps.commonality = 1.2f * eachLeatherCommonality * sourceDef.race.leatherCommonalityFactor;
                        StatUtility.SetStatValueInList(ref d.stuffProps.statFactors, StatDefOf.Insulation_Cold, sourceDef.race.leatherInsulation);
                        StatUtility.SetStatValueInList(ref d.stuffProps.statFactors, StatDefOf.Insulation_Heat, sourceDef.race.leatherInsulation);
                        List <StatModifier> sfos = sourceDef.race.leatherStatFactors;
                        if (sfos != null)
                        {
                            foreach (StatModifier current in sfos)
                            {
                                StatUtility.SetStatValueInList(ref d.stuffProps.statFactors, current.stat, current.value);
                            }
                        }
                        sourceDef.race.leatherDef = d;
                        yield return(d);
                    }
                }
            }
        }
Exemple #3
0
 // Token: 0x060034E5 RID: 13541 RVA: 0x00121E03 File Offset: 0x00120003
 public static IEnumerable <ThingDef> ImpliedCorpseDefs()
 {
     foreach (ThingDef thingDef in DefDatabase <ThingDef> .AllDefs.ToList <ThingDef>())
     {
         if (thingDef.category == ThingCategory.Pawn)
         {
             ThingDef thingDef2 = new ThingDef();
             thingDef2.category            = ThingCategory.Item;
             thingDef2.thingClass          = typeof(Corpse);
             thingDef2.selectable          = true;
             thingDef2.tickerType          = TickerType.Rare;
             thingDef2.altitudeLayer       = AltitudeLayer.ItemImportant;
             thingDef2.scatterableOnMapGen = false;
             thingDef2.SetStatBaseValue(StatDefOf.Beauty, -50f);
             thingDef2.SetStatBaseValue(StatDefOf.DeteriorationRate, 1f);
             thingDef2.SetStatBaseValue(StatDefOf.FoodPoisonChanceFixedHuman, 0.05f);
             thingDef2.alwaysHaulable                = true;
             thingDef2.soundDrop                     = SoundDefOf.Corpse_Drop;
             thingDef2.pathCost                      = 15;
             thingDef2.socialPropernessMatters       = false;
             thingDef2.tradeability                  = Tradeability.None;
             thingDef2.messageOnDeteriorateInStorage = false;
             thingDef2.inspectorTabs                 = new List <Type>();
             thingDef2.inspectorTabs.Add(typeof(ITab_Pawn_Health));
             thingDef2.inspectorTabs.Add(typeof(ITab_Pawn_Character));
             thingDef2.inspectorTabs.Add(typeof(ITab_Pawn_Gear));
             thingDef2.inspectorTabs.Add(typeof(ITab_Pawn_Social));
             thingDef2.inspectorTabs.Add(typeof(ITab_Pawn_Log));
             thingDef2.comps.Add(new CompProperties_Forbiddable());
             thingDef2.recipes = new List <RecipeDef>();
             if (!thingDef.race.IsMechanoid)
             {
                 thingDef2.recipes.Add(RecipeDefOf.RemoveBodyPart);
             }
             thingDef2.defName            = "Corpse_" + thingDef.defName;
             thingDef2.label              = "CorpseLabel".Translate(thingDef.label);
             thingDef2.description        = "CorpseDesc".Translate(thingDef.label);
             thingDef2.soundImpactDefault = thingDef.soundImpactDefault;
             thingDef2.SetStatBaseValue(StatDefOf.MarketValue, ThingDefGenerator_Corpses.CalculateMarketValue(thingDef));
             thingDef2.SetStatBaseValue(StatDefOf.Flammability, thingDef.GetStatValueAbstract(StatDefOf.Flammability, null));
             thingDef2.SetStatBaseValue(StatDefOf.MaxHitPoints, (float)thingDef.BaseMaxHitPoints);
             thingDef2.SetStatBaseValue(StatDefOf.Mass, thingDef.statBases.GetStatOffsetFromList(StatDefOf.Mass));
             thingDef2.SetStatBaseValue(StatDefOf.Nutrition, 5.2f);
             thingDef2.modContentPack    = thingDef.modContentPack;
             thingDef2.ingestible        = new IngestibleProperties();
             thingDef2.ingestible.parent = thingDef2;
             IngestibleProperties ingestible = thingDef2.ingestible;
             ingestible.foodType      = FoodTypeFlags.Corpse;
             ingestible.sourceDef     = thingDef;
             ingestible.preferability = (thingDef.race.IsFlesh ? FoodPreferability.DesperateOnly : FoodPreferability.NeverForNutrition);
             DirectXmlCrossRefLoader.RegisterObjectWantsCrossRef(ingestible, "tasteThought", ThoughtDefOf.AteCorpse.defName, null, null);
             ingestible.maxNumToIngestAtOnce = 1;
             ingestible.ingestEffect         = EffecterDefOf.EatMeat;
             ingestible.ingestSound          = SoundDefOf.RawMeat_Eat;
             ingestible.specialThoughtDirect = thingDef.race.FleshType.ateDirect;
             if (thingDef.race.IsFlesh)
             {
                 CompProperties_Rottable compProperties_Rottable = new CompProperties_Rottable();
                 compProperties_Rottable.daysToRotStart         = 2.5f;
                 compProperties_Rottable.daysToDessicated       = 5f;
                 compProperties_Rottable.rotDamagePerDay        = 2f;
                 compProperties_Rottable.dessicatedDamagePerDay = 0.7f;
                 thingDef2.comps.Add(compProperties_Rottable);
                 CompProperties_SpawnerFilth compProperties_SpawnerFilth = new CompProperties_SpawnerFilth();
                 compProperties_SpawnerFilth.filthDef          = ThingDefOf.Filth_CorpseBile;
                 compProperties_SpawnerFilth.spawnCountOnSpawn = 0;
                 compProperties_SpawnerFilth.spawnMtbHours     = 0f;
                 compProperties_SpawnerFilth.spawnRadius       = 0.1f;
                 compProperties_SpawnerFilth.spawnEveryDays    = 1f;
                 compProperties_SpawnerFilth.requiredRotStage  = new RotStage?(RotStage.Rotting);
                 thingDef2.comps.Add(compProperties_SpawnerFilth);
             }
             if (thingDef2.thingCategories == null)
             {
                 thingDef2.thingCategories = new List <ThingCategoryDef>();
             }
             if (thingDef.race.Humanlike)
             {
                 DirectXmlCrossRefLoader.RegisterListWantsCrossRef <ThingCategoryDef>(thingDef2.thingCategories, ThingCategoryDefOf.CorpsesHumanlike.defName, thingDef2, null);
             }
             else
             {
                 DirectXmlCrossRefLoader.RegisterListWantsCrossRef <ThingCategoryDef>(thingDef2.thingCategories, thingDef.race.FleshType.corpseCategory.defName, thingDef2, null);
             }
             thingDef.race.corpseDef = thingDef2;
             yield return(thingDef2);
         }
     }
     List <ThingDef> .Enumerator enumerator = default(List <ThingDef> .Enumerator);
     yield break;
     yield break;
 }
Exemple #4
0
        public static IEnumerable <ThingDef> ImpliedMeatDefs()
        {
            foreach (ThingDef item in DefDatabase <ThingDef> .AllDefs.ToList())
            {
                if (item.category == ThingCategory.Pawn && item.race.useMeatFrom == null)
                {
                    if (item.race.IsFlesh)
                    {
                        ThingDef d = new ThingDef();
                        d.resourceReadoutPriority = ResourceCountPriority.Middle;
                        d.category    = ThingCategory.Item;
                        d.thingClass  = typeof(ThingWithComps);
                        d.graphicData = new GraphicData();
                        d.graphicData.graphicClass = typeof(Graphic_StackCount);
                        d.useHitPoints             = true;
                        d.selectable = true;
                        d.SetStatBaseValue(StatDefOf.MaxHitPoints, 100f);
                        d.altitudeLayer = AltitudeLayer.Item;
                        d.stackLimit    = 75;
                        d.comps.Add(new CompProperties_Forbiddable());
                        CompProperties_Rottable rotProps = new CompProperties_Rottable
                        {
                            daysToRotStart = 2f,
                            rotDestroys    = true
                        };
                        d.comps.Add(rotProps);
                        d.tickerType = TickerType.Rare;
                        d.SetStatBaseValue(StatDefOf.Beauty, -4f);
                        d.alwaysHaulable          = true;
                        d.rotatable               = false;
                        d.pathCost                = 15;
                        d.drawGUIOverlay          = true;
                        d.socialPropernessMatters = true;
                        d.modContentPack          = item.modContentPack;
                        d.category                = ThingCategory.Item;
                        if (item.race.Humanlike)
                        {
                            d.description = "MeatHumanDesc".Translate(item.label);
                        }
                        else if (item.race.FleshType == FleshTypeDefOf.Insectoid)
                        {
                            d.description = "MeatInsectDesc".Translate(item.label);
                        }
                        else
                        {
                            d.description = "MeatDesc".Translate(item.label);
                        }
                        d.useHitPoints = true;
                        d.SetStatBaseValue(StatDefOf.MaxHitPoints, 60f);
                        d.SetStatBaseValue(StatDefOf.DeteriorationRate, 6f);
                        d.SetStatBaseValue(StatDefOf.Mass, 0.03f);
                        d.SetStatBaseValue(StatDefOf.Flammability, 0.5f);
                        d.SetStatBaseValue(StatDefOf.Nutrition, 0.05f);
                        d.SetStatBaseValue(StatDefOf.FoodPoisonChanceFixedHuman, 0.02f);
                        d.BaseMarketValue = item.race.meatMarketValue;
                        if (d.thingCategories == null)
                        {
                            d.thingCategories = new List <ThingCategoryDef>();
                        }
                        DirectXmlCrossRefLoader.RegisterListWantsCrossRef(d.thingCategories, "MeatRaw", d);
                        d.ingestible               = new IngestibleProperties();
                        d.ingestible.parent        = d;
                        d.ingestible.foodType      = FoodTypeFlags.Meat;
                        d.ingestible.preferability = FoodPreferability.RawBad;
                        DirectXmlCrossRefLoader.RegisterObjectWantsCrossRef(d.ingestible, "tasteThought", ThoughtDefOf.AteRawFood.defName);
                        d.ingestible.ingestEffect               = EffecterDefOf.EatMeat;
                        d.ingestible.ingestSound                = SoundDefOf.RawMeat_Eat;
                        d.ingestible.specialThoughtDirect       = item.race.FleshType.ateDirect;
                        d.ingestible.specialThoughtAsIngredient = item.race.FleshType.ateAsIngredient;
                        d.graphicData.color = item.race.meatColor;
                        if (item.race.Humanlike)
                        {
                            d.graphicData.texPath = "Things/Item/Resource/MeatFoodRaw/Meat_Human";
                        }
                        else if (item.race.FleshType == FleshTypeDefOf.Insectoid)
                        {
                            d.graphicData.texPath = "Things/Item/Resource/MeatFoodRaw/Meat_Insect";
                        }
                        else if (item.race.baseBodySize < 0.7f)
                        {
                            d.graphicData.texPath = "Things/Item/Resource/MeatFoodRaw/Meat_Small";
                        }
                        else
                        {
                            d.graphicData.texPath = "Things/Item/Resource/MeatFoodRaw/Meat_Big";
                        }
                        d.defName = "Meat_" + item.defName;
                        if (item.race.meatLabel.NullOrEmpty())
                        {
                            d.label = "MeatLabel".Translate(item.label);
                        }
                        else
                        {
                            d.label = item.race.meatLabel;
                        }
                        d.ingestible.sourceDef = item;
                        item.race.meatDef      = d;
                        yield return(d);

                        /*Error: Unable to find new state assignment for yield return*/;
                    }
                    DirectXmlCrossRefLoader.RegisterObjectWantsCrossRef(item.race, "meatDef", "Steel");
                }
            }
            yield break;
IL_066c:
            /*Error near IL_066d: Unexpected return in MoveNext()*/;
        }
            public bool MoveNext()
            {
                uint num = (uint)this.$PC;

                this.$PC = -1;
                bool flag = false;

                switch (num)
                {
                case 0u:
                    enumerator = DefDatabase <ThingDef> .AllDefs.ToList <ThingDef>().GetEnumerator();

                    num = 4294967293u;
                    break;

                case 1u:
                    break;

                default:
                    return(false);
                }
                try
                {
                    switch (num)
                    {
                    }
                    while (enumerator.MoveNext())
                    {
                        sourceDef = enumerator.Current;
                        if (sourceDef.category == ThingCategory.Pawn)
                        {
                            if (sourceDef.race.useMeatFrom == null)
                            {
                                if (sourceDef.race.IsFlesh)
                                {
                                    d = new ThingDef();
                                    d.resourceReadoutPriority = ResourceCountPriority.Middle;
                                    d.category    = ThingCategory.Item;
                                    d.thingClass  = typeof(ThingWithComps);
                                    d.graphicData = new GraphicData();
                                    d.graphicData.graphicClass = typeof(Graphic_Single);
                                    d.useHitPoints             = true;
                                    d.selectable = true;
                                    d.SetStatBaseValue(StatDefOf.MaxHitPoints, 100f);
                                    d.altitudeLayer = AltitudeLayer.Item;
                                    d.stackLimit    = 75;
                                    d.comps.Add(new CompProperties_Forbiddable());
                                    rotProps = new CompProperties_Rottable();
                                    rotProps.daysToRotStart = 2f;
                                    rotProps.rotDestroys    = true;
                                    d.comps.Add(rotProps);
                                    d.tickerType = TickerType.Rare;
                                    d.SetStatBaseValue(StatDefOf.Beauty, -4f);
                                    d.alwaysHaulable          = true;
                                    d.rotatable               = false;
                                    d.pathCost                = 15;
                                    d.drawGUIOverlay          = true;
                                    d.socialPropernessMatters = true;
                                    d.modContentPack          = sourceDef.modContentPack;
                                    d.category                = ThingCategory.Item;
                                    if (sourceDef.race.Humanlike)
                                    {
                                        d.description = "MeatHumanDesc".Translate(new object[]
                                        {
                                            sourceDef.label
                                        });
                                    }
                                    else if (sourceDef.race.FleshType == FleshTypeDefOf.Insectoid)
                                    {
                                        d.description = "MeatInsectDesc".Translate(new object[]
                                        {
                                            sourceDef.label
                                        });
                                    }
                                    else
                                    {
                                        d.description = "MeatDesc".Translate(new object[]
                                        {
                                            sourceDef.label
                                        });
                                    }
                                    d.useHitPoints = true;
                                    d.SetStatBaseValue(StatDefOf.MaxHitPoints, 60f);
                                    d.SetStatBaseValue(StatDefOf.DeteriorationRate, 6f);
                                    d.SetStatBaseValue(StatDefOf.Mass, 0.03f);
                                    d.SetStatBaseValue(StatDefOf.Flammability, 0.5f);
                                    d.SetStatBaseValue(StatDefOf.Nutrition, 0.05f);
                                    d.SetStatBaseValue(StatDefOf.FoodPoisonChanceFixedHuman, 0.02f);
                                    d.BaseMarketValue = sourceDef.race.meatMarketValue;
                                    if (d.thingCategories == null)
                                    {
                                        d.thingCategories = new List <ThingCategoryDef>();
                                    }
                                    DirectXmlCrossRefLoader.RegisterListWantsCrossRef <ThingCategoryDef>(d.thingCategories, "MeatRaw", d);
                                    d.ingestible               = new IngestibleProperties();
                                    d.ingestible.parent        = d;
                                    d.ingestible.foodType      = FoodTypeFlags.Meat;
                                    d.ingestible.preferability = FoodPreferability.RawBad;
                                    DirectXmlCrossRefLoader.RegisterObjectWantsCrossRef(d.ingestible, "tasteThought", ThoughtDefOf.AteRawFood.defName);
                                    d.ingestible.ingestEffect               = EffecterDefOf.EatMeat;
                                    d.ingestible.ingestSound                = SoundDefOf.RawMeat_Eat;
                                    d.ingestible.specialThoughtDirect       = sourceDef.race.FleshType.ateDirect;
                                    d.ingestible.specialThoughtAsIngredient = sourceDef.race.FleshType.ateAsIngredient;
                                    if (sourceDef.race.Humanlike)
                                    {
                                        d.graphicData.texPath = "Things/Item/Resource/MeatFoodRaw/MeatHuman";
                                    }
                                    else
                                    {
                                        if (sourceDef.race.baseBodySize < 0.7f)
                                        {
                                            d.graphicData.texPath = "Things/Item/Resource/MeatFoodRaw/MeatSmall";
                                        }
                                        else
                                        {
                                            d.graphicData.texPath = "Things/Item/Resource/MeatFoodRaw/MeatBig";
                                        }
                                        d.graphicData.color = sourceDef.race.meatColor;
                                    }
                                    d.defName = "Meat_" + sourceDef.defName;
                                    if (sourceDef.race.meatLabel.NullOrEmpty())
                                    {
                                        d.label = "MeatLabel".Translate(new object[]
                                        {
                                            sourceDef.label
                                        });
                                    }
                                    else
                                    {
                                        d.label = sourceDef.race.meatLabel;
                                    }
                                    d.ingestible.sourceDef = sourceDef;
                                    sourceDef.race.meatDef = d;
                                    this.$current          = d;
                                    if (!this.$disposing)
                                    {
                                        this.$PC = 1;
                                    }
                                    flag = true;
                                    return(true);
                                }
                                DirectXmlCrossRefLoader.RegisterObjectWantsCrossRef(sourceDef.race, "meatDef", "Steel");
                            }
                        }
                    }
                }
                finally
                {
                    if (!flag)
                    {
                        ((IDisposable)enumerator).Dispose();
                    }
                }
                this.$PC = -1;
                return(false);
            }
            public bool MoveNext()
            {
                uint num = (uint)this.$PC;

                this.$PC = -1;
                bool flag = false;

                switch (num)
                {
                case 0u:
                    enumerator = DefDatabase <ThingDef> .AllDefs.ToList <ThingDef>().GetEnumerator();

                    num = 4294967293u;
                    break;

                case 1u:
                    break;

                default:
                    return(false);
                }
                try
                {
                    switch (num)
                    {
                    }
                    while (enumerator.MoveNext())
                    {
                        raceDef = enumerator.Current;
                        if (raceDef.category == ThingCategory.Pawn)
                        {
                            d                     = new ThingDef();
                            d.category            = ThingCategory.Item;
                            d.thingClass          = typeof(Corpse);
                            d.selectable          = true;
                            d.tickerType          = TickerType.Rare;
                            d.altitudeLayer       = AltitudeLayer.ItemImportant;
                            d.scatterableOnMapGen = false;
                            d.SetStatBaseValue(StatDefOf.Beauty, -50f);
                            d.SetStatBaseValue(StatDefOf.DeteriorationRate, 1f);
                            d.SetStatBaseValue(StatDefOf.FoodPoisonChanceFixedHuman, 0.05f);
                            d.alwaysHaulable          = true;
                            d.soundDrop               = SoundDefOf.Corpse_Drop;
                            d.pathCost                = 15;
                            d.socialPropernessMatters = false;
                            d.tradeability            = Tradeability.None;
                            d.inspectorTabs           = new List <Type>();
                            d.inspectorTabs.Add(typeof(ITab_Pawn_Health));
                            d.inspectorTabs.Add(typeof(ITab_Pawn_Character));
                            d.inspectorTabs.Add(typeof(ITab_Pawn_Gear));
                            d.inspectorTabs.Add(typeof(ITab_Pawn_Social));
                            d.inspectorTabs.Add(typeof(ITab_Pawn_Log));
                            d.comps.Add(new CompProperties_Forbiddable());
                            d.recipes = new List <RecipeDef>();
                            if (!raceDef.race.IsMechanoid)
                            {
                                d.recipes.Add(RecipeDefOf.RemoveBodyPart);
                            }
                            d.defName = "Corpse_" + raceDef.defName;
                            d.label   = "CorpseLabel".Translate(new object[]
                            {
                                raceDef.label
                            });
                            d.description = "CorpseDesc".Translate(new object[]
                            {
                                raceDef.label
                            });
                            d.soundImpactDefault = raceDef.soundImpactDefault;
                            d.SetStatBaseValue(StatDefOf.MarketValue, ThingDefGenerator_Corpses.CalculateMarketValue(raceDef));
                            d.SetStatBaseValue(StatDefOf.Flammability, raceDef.GetStatValueAbstract(StatDefOf.Flammability, null));
                            d.SetStatBaseValue(StatDefOf.MaxHitPoints, (float)raceDef.BaseMaxHitPoints);
                            d.SetStatBaseValue(StatDefOf.Mass, raceDef.statBases.GetStatOffsetFromList(StatDefOf.Mass));
                            d.SetStatBaseValue(StatDefOf.Nutrition, 5.2f);
                            d.modContentPack    = raceDef.modContentPack;
                            d.ingestible        = new IngestibleProperties();
                            d.ingestible.parent = d;
                            ing               = d.ingestible;
                            ing.foodType      = FoodTypeFlags.Corpse;
                            ing.sourceDef     = raceDef;
                            ing.preferability = ((!raceDef.race.IsFlesh) ? FoodPreferability.NeverForNutrition : FoodPreferability.DesperateOnly);
                            DirectXmlCrossRefLoader.RegisterObjectWantsCrossRef(ing, "tasteThought", ThoughtDefOf.AteCorpse.defName);
                            ing.maxNumToIngestAtOnce = 1;
                            ing.ingestEffect         = EffecterDefOf.EatMeat;
                            ing.ingestSound          = SoundDefOf.RawMeat_Eat;
                            ing.specialThoughtDirect = raceDef.race.FleshType.ateDirect;
                            if (raceDef.race.IsFlesh)
                            {
                                CompProperties_Rottable compProperties_Rottable = new CompProperties_Rottable();
                                compProperties_Rottable.daysToRotStart         = 2.5f;
                                compProperties_Rottable.daysToDessicated       = 5f;
                                compProperties_Rottable.rotDamagePerDay        = 2f;
                                compProperties_Rottable.dessicatedDamagePerDay = 0.7f;
                                d.comps.Add(compProperties_Rottable);
                                CompProperties_SpawnerFilth compProperties_SpawnerFilth = new CompProperties_SpawnerFilth();
                                compProperties_SpawnerFilth.filthDef          = ThingDefOf.Filth_CorpseBile;
                                compProperties_SpawnerFilth.spawnCountOnSpawn = 0;
                                compProperties_SpawnerFilth.spawnMtbHours     = 0f;
                                compProperties_SpawnerFilth.spawnRadius       = 0.1f;
                                compProperties_SpawnerFilth.spawnEveryDays    = 1f;
                                compProperties_SpawnerFilth.requiredRotStage  = new RotStage?(RotStage.Rotting);
                                d.comps.Add(compProperties_SpawnerFilth);
                            }
                            if (d.thingCategories == null)
                            {
                                d.thingCategories = new List <ThingCategoryDef>();
                            }
                            if (raceDef.race.Humanlike)
                            {
                                DirectXmlCrossRefLoader.RegisterListWantsCrossRef <ThingCategoryDef>(d.thingCategories, ThingCategoryDefOf.CorpsesHumanlike.defName, d);
                            }
                            else
                            {
                                DirectXmlCrossRefLoader.RegisterListWantsCrossRef <ThingCategoryDef>(d.thingCategories, raceDef.race.FleshType.corpseCategory.defName, d);
                            }
                            raceDef.race.corpseDef = d;
                            this.$current          = d;
                            if (!this.$disposing)
                            {
                                this.$PC = 1;
                            }
                            flag = true;
                            return(true);
                        }
                    }
                }
                finally
                {
                    if (!flag)
                    {
                        ((IDisposable)enumerator).Dispose();
                    }
                }
                this.$PC = -1;
                return(false);
            }
Exemple #7
0
 public static IEnumerable <ThingDef> ImpliedCorpseDefs()
 {
     foreach (ThingDef raceDef in DefDatabase <ThingDef> .AllDefs.ToList <ThingDef>())
     {
         if (raceDef.category == ThingCategory.Pawn)
         {
             ThingDef d = new ThingDef();
             d.category            = ThingCategory.Item;
             d.thingClass          = typeof(Corpse);
             d.selectable          = true;
             d.tickerType          = TickerType.Rare;
             d.altitudeLayer       = AltitudeLayer.ItemImportant;
             d.scatterableOnMapGen = false;
             d.SetStatBaseValue(StatDefOf.Beauty, -150f);
             d.SetStatBaseValue(StatDefOf.DeteriorationRate, 2f);
             d.alwaysHaulable          = true;
             d.soundDrop               = SoundDef.Named("Corpse_Drop");
             d.pathCost                = 15;
             d.socialPropernessMatters = false;
             d.tradeability            = Tradeability.Never;
             d.inspectorTabs           = new List <Type>();
             d.inspectorTabs.Add(typeof(ITab_Pawn_Health));
             d.inspectorTabs.Add(typeof(ITab_Pawn_Character));
             d.inspectorTabs.Add(typeof(ITab_Pawn_Gear));
             d.inspectorTabs.Add(typeof(ITab_Pawn_Social));
             d.inspectorTabs.Add(typeof(ITab_Pawn_Combat));
             d.comps.Add(new CompProperties_Forbiddable());
             d.recipes = new List <RecipeDef>();
             if (raceDef.race.IsMechanoid)
             {
                 d.recipes.Add(RecipeDefOf.RemoveMechanoidBodyPart);
             }
             else
             {
                 d.recipes.Add(RecipeDefOf.RemoveBodyPart);
             }
             d.defName = raceDef.defName + "_Corpse";
             d.label   = "CorpseLabel".Translate(new object[]
             {
                 raceDef.label
             });
             d.description = "CorpseDesc".Translate(new object[]
             {
                 raceDef.label
             });
             d.soundImpactDefault = raceDef.soundImpactDefault;
             d.SetStatBaseValue(StatDefOf.Flammability, raceDef.GetStatValueAbstract(StatDefOf.Flammability, null));
             d.SetStatBaseValue(StatDefOf.MaxHitPoints, (float)raceDef.BaseMaxHitPoints);
             d.SetStatBaseValue(StatDefOf.Mass, raceDef.statBases.GetStatOffsetFromList(StatDefOf.Mass));
             d.ingestible = new IngestibleProperties();
             IngestibleProperties ing = d.ingestible;
             ing.foodType      = FoodTypeFlags.Corpse;
             ing.sourceDef     = raceDef;
             ing.preferability = FoodPreferability.DesperateOnly;
             DirectXmlCrossRefLoader.RegisterObjectWantsCrossRef(ing, "tasteThought", ThoughtDefOf.AteCorpse.defName);
             ing.nutrition            = 1f;
             ing.maxNumToIngestAtOnce = 1;
             ing.ingestEffect         = EffecterDefOf.EatMeat;
             ing.ingestSound          = SoundDefOf.RawMeat_Eat;
             ing.specialThoughtDirect = raceDef.race.FleshType.ateDirect;
             if (raceDef.race.IsFlesh)
             {
                 CompProperties_Rottable compProperties_Rottable = new CompProperties_Rottable();
                 compProperties_Rottable.daysToRotStart         = 2.5f;
                 compProperties_Rottable.daysToDessicated       = 5f;
                 compProperties_Rottable.rotDamagePerDay        = 2f;
                 compProperties_Rottable.dessicatedDamagePerDay = 0.7f;
                 d.comps.Add(compProperties_Rottable);
                 CompProperties_SpawnerFilth compProperties_SpawnerFilth = new CompProperties_SpawnerFilth();
                 compProperties_SpawnerFilth.filthDef          = ThingDefOf.FilthCorpseBile;
                 compProperties_SpawnerFilth.spawnCountOnSpawn = 0;
                 compProperties_SpawnerFilth.spawnMtbHours     = 0f;
                 compProperties_SpawnerFilth.spawnRadius       = 0.1f;
                 compProperties_SpawnerFilth.spawnEveryDays    = 1f;
                 compProperties_SpawnerFilth.requiredRotStage  = new RotStage?(RotStage.Rotting);
                 d.comps.Add(compProperties_SpawnerFilth);
             }
             if (d.thingCategories == null)
             {
                 d.thingCategories = new List <ThingCategoryDef>();
             }
             if (raceDef.race.Humanlike)
             {
                 DirectXmlCrossRefLoader.RegisterListWantsCrossRef <ThingCategoryDef>(d.thingCategories, ThingCategoryDefOf.CorpsesHumanlike.defName);
             }
             else
             {
                 DirectXmlCrossRefLoader.RegisterListWantsCrossRef <ThingCategoryDef>(d.thingCategories, raceDef.race.FleshType.corpseCategory.defName);
             }
             raceDef.race.corpseDef = d;
             yield return(d);
         }
     }
 }
Exemple #8
0
        public static void AddSaltedMeats()
        {
            HashSet <ThingDef> defsToAdd = new HashSet <ThingDef>();

            foreach (ThingDef td in DefDatabase <ThingDef> .AllDefs.Where(t => t.IsMeat))
            {
                ThingDef d = new ThingDef
                {
                    resourceReadoutPriority = td.resourceReadoutPriority, //ResourceCountPriority.Middle;
                    category    = td.category,                            // ThingCategory.Item;
                    thingClass  = td.thingClass,                          // typeof(ThingWithComps);
                    graphicData = new GraphicData()
                };
                d.graphicData.graphicClass = td.graphicData.graphicClass; // typeof(Graphic_Single);
                d.useHitPoints             = td.useHitPoints;             // true;
                d.selectable = td.selectable;                             // true;
                //d.SetStatBaseValue(StatDefOf.MaxHitPoints, 115f);
                d.SetStatBaseValue(StatDefOf.MaxHitPoints, td.GetStatValueAbstract(StatDefOf.MaxHitPoints) * 1.15f);
                d.altitudeLayer = td.altitudeLayer; // AltitudeLayer.Item;
                d.stackLimit    = td.stackLimit;    // 75;
                d.comps.Add(new CompProperties_Forbiddable());
                CompProperties_Rottable rotProps = new CompProperties_Rottable
                {
                    daysToRotStart = td.GetCompProperties <CompProperties_Rottable>().daysToRotStart, // 2f;
                    rotDestroys    = td.GetCompProperties <CompProperties_Rottable>().rotDestroys     // true;
                };
                d.comps.Add(rotProps);
                d.tickerType = td.tickerType;                                                                                 // TickerType.Rare;
                d.SetStatBaseValue(StatDefOf.Beauty, td.GetStatValueAbstract(StatDefOf.Beauty));                              // -20f
                d.alwaysHaulable          = td.alwaysHaulable;                                                                // true;
                d.rotatable               = td.rotatable;                                                                     // false;
                d.pathCost                = td.pathCost;                                                                      // 15;
                d.drawGUIOverlay          = td.drawGUIOverlay;                                                                // true;
                d.socialPropernessMatters = td.socialPropernessMatters;                                                       // true;

                d.modContentPack = td.modContentPack;                                                                         // +

                d.category     = td.category;                                                                                 // ThingCategory.Item;
                d.description  = td.description;
                d.useHitPoints = td.useHitPoints;                                                                             // true;
                d.SetStatBaseValue(StatDefOf.MaxHitPoints, td.GetStatValueAbstract(StatDefOf.MaxHitPoints) * 1.15f);          // 65f
                d.SetStatBaseValue(StatDefOf.DeteriorationRate, td.GetStatValueAbstract(StatDefOf.DeteriorationRate) * 0.5f); // 3f
                d.SetStatBaseValue(StatDefOf.Mass, td.GetStatValueAbstract(StatDefOf.Mass));                                  // 0.025f
                d.SetStatBaseValue(StatDefOf.Flammability, td.GetStatValueAbstract(StatDefOf.Flammability));                  // 0.5f
                d.SetStatBaseValue(StatDefOf.Nutrition, td.GetStatValueAbstract(StatDefOf.Nutrition) * 1.6f);
                //d.ingestible.nutrition = td.ingestible.nutrition + 0.03f;
                d.SetStatBaseValue(StatDefOf.FoodPoisonChanceFixedHuman, 0.02f);
                //d.comps.Add(new CompProperties_FoodPoisonable());
                d.BaseMarketValue = td.BaseMarketValue;
                if (d.thingCategories == null)
                {
                    d.thingCategories = new List <ThingCategoryDef>();
                }
                DirectXmlCrossRefLoader.RegisterListWantsCrossRef <ThingCategoryDef>(d.thingCategories, "LotR_MeatRawSalted", d);
                d.ingestible = new IngestibleProperties {
                    parent = d
                };
                d.ingestible.foodType      = td.ingestible.foodType;      // FoodTypeFlags.Meat;
                d.ingestible.preferability = td.ingestible.preferability; // FoodPreferability.RawBad;
                DirectXmlCrossRefLoader.RegisterObjectWantsCrossRef(d.ingestible, "tasteThought", ThoughtDefOf.AteRawFood.defName);
                d.ingestible.ingestEffect               = td.ingestible.ingestEffect;
                d.ingestible.ingestSound                = td.ingestible.ingestSound;
                d.ingestible.specialThoughtDirect       = td.ingestible.specialThoughtDirect;
                d.ingestible.specialThoughtAsIngredient = td.ingestible.specialThoughtAsIngredient;

                d.graphicData.texPath = td.graphicData.texPath;
                d.graphicData.color   = td.graphicData.color;
                //d.thingCategories.Add(TTADefOf.LotR_MeatRawSalted);
                d.defName = td.defName + "Salted";
                d.label   = "TTA_SaltedLabel".Translate(td.label);
                d.ingestible.sourceDef = td.ingestible.sourceDef;
                defsToAdd.Add(d);
            }
            TTADefOf.LotR_MeatRawSalted.parent = ThingCategoryDefOf.MeatRaw;
            while (defsToAdd?.Count > 0)
            {
                var thingDef = defsToAdd.FirstOrDefault();
                if (thingDef != null)
                {
                    if (!DefDatabase <ThingDef> .AllDefs.Contains(thingDef))
                    {
                        thingDef.PostLoad();
                        DefDatabase <ThingDef> .Add(thingDef);

                        if (!TTADefOf.LotR_MeatRawSalted.childThingDefs.Contains(thingDef))
                        {
                            TTADefOf.LotR_MeatRawSalted.childThingDefs.Add(thingDef);
                        }
                    }
                    defsToAdd.Remove(thingDef);
                }
                else
                {
                    break;
                }
            }

            DirectXmlCrossRefLoader.ResolveAllWantedCrossReferences(FailMode.Silent);
        }
Exemple #9
0
        public static IEnumerable <ThingDef> ImpliedBloodDefs()
        {
            foreach (ThingDef sourceDef in DefDatabase <ThingDef> .AllDefs.ToList())
            {
                if (sourceDef.category != ThingCategory.Pawn || sourceDef.race.useMeatFrom != null || !sourceDef.race.IsFlesh)
                {
                    continue;
                }


                ThingDef bloodDef = new ThingDef();

                bloodDef.defName = "Blood_" + sourceDef.defName;
                bloodDef.label   = GetBloodLabel(sourceDef);

                bloodDef.resourceReadoutPriority = ResourceCountPriority.Middle;
                bloodDef.category      = ThingCategory.Item;
                bloodDef.thingClass    = typeof(ThingWithComps);
                bloodDef.useHitPoints  = true;
                bloodDef.selectable    = true;
                bloodDef.altitudeLayer = AltitudeLayer.Item;
                bloodDef.stackLimit    = 25;

                bloodDef.SetStatBaseValue(StatDefOf.Beauty, -4f);
                bloodDef.SetStatBaseValue(StatDefOf.MaxHitPoints, 60f);
                bloodDef.SetStatBaseValue(StatDefOf.DeteriorationRate, 10f);
                bloodDef.SetStatBaseValue(StatDefOf.Mass, 0.5f);
                bloodDef.SetStatBaseValue(StatDefOf.Flammability, 2f);
                bloodDef.SetStatBaseValue(StatDefOf.Nutrition, 0.01f);
                bloodDef.SetStatBaseValue(StatDefOf.FoodPoisonChanceFixedHuman, 0.02f);

                bloodDef.tickerType = TickerType.Rare;

                bloodDef.comps.Add(new CompProperties_Forbiddable());
                bloodDef.comps.Add(new CompProperties_Rottable
                {
                    daysToRotStart = 0.5f,
                    rotDestroys    = true
                });
                bloodDef.comps.Add(new CompProperties_Blood
                {
                    bloodAmount = 0.1f,
                    minSeverityForBadThought = 0.4f,
                    harvestEfficiencyFactor  = 2f
                });

                //humanlike blood can be self-administered (if same race)
                if (sourceDef.race.Humanlike)
                {
                    bloodDef.comps.Add(new CompProperties_Usable
                    {
                        useJob   = DefDatabase <JobDef> .GetNamed("UseItem"),
                        useLabel = "GiveSelfTransfusion".Translate(bloodDef.label)
                    });
                    bloodDef.comps.Add(new CompProperties_RestrictUsableWithSkill
                    {
                        skillRequirements = new List <SkillRequirement>
                        {
                            new SkillRequirement {
                                skill = SkillDefOf.Medicine, minLevel = 4
                            }
                        }
                    });
                    bloodDef.comps.Add(new CompProperties_RestrictUsableByRace {
                        allowedRaces = new List <ThingDef> {
                            sourceDef
                        }
                    });
                    bloodDef.comps.Add(new CompProperties_UseEffect {
                        compClass = typeof(CompUseEffect_AdministerBloodTransfusion)
                    });
                    bloodDef.comps.Add(new CompProperties_UseEffect {
                        compClass = typeof(CompUseEffect_DestroySelf)
                    });
                }

                bloodDef.alwaysHaulable = true;
                bloodDef.drawGUIOverlay = true;
                bloodDef.rotatable      = false;
                bloodDef.pathCost       = 15;

                if (bloodDef.thingCategories == null)
                {
                    bloodDef.thingCategories = new List <ThingCategoryDef>();
                }

                DirectXmlCrossRefLoader.RegisterListWantsCrossRef(bloodDef.thingCategories, "RawBlood", bloodDef);

                bloodDef.uiIconForStackCount = 1;
                bloodDef.soundInteract       = SoundDefOf.Standard_Drop;
                bloodDef.soundDrop           = SoundDefOf.Standard_Drop;

                bloodDef.techLevel = TechLevel.Industrial;

                bloodDef.socialPropernessMatters = true;
                bloodDef.modContentPack          = sourceDef.modContentPack; //does this matter?

                //worth 4x as much as the meat of the same animal if humanlike, half as much for critters
                bloodDef.BaseMarketValue = sourceDef.race.Humanlike
                                                   ? sourceDef.race.meatMarketValue * 4f
                                                   : sourceDef.race.meatMarketValue / 2f;

                bloodDef.graphicData = new GraphicData
                {
                    graphicClass = typeof(Graphic_StackCount),
                    texPath      = sourceDef.race.FleshType == FleshTypeDefOf.Insectoid
                                      ? "Things/Item/Resource/InsectBloodPack"
                                      : "Things/Item/Resource/BloodPack",
                    drawSize = Vector2.one * 0.85f
                };

                if (sourceDef.race.Humanlike)
                {
                    bloodDef.description = "BloodHumanlikeDesc".Translate(sourceDef.label);
                }
                else if (sourceDef.race.FleshType == FleshTypeDefOf.Insectoid)
                {
                    bloodDef.description = "BloodInsectDesc".Translate(sourceDef.label);
                }
                else
                {
                    bloodDef.description = "BloodDesc".Translate(sourceDef.label);
                }


                bloodDef.ingestible = new IngestibleProperties
                {
                    parent               = bloodDef,
                    foodType             = FoodTypeFlags.Fluid | FoodTypeFlags.AnimalProduct,
                    preferability        = FoodPreferability.DesperateOnlyForHumanlikes,
                    ingestCommandString  = "Drink {0}",
                    ingestReportString   = "Drinking {0}.",
                    ingestEffect         = EffecterDefOf.EatMeat,
                    ingestSound          = SoundDef.Named("Ingest_Drink"),
                    sourceDef            = sourceDef,
                    specialThoughtDirect = sourceDef.race.Humanlike
                                                ? ThoughtDef.Named("DrankHumanlikeBlood")
                                                : sourceDef.race.FleshType == FleshTypeDefOf.Insectoid
                                                        ? ThoughtDef.Named("ConsumedInsectHemolymph")
                                                        : null,
                    specialThoughtAsIngredient = sourceDef.race.Humanlike
                                                ? ThoughtDef.Named("ConsumedHumanlikeBloodAsIngredient")
                                                : sourceDef.race.FleshType == FleshTypeDefOf.Insectoid
                                                        ? ThoughtDef.Named("ConsumedInsectHemolymphAsIngredient")
                                                        : null,
                };

                DirectXmlCrossRefLoader.RegisterObjectWantsCrossRef(bloodDef.ingestible, "tasteThought", "DrankRawBlood");

                yield return(bloodDef);
            }
        }
Exemple #10
0
        public static IEnumerable <ThingDef> ImpliedLeatherDefs()
        {
            int numLeathers = DefDatabase <ThingDef> .AllDefs.Where(ThingDefGenerator_Leather.GeneratesLeather).Count();

            float eachLeatherCommonality = (float)(1.0 / (float)numLeathers);

            foreach (ThingDef item in DefDatabase <ThingDef> .AllDefs.ToList())
            {
                if (ThingDefGenerator_Leather.GeneratesLeather(item) && item.race.useLeatherFrom == null)
                {
                    ThingDef d = new ThingDef();
                    d.resourceReadoutPriority = ResourceCountPriority.Middle;
                    d.category    = ThingCategory.Item;
                    d.thingClass  = typeof(ThingWithComps);
                    d.graphicData = new GraphicData();
                    d.graphicData.graphicClass = typeof(Graphic_Single);
                    d.useHitPoints             = true;
                    d.selectable = true;
                    d.SetStatBaseValue(StatDefOf.MaxHitPoints, 100f);
                    d.altitudeLayer = AltitudeLayer.Item;
                    d.stackLimit    = 75;
                    d.comps.Add(new CompProperties_Forbiddable());
                    d.SetStatBaseValue(StatDefOf.Beauty, -20f);
                    d.SetStatBaseValue(StatDefOf.DeteriorationRate, 2f);
                    d.alwaysHaulable = true;
                    d.drawGUIOverlay = true;
                    d.rotatable      = false;
                    d.pathCost       = 15;
                    d.category       = ThingCategory.Item;
                    d.description    = "LeatherDesc".Translate(item.label);
                    d.useHitPoints   = true;
                    d.SetStatBaseValue(StatDefOf.MaxHitPoints, 60f);
                    d.SetStatBaseValue(StatDefOf.MarketValue, (float)(item.race.leatherMarketValueFactor * 2.0999999046325684));
                    d.SetStatBaseValue(StatDefOf.Mass, 0.03f);
                    d.SetStatBaseValue(StatDefOf.Flammability, 1f);
                    if (d.thingCategories == null)
                    {
                        d.thingCategories = new List <ThingCategoryDef>();
                    }
                    DirectXmlCrossRefLoader.RegisterListWantsCrossRef(d.thingCategories, "Leathers");
                    d.graphicData.texPath = "Things/Item/Resource/Cloth";
                    d.stuffProps          = new StuffProperties();
                    DirectXmlCrossRefLoader.RegisterListWantsCrossRef(d.stuffProps.categories, "Leathery");
                    StatUtility.SetStatValueInList(ref d.stuffProps.statFactors, StatDefOf.MarketValue, 1.3f);
                    StatUtility.SetStatValueInList(ref d.stuffProps.statFactors, StatDefOf.ArmorRating_Blunt, 1.5f);
                    StatUtility.SetStatValueInList(ref d.stuffProps.statFactors, StatDefOf.ArmorRating_Sharp, 1.5f);
                    StatUtility.SetStatValueInList(ref d.stuffProps.statFactors, StatDefOf.ArmorRating_Heat, 1.7f);
                    StatUtility.SetStatValueInList(ref d.stuffProps.statFactors, StatDefOf.ArmorRating_Electric, 4f);
                    d.defName = item.defName + "_Leather";
                    if (!item.race.leatherLabel.NullOrEmpty())
                    {
                        d.label = item.race.leatherLabel;
                    }
                    else
                    {
                        d.label = "LeatherLabel".Translate(item.label);
                    }
                    d.stuffProps.color       = item.race.leatherColor;
                    d.graphicData.color      = item.race.leatherColor;
                    d.graphicData.colorTwo   = item.race.leatherColor;
                    d.stuffProps.commonality = (float)(1.2000000476837158 * eachLeatherCommonality * item.race.leatherCommonalityFactor);
                    StatUtility.SetStatValueInList(ref d.stuffProps.statFactors, StatDefOf.Insulation_Cold, item.race.leatherInsulation);
                    StatUtility.SetStatValueInList(ref d.stuffProps.statFactors, StatDefOf.Insulation_Heat, item.race.leatherInsulation);
                    List <StatModifier> sfos = item.race.leatherStatFactors;
                    if (sfos != null)
                    {
                        foreach (StatModifier item2 in sfos)
                        {
                            StatUtility.SetStatValueInList(ref d.stuffProps.statFactors, item2.stat, item2.value);
                        }
                    }
                    item.race.leatherDef = d;
                    yield return(d);

                    /*Error: Unable to find new state assignment for yield return*/;
                }
            }
            yield break;
IL_05e9:
            /*Error near IL_05ea: Unexpected return in MoveNext()*/;
        }
        public static IEnumerable <ThingDef> ImpliedCorpseDefs()
        {
            foreach (ThingDef item in DefDatabase <ThingDef> .AllDefs.ToList())
            {
                if (item.category == ThingCategory.Pawn)
                {
                    ThingDef d = new ThingDef
                    {
                        category            = ThingCategory.Item,
                        thingClass          = typeof(Corpse),
                        selectable          = true,
                        tickerType          = TickerType.Rare,
                        altitudeLayer       = AltitudeLayer.ItemImportant,
                        scatterableOnMapGen = false
                    };
                    d.SetStatBaseValue(StatDefOf.Beauty, -50f);
                    d.SetStatBaseValue(StatDefOf.DeteriorationRate, 1f);
                    d.SetStatBaseValue(StatDefOf.FoodPoisonChanceFixedHuman, 0.05f);
                    d.alwaysHaulable          = true;
                    d.soundDrop               = SoundDefOf.Corpse_Drop;
                    d.pathCost                = 15;
                    d.socialPropernessMatters = false;
                    d.tradeability            = Tradeability.None;
                    d.inspectorTabs           = new List <Type>();
                    d.inspectorTabs.Add(typeof(ITab_Pawn_Health));
                    d.inspectorTabs.Add(typeof(ITab_Pawn_Character));
                    d.inspectorTabs.Add(typeof(ITab_Pawn_Gear));
                    d.inspectorTabs.Add(typeof(ITab_Pawn_Social));
                    d.inspectorTabs.Add(typeof(ITab_Pawn_Log));
                    d.comps.Add(new CompProperties_Forbiddable());
                    d.recipes = new List <RecipeDef>();
                    if (!item.race.IsMechanoid)
                    {
                        d.recipes.Add(RecipeDefOf.RemoveBodyPart);
                    }
                    d.defName            = "Corpse_" + item.defName;
                    d.label              = "CorpseLabel".Translate(item.label);
                    d.description        = "CorpseDesc".Translate(item.label);
                    d.soundImpactDefault = item.soundImpactDefault;
                    d.SetStatBaseValue(StatDefOf.MarketValue, CalculateMarketValue(item));
                    d.SetStatBaseValue(StatDefOf.Flammability, item.GetStatValueAbstract(StatDefOf.Flammability));
                    d.SetStatBaseValue(StatDefOf.MaxHitPoints, (float)item.BaseMaxHitPoints);
                    d.SetStatBaseValue(StatDefOf.Mass, item.statBases.GetStatOffsetFromList(StatDefOf.Mass));
                    d.SetStatBaseValue(StatDefOf.Nutrition, 5.2f);
                    d.modContentPack    = item.modContentPack;
                    d.ingestible        = new IngestibleProperties();
                    d.ingestible.parent = d;
                    IngestibleProperties ing = d.ingestible;
                    ing.foodType      = FoodTypeFlags.Corpse;
                    ing.sourceDef     = item;
                    ing.preferability = ((!item.race.IsFlesh) ? FoodPreferability.NeverForNutrition : FoodPreferability.DesperateOnly);
                    DirectXmlCrossRefLoader.RegisterObjectWantsCrossRef(ing, "tasteThought", ThoughtDefOf.AteCorpse.defName);
                    ing.maxNumToIngestAtOnce = 1;
                    ing.ingestEffect         = EffecterDefOf.EatMeat;
                    ing.ingestSound          = SoundDefOf.RawMeat_Eat;
                    ing.specialThoughtDirect = item.race.FleshType.ateDirect;
                    if (item.race.IsFlesh)
                    {
                        CompProperties_Rottable compProperties_Rottable = new CompProperties_Rottable();
                        compProperties_Rottable.daysToRotStart         = 2.5f;
                        compProperties_Rottable.daysToDessicated       = 5f;
                        compProperties_Rottable.rotDamagePerDay        = 2f;
                        compProperties_Rottable.dessicatedDamagePerDay = 0.7f;
                        d.comps.Add(compProperties_Rottable);
                        CompProperties_SpawnerFilth compProperties_SpawnerFilth = new CompProperties_SpawnerFilth();
                        compProperties_SpawnerFilth.filthDef          = ThingDefOf.Filth_CorpseBile;
                        compProperties_SpawnerFilth.spawnCountOnSpawn = 0;
                        compProperties_SpawnerFilth.spawnMtbHours     = 0f;
                        compProperties_SpawnerFilth.spawnRadius       = 0.1f;
                        compProperties_SpawnerFilth.spawnEveryDays    = 1f;
                        compProperties_SpawnerFilth.requiredRotStage  = RotStage.Rotting;
                        d.comps.Add(compProperties_SpawnerFilth);
                    }
                    if (d.thingCategories == null)
                    {
                        d.thingCategories = new List <ThingCategoryDef>();
                    }
                    if (item.race.Humanlike)
                    {
                        DirectXmlCrossRefLoader.RegisterListWantsCrossRef(d.thingCategories, ThingCategoryDefOf.CorpsesHumanlike.defName, d);
                    }
                    else
                    {
                        DirectXmlCrossRefLoader.RegisterListWantsCrossRef(d.thingCategories, item.race.FleshType.corpseCategory.defName, d);
                    }
                    item.race.corpseDef = d;
                    yield return(d);

                    /*Error: Unable to find new state assignment for yield return*/;
                }
            }
            yield break;
IL_05de:
            /*Error near IL_05df: Unexpected return in MoveNext()*/;
        }
 public static IEnumerable <ThingDef> ImpliedMeatDefs()
 {
     foreach (ThingDef sourceDef in DefDatabase <ThingDef> .AllDefs.ToList <ThingDef>())
     {
         if (sourceDef.category == ThingCategory.Pawn)
         {
             if (sourceDef.race.useMeatFrom == null)
             {
                 if (!sourceDef.race.IsFlesh)
                 {
                     DirectXmlCrossRefLoader.RegisterObjectWantsCrossRef(sourceDef.race, "meatDef", "Steel");
                 }
                 else
                 {
                     ThingDef d = new ThingDef();
                     d.resourceReadoutPriority = ResourceCountPriority.Middle;
                     d.category    = ThingCategory.Item;
                     d.thingClass  = typeof(ThingWithComps);
                     d.graphicData = new GraphicData();
                     d.graphicData.graphicClass = typeof(Graphic_Single);
                     d.useHitPoints             = true;
                     d.selectable = true;
                     d.SetStatBaseValue(StatDefOf.MaxHitPoints, 100f);
                     d.altitudeLayer = AltitudeLayer.Item;
                     d.stackLimit    = 75;
                     d.comps.Add(new CompProperties_Forbiddable());
                     CompProperties_Rottable rotProps = new CompProperties_Rottable();
                     rotProps.daysToRotStart = 2f;
                     rotProps.rotDestroys    = true;
                     d.comps.Add(rotProps);
                     d.comps.Add(new CompProperties_FoodPoisoningChance());
                     d.tickerType = TickerType.Rare;
                     d.SetStatBaseValue(StatDefOf.Beauty, -20f);
                     d.alwaysHaulable          = true;
                     d.rotatable               = false;
                     d.pathCost                = 15;
                     d.drawGUIOverlay          = true;
                     d.socialPropernessMatters = true;
                     d.category                = ThingCategory.Item;
                     d.description             = "MeatDesc".Translate(new object[]
                     {
                         sourceDef.label
                     });
                     d.useHitPoints = true;
                     d.SetStatBaseValue(StatDefOf.MaxHitPoints, 60f);
                     d.SetStatBaseValue(StatDefOf.DeteriorationRate, 6f);
                     d.SetStatBaseValue(StatDefOf.Mass, 0.03f);
                     d.SetStatBaseValue(StatDefOf.Flammability, 0.5f);
                     d.BaseMarketValue = ThingDefGenerator_Meat.GetMeatMarketValue(sourceDef);
                     if (d.thingCategories == null)
                     {
                         d.thingCategories = new List <ThingCategoryDef>();
                     }
                     DirectXmlCrossRefLoader.RegisterListWantsCrossRef <ThingCategoryDef>(d.thingCategories, "MeatRaw");
                     d.ingestible               = new IngestibleProperties();
                     d.ingestible.foodType      = FoodTypeFlags.Meat;
                     d.ingestible.preferability = FoodPreferability.RawBad;
                     DirectXmlCrossRefLoader.RegisterObjectWantsCrossRef(d.ingestible, "tasteThought", ThoughtDefOf.AteRawFood.defName);
                     d.ingestible.nutrition                  = 0.05f;
                     d.ingestible.ingestEffect               = EffecterDefOf.EatMeat;
                     d.ingestible.ingestSound                = SoundDef.Named("RawMeat_Eat");
                     d.ingestible.specialThoughtDirect       = sourceDef.race.FleshType.ateDirect;
                     d.ingestible.specialThoughtAsIngredient = sourceDef.race.FleshType.ateAsIngredient;
                     if (sourceDef.race.Humanlike)
                     {
                         d.graphicData.texPath = "Things/Item/Resource/MeatFoodRaw/MeatHuman";
                     }
                     else
                     {
                         if (sourceDef.race.baseBodySize < 0.7f)
                         {
                             d.graphicData.texPath = "Things/Item/Resource/MeatFoodRaw/MeatSmall";
                         }
                         else
                         {
                             d.graphicData.texPath = "Things/Item/Resource/MeatFoodRaw/MeatBig";
                         }
                         d.graphicData.color = sourceDef.race.meatColor;
                     }
                     d.defName = sourceDef.defName + "_Meat";
                     if (sourceDef.race.meatLabel.NullOrEmpty())
                     {
                         d.label = "MeatLabel".Translate(new object[]
                         {
                             sourceDef.label
                         });
                     }
                     else
                     {
                         d.label = sourceDef.race.meatLabel;
                     }
                     d.ingestible.sourceDef = sourceDef;
                     sourceDef.race.meatDef = d;
                     yield return(d);
                 }
             }
         }
     }
 }
Exemple #13
0
 public static IEnumerable <ThingDef> ImpliedMeatDefs()
 {
     foreach (ThingDef item in DefDatabase <ThingDef> .AllDefs.ToList())
     {
         if (item.category != ThingCategory.Pawn || item.race.useMeatFrom != null)
         {
             continue;
         }
         if (!item.race.IsFlesh)
         {
             DirectXmlCrossRefLoader.RegisterObjectWantsCrossRef(item.race, "meatDef", "Steel");
             continue;
         }
         ThingDef thingDef = new ThingDef();
         thingDef.resourceReadoutPriority = ResourceCountPriority.Middle;
         thingDef.category    = ThingCategory.Item;
         thingDef.thingClass  = typeof(ThingWithComps);
         thingDef.graphicData = new GraphicData();
         thingDef.graphicData.graphicClass = typeof(Graphic_StackCount);
         thingDef.useHitPoints             = true;
         thingDef.selectable = true;
         thingDef.SetStatBaseValue(StatDefOf.MaxHitPoints, 100f);
         thingDef.altitudeLayer = AltitudeLayer.Item;
         thingDef.stackLimit    = 75;
         thingDef.comps.Add(new CompProperties_Forbiddable());
         CompProperties_Rottable compProperties_Rottable = new CompProperties_Rottable();
         compProperties_Rottable.daysToRotStart = 2f;
         compProperties_Rottable.rotDestroys    = true;
         thingDef.comps.Add(compProperties_Rottable);
         thingDef.tickerType = TickerType.Rare;
         thingDef.SetStatBaseValue(StatDefOf.Beauty, -4f);
         thingDef.alwaysHaulable          = true;
         thingDef.rotatable               = false;
         thingDef.pathCost                = DefGenerator.StandardItemPathCost;
         thingDef.drawGUIOverlay          = true;
         thingDef.socialPropernessMatters = true;
         thingDef.modContentPack          = item.modContentPack;
         thingDef.category                = ThingCategory.Item;
         if (item.race.Humanlike)
         {
             thingDef.description = "MeatHumanDesc".Translate(item.label);
         }
         else if (item.race.FleshType == FleshTypeDefOf.Insectoid)
         {
             thingDef.description = "MeatInsectDesc".Translate(item.label);
         }
         else
         {
             thingDef.description = "MeatDesc".Translate(item.label);
         }
         thingDef.useHitPoints       = true;
         thingDef.healthAffectsPrice = false;
         thingDef.SetStatBaseValue(StatDefOf.MaxHitPoints, 60f);
         thingDef.SetStatBaseValue(StatDefOf.DeteriorationRate, 6f);
         thingDef.SetStatBaseValue(StatDefOf.Mass, 0.03f);
         thingDef.SetStatBaseValue(StatDefOf.Flammability, 0.5f);
         thingDef.SetStatBaseValue(StatDefOf.Nutrition, 0.05f);
         thingDef.SetStatBaseValue(StatDefOf.FoodPoisonChanceFixedHuman, 0.02f);
         thingDef.BaseMarketValue = item.race.meatMarketValue;
         if (thingDef.thingCategories == null)
         {
             thingDef.thingCategories = new List <ThingCategoryDef>();
         }
         DirectXmlCrossRefLoader.RegisterListWantsCrossRef(thingDef.thingCategories, "MeatRaw", thingDef);
         thingDef.ingestible               = new IngestibleProperties();
         thingDef.ingestible.parent        = thingDef;
         thingDef.ingestible.foodType      = FoodTypeFlags.Meat;
         thingDef.ingestible.preferability = FoodPreferability.RawBad;
         DirectXmlCrossRefLoader.RegisterObjectWantsCrossRef(thingDef.ingestible, "tasteThought", ThoughtDefOf.AteRawFood.defName);
         thingDef.ingestible.ingestEffect               = EffecterDefOf.EatMeat;
         thingDef.ingestible.ingestSound                = SoundDefOf.RawMeat_Eat;
         thingDef.ingestible.specialThoughtDirect       = item.race.FleshType.ateDirect;
         thingDef.ingestible.specialThoughtAsIngredient = item.race.FleshType.ateAsIngredient;
         thingDef.graphicData.color = item.race.meatColor;
         if (item.race.Humanlike)
         {
             thingDef.graphicData.texPath = "Things/Item/Resource/MeatFoodRaw/Meat_Human";
         }
         else if (item.race.FleshType == FleshTypeDefOf.Insectoid)
         {
             thingDef.graphicData.texPath = "Things/Item/Resource/MeatFoodRaw/Meat_Insect";
         }
         else if (item.race.baseBodySize < 0.7f)
         {
             thingDef.graphicData.texPath = "Things/Item/Resource/MeatFoodRaw/Meat_Small";
         }
         else
         {
             thingDef.graphicData.texPath = "Things/Item/Resource/MeatFoodRaw/Meat_Big";
         }
         thingDef.defName = "Meat_" + item.defName;
         if (item.race.meatLabel.NullOrEmpty())
         {
             thingDef.label = "MeatLabel".Translate(item.label);
         }
         else
         {
             thingDef.label = item.race.meatLabel;
         }
         thingDef.ingestible.sourceDef = item;
         item.race.meatDef             = thingDef;
         yield return(thingDef);
     }
 }