private static bool TryFindRandomRequestedThingDef(Map map, out ThingDef thingDef, out int count)
        {
            IncidentWorker_QuestTradeRequest.requestCountDict.Clear();
            Func <ThingDef, bool> globalValidator = delegate(ThingDef td)
            {
                bool result2;
                if (td.BaseMarketValue / td.BaseMass < 5f)
                {
                    result2 = false;
                }
                else if (!td.alwaysHaulable)
                {
                    result2 = false;
                }
                else
                {
                    CompProperties_Rottable compProperties = td.GetCompProperties <CompProperties_Rottable>();
                    if (compProperties != null && compProperties.daysToRotStart < 10f)
                    {
                        result2 = false;
                    }
                    else if (td.ingestible != null && td.ingestible.HumanEdible)
                    {
                        result2 = false;
                    }
                    else if (td == ThingDefOf.Silver)
                    {
                        result2 = false;
                    }
                    else if (!td.PlayerAcquirable)
                    {
                        result2 = false;
                    }
                    else
                    {
                        int num = IncidentWorker_QuestTradeRequest.RandomRequestCount(td, map);
                        IncidentWorker_QuestTradeRequest.requestCountDict.Add(td, num);
                        result2 = PlayerItemAccessibilityUtility.PossiblyAccessible(td, num, map);
                    }
                }
                return(result2);
            };
            bool result;

            if ((from td in ThingSetMakerUtility.allGeneratableItems
                 where globalValidator(td)
                 select td).TryRandomElement(out thingDef))
            {
                count  = IncidentWorker_QuestTradeRequest.requestCountDict[thingDef];
                result = true;
            }
            else
            {
                count  = 0;
                result = false;
            }
            return(result);
        }
Ejemplo n.º 2
0
        private static bool TryFindRandomRequestedThingDef(Map map, out ThingDef thingDef, out int count)
        {
            requestCountDict.Clear();
            Func <ThingDef, bool> globalValidator = delegate(ThingDef td)
            {
                if (td.BaseMarketValue / td.BaseMass < 5f)
                {
                    return(false);
                }
                if (!td.alwaysHaulable)
                {
                    return(false);
                }
                CompProperties_Rottable compProperties = td.GetCompProperties <CompProperties_Rottable>();
                if (compProperties != null && compProperties.daysToRotStart < 10f)
                {
                    return(false);
                }
                if (td.ingestible != null && td.ingestible.HumanEdible)
                {
                    return(false);
                }
                if (td == ThingDefOf.Silver)
                {
                    return(false);
                }
                if (!td.PlayerAcquirable)
                {
                    return(false);
                }
                int num = RandomRequestCount(td, map);
                requestCountDict.Add(td, num);
                if (!PlayerItemAccessibilityUtility.PossiblyAccessible(td, num, map))
                {
                    return(false);
                }
                if (!PlayerItemAccessibilityUtility.PlayerCanMake(td, map))
                {
                    return(false);
                }
                if (td.thingSetMakerTags != null && td.thingSetMakerTags.Contains("RewardSpecial"))
                {
                    return(false);
                }
                return(true);
            };

            if ((from td in ThingSetMakerUtility.allGeneratableItems
                 where globalValidator(td)
                 select td).TryRandomElement(out thingDef))
            {
                count = requestCountDict[thingDef];
                return(true);
            }
            count = 0;
            return(false);
        }
Ejemplo n.º 3
0
        public override bool CanEverMatch(ThingDef def)
        {
            CompProperties_Rottable compProperties = def.GetCompProperties <CompProperties_Rottable>();

            if (compProperties != null)
            {
                return(!compProperties.rotDestroys);
            }
            return(false);
        }
        public override bool AlwaysMatches(ThingDef def)
        {
            CompProperties_Rottable compProperties = def.GetCompProperties <CompProperties_Rottable>();

            if (compProperties != null && compProperties.rotDestroys)
            {
                return(true);
            }
            if (compProperties == null && def.IsIngestible)
            {
                return(true);
            }
            return(false);
        }
        private static bool TryFindRandomRequestedThingDef(Map map, out ThingDef thingDef, out int count)
        {
            IncidentWorker_CaravanRequest.requestCountDict.Clear();
            Func <ThingDef, bool> globalValidator = delegate(ThingDef td)
            {
                if (td.BaseMarketValue / td.BaseMass < 5.0)
                {
                    return(false);
                }
                if (!td.alwaysHaulable)
                {
                    return(false);
                }
                CompProperties_Rottable compProperties = td.GetCompProperties <CompProperties_Rottable>();
                if (compProperties != null && compProperties.daysToRotStart < 10.0)
                {
                    return(false);
                }
                if (td.ingestible != null && td.ingestible.HumanEdible)
                {
                    return(false);
                }
                if (td == ThingDefOf.Silver)
                {
                    return(false);
                }
                if (!td.PlayerAcquirable)
                {
                    return(false);
                }
                int num = IncidentWorker_CaravanRequest.RandomRequestCount(td, map);
                IncidentWorker_CaravanRequest.requestCountDict.Add(td, num);
                if (!PlayerItemAccessibilityUtility.PossiblyAccessible(td, num, map))
                {
                    return(false);
                }
                return(true);
            };

            if ((from td in ItemCollectionGeneratorUtility.allGeneratableItems
                 where globalValidator(td)
                 select td).TryRandomElement <ThingDef>(out thingDef))
            {
                count = IncidentWorker_CaravanRequest.requestCountDict[thingDef];
                return(true);
            }
            count = 0;
            return(false);
        }
Ejemplo n.º 6
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;
 }
Ejemplo n.º 7
0
        public override bool AlwaysMatches(ThingDef def)
        {
            CompProperties_Rottable compProperties = def.GetCompProperties <CompProperties_Rottable>();

            return((compProperties != null && compProperties.rotDestroys) || (compProperties == null && def.IsIngestible));
        }
Ejemplo n.º 8
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())
                    {
                        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);
            }
            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 override bool CanEverMatch(ThingDef def)
        {
            CompProperties_Rottable compProperties = def.GetCompProperties <CompProperties_Rottable>();

            return(compProperties != null || def.IsIngestible);
        }
Ejemplo n.º 12
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);
         }
     }
 }
Ejemplo n.º 13
0
        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()*/;
        }
Ejemplo n.º 14
0
 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);
                 }
             }
         }
     }
 }
Ejemplo n.º 15
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);
     }
 }