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);
                    }
                }
            }
        }
Esempio n. 2
0
        public static IEnumerable <TerrainDef> ImpliedTerrainDefs()
        {
            int i = 0;

            foreach (ThingDef rock in from def in DefDatabase <ThingDef> .AllDefs
                     where def.building != null && def.building.isNaturalRock && !def.building.isResourceRock
                     select def)
            {
                TerrainDef rough  = new TerrainDef();
                TerrainDef hewn   = new TerrainDef();
                TerrainDef smooth = new TerrainDef();
                rough.texturePath = "Terrain/Surfaces/RoughStone";
                rough.edgeType    = TerrainDef.TerrainEdgeType.FadeRough;
                rough.pathCost    = 2;
                StatUtility.SetStatValueInList(ref rough.statBases, StatDefOf.Beauty, -1f);
                rough.scatterType = "Rocky";
                rough.affordances = new List <TerrainAffordanceDef>();
                rough.affordances.Add(TerrainAffordanceDefOf.Light);
                rough.affordances.Add(TerrainAffordanceDefOf.Medium);
                rough.affordances.Add(TerrainAffordanceDefOf.Heavy);
                rough.affordances.Add(TerrainAffordanceDefOf.SmoothableStone);
                rough.fertility   = 0f;
                rough.acceptFilth = false;
                rough.acceptTerrainSourceFilth = false;
                rough.modContentPack           = rock.modContentPack;
                rough.renderPrecedence         = 190 + i;
                rough.defName                = rock.defName + "_Rough";
                rough.label                  = "RoughStoneTerrainLabel".Translate(rock.label);
                rough.description            = "RoughStoneTerrainDesc".Translate(rock.label);
                rough.color                  = rock.graphicData.color;
                rock.building.naturalTerrain = rough;
                hewn.texturePath             = "Terrain/Surfaces/RoughHewnRock";
                hewn.edgeType                = TerrainDef.TerrainEdgeType.FadeRough;
                hewn.pathCost                = 1;
                StatUtility.SetStatValueInList(ref hewn.statBases, StatDefOf.Beauty, -1f);
                hewn.scatterType = "Rocky";
                hewn.affordances = new List <TerrainAffordanceDef>();
                hewn.affordances.Add(TerrainAffordanceDefOf.Light);
                hewn.affordances.Add(TerrainAffordanceDefOf.Medium);
                hewn.affordances.Add(TerrainAffordanceDefOf.Heavy);
                hewn.affordances.Add(TerrainAffordanceDefOf.SmoothableStone);
                hewn.fertility   = 0f;
                hewn.acceptFilth = true;
                hewn.acceptTerrainSourceFilth = true;
                hewn.modContentPack           = rock.modContentPack;
                hewn.renderPrecedence         = 50 + i;
                hewn.defName               = rock.defName + "_RoughHewn";
                hewn.label                 = "RoughHewnStoneTerrainLabel".Translate(rock.label);
                hewn.description           = "RoughHewnStoneTerrainDesc".Translate(rock.label);
                hewn.color                 = rock.graphicData.color;
                rock.building.leaveTerrain = hewn;
                smooth.texturePath         = "Terrain/Surfaces/SmoothStone";
                smooth.edgeType            = TerrainDef.TerrainEdgeType.FadeRough;
                smooth.pathCost            = 0;
                StatUtility.SetStatValueInList(ref smooth.statBases, StatDefOf.Beauty, 2f);
                StatUtility.SetStatValueInList(ref smooth.statBases, StatDefOf.MarketValue, 8f);
                smooth.scatterType = "Rocky";
                smooth.affordances = new List <TerrainAffordanceDef>();
                smooth.affordances.Add(TerrainAffordanceDefOf.Light);
                smooth.affordances.Add(TerrainAffordanceDefOf.Medium);
                smooth.affordances.Add(TerrainAffordanceDefOf.Heavy);
                smooth.fertility   = 0f;
                smooth.acceptFilth = true;
                smooth.acceptTerrainSourceFilth = true;
                smooth.modContentPack           = rock.modContentPack;
                smooth.renderPrecedence         = 140 + i;
                smooth.defName        = rock.defName + "_Smooth";
                smooth.label          = "SmoothStoneTerrainLabel".Translate(rock.label);
                smooth.description    = "SmoothStoneTerrainDesc".Translate(rock.label);
                smooth.color          = rock.graphicData.color;
                rough.smoothedTerrain = smooth;
                hewn.smoothedTerrain  = smooth;
                yield return(rough);
            }
        }
 public static void SetStatBaseValue(this BuildableDef def, StatDef stat, float newBaseValue)
 {
     StatUtility.SetStatValueInList(ref def.statBases, stat, newBaseValue);
 }
        public static IEnumerable <TerrainDef> ImpliedTerrainDefs()
        {
            int i = 0;

            foreach (ThingDef item in DefDatabase <ThingDef> .AllDefs.Where((ThingDef def) => def.building != null && def.building.isNaturalRock && !def.building.isResourceRock))
            {
                TerrainDef terrainDef = new TerrainDef();
                TerrainDef hewn       = new TerrainDef();
                TerrainDef smooth     = new TerrainDef();
                terrainDef.texturePath = "Terrain/Surfaces/RoughStone";
                terrainDef.edgeType    = TerrainDef.TerrainEdgeType.FadeRough;
                terrainDef.pathCost    = 2;
                StatUtility.SetStatValueInList(ref terrainDef.statBases, StatDefOf.Beauty, -1f);
                terrainDef.scatterType = "Rocky";
                terrainDef.affordances = new List <TerrainAffordanceDef>();
                terrainDef.affordances.Add(TerrainAffordanceDefOf.Light);
                terrainDef.affordances.Add(TerrainAffordanceDefOf.Medium);
                terrainDef.affordances.Add(TerrainAffordanceDefOf.Heavy);
                terrainDef.affordances.Add(TerrainAffordanceDefOf.SmoothableStone);
                terrainDef.fertility           = 0f;
                terrainDef.filthAcceptanceMask = (FilthSourceFlags.Terrain | FilthSourceFlags.Unnatural);
                terrainDef.modContentPack      = item.modContentPack;
                terrainDef.renderPrecedence    = 190 + i;
                terrainDef.defName             = item.defName + "_Rough";
                terrainDef.label             = "RoughStoneTerrainLabel".Translate(item.label);
                terrainDef.description       = "RoughStoneTerrainDesc".Translate(item.label);
                terrainDef.color             = item.graphicData.color;
                item.building.naturalTerrain = terrainDef;
                hewn.texturePath             = "Terrain/Surfaces/RoughHewnRock";
                hewn.edgeType = TerrainDef.TerrainEdgeType.FadeRough;
                hewn.pathCost = 1;
                StatUtility.SetStatValueInList(ref hewn.statBases, StatDefOf.Beauty, -1f);
                hewn.scatterType = "Rocky";
                hewn.affordances = new List <TerrainAffordanceDef>();
                hewn.affordances.Add(TerrainAffordanceDefOf.Light);
                hewn.affordances.Add(TerrainAffordanceDefOf.Medium);
                hewn.affordances.Add(TerrainAffordanceDefOf.Heavy);
                hewn.affordances.Add(TerrainAffordanceDefOf.SmoothableStone);
                hewn.fertility           = 0f;
                hewn.filthAcceptanceMask = FilthSourceFlags.Any;
                hewn.modContentPack      = item.modContentPack;
                hewn.renderPrecedence    = 50 + i;
                hewn.defName             = item.defName + "_RoughHewn";
                hewn.label                 = "RoughHewnStoneTerrainLabel".Translate(item.label);
                hewn.description           = "RoughHewnStoneTerrainDesc".Translate(item.label);
                hewn.color                 = item.graphicData.color;
                item.building.leaveTerrain = hewn;
                smooth.texturePath         = "Terrain/Surfaces/SmoothStone";
                smooth.edgeType            = TerrainDef.TerrainEdgeType.FadeRough;
                smooth.pathCost            = 0;
                StatUtility.SetStatValueInList(ref smooth.statBases, StatDefOf.Beauty, 2f);
                StatUtility.SetStatValueInList(ref smooth.statBases, StatDefOf.MarketValue, 8f);
                smooth.scatterType = "Rocky";
                smooth.affordances = new List <TerrainAffordanceDef>();
                smooth.affordances.Add(TerrainAffordanceDefOf.Light);
                smooth.affordances.Add(TerrainAffordanceDefOf.Medium);
                smooth.affordances.Add(TerrainAffordanceDefOf.Heavy);
                smooth.fertility           = 0f;
                smooth.filthAcceptanceMask = FilthSourceFlags.Any;
                smooth.modContentPack      = item.modContentPack;
                smooth.tags = new List <string>
                {
                    "Floor"
                };
                smooth.renderPrecedence    = 140 + i;
                smooth.defName             = item.defName + "_Smooth";
                smooth.label               = "SmoothStoneTerrainLabel".Translate(item.label);
                smooth.description         = "SmoothStoneTerrainDesc".Translate(item.label);
                smooth.color               = item.graphicData.color;
                terrainDef.smoothedTerrain = smooth;
                hewn.smoothedTerrain       = smooth;
                yield return(terrainDef);

                yield return(hewn);

                yield return(smooth);

                i++;
            }
        }
        public static IEnumerable <TerrainDef> ImpliedTerrainDefs()
        {
            int i = 0;

            using (IEnumerator <ThingDef> enumerator = (from def in DefDatabase <ThingDef> .AllDefs
                                                        where def.building != null && def.building.isNaturalRock && !def.building.isResourceRock
                                                        select def).GetEnumerator())
            {
                if (enumerator.MoveNext())
                {
                    ThingDef   rock   = enumerator.Current;
                    TerrainDef rough  = new TerrainDef();
                    TerrainDef hewn   = new TerrainDef();
                    TerrainDef smooth = new TerrainDef();
                    rough.texturePath = "Terrain/Surfaces/RoughStone";
                    rough.edgeType    = TerrainDef.TerrainEdgeType.FadeRough;
                    rough.pathCost    = 1;
                    StatUtility.SetStatValueInList(ref rough.statBases, StatDefOf.Beauty, -1f);
                    rough.scatterType = "Rocky";
                    rough.affordances = new List <TerrainAffordance>();
                    rough.affordances.Add(TerrainAffordance.Light);
                    rough.affordances.Add(TerrainAffordance.Heavy);
                    rough.affordances.Add(TerrainAffordance.SmoothableStone);
                    rough.fertility        = 0f;
                    rough.renderPrecedence = 190 + i;
                    rough.defName          = rock.defName + "_Rough";
                    rough.label            = "RoughStoneTerrainLabel".Translate(rock.label);
                    rough.description      = "RoughStoneTerrainDesc".Translate(rock.label);
                    rough.color            = rock.graphicData.color;
                    rock.naturalTerrain    = rough;
                    hewn.texturePath       = "Terrain/Surfaces/RoughHewnRock";
                    hewn.edgeType          = TerrainDef.TerrainEdgeType.FadeRough;
                    hewn.pathCost          = 1;
                    StatUtility.SetStatValueInList(ref hewn.statBases, StatDefOf.Beauty, -1f);
                    hewn.scatterType = "Rocky";
                    hewn.affordances = new List <TerrainAffordance>();
                    hewn.affordances.Add(TerrainAffordance.Light);
                    hewn.affordances.Add(TerrainAffordance.Heavy);
                    hewn.affordances.Add(TerrainAffordance.SmoothableStone);
                    hewn.fertility        = 0f;
                    hewn.renderPrecedence = 50 + i;
                    hewn.defName          = rock.defName + "_RoughHewn";
                    hewn.label            = "RoughHewnStoneTerrainLabel".Translate(rock.label);
                    hewn.description      = "RoughHewnStoneTerrainDesc".Translate(rock.label);
                    hewn.color            = rock.graphicData.color;
                    rock.leaveTerrain     = hewn;
                    smooth.texturePath    = "Terrain/Surfaces/SmoothStone";
                    smooth.edgeType       = TerrainDef.TerrainEdgeType.FadeRough;
                    smooth.pathCost       = 0;
                    StatUtility.SetStatValueInList(ref smooth.statBases, StatDefOf.Beauty, 2f);
                    smooth.scatterType = "Rocky";
                    smooth.affordances = new List <TerrainAffordance>();
                    smooth.affordances.Add(TerrainAffordance.Light);
                    smooth.affordances.Add(TerrainAffordance.Heavy);
                    smooth.affordances.Add(TerrainAffordance.SmoothHard);
                    smooth.fertility = 0f;
                    smooth.acceptTerrainSourceFilth = true;
                    smooth.renderPrecedence         = 140 + i;
                    smooth.defName        = rock.defName + "_Smooth";
                    smooth.label          = "SmoothStoneTerrainLabel".Translate(rock.label);
                    smooth.description    = "SmoothStoneTerrainDesc".Translate(rock.label);
                    smooth.color          = rock.graphicData.color;
                    rough.smoothedTerrain = smooth;
                    hewn.smoothedTerrain  = smooth;
                    yield return(rough);

                    /*Error: Unable to find new state assignment for yield return*/;
                }
            }
            yield break;
IL_058c:
            /*Error near IL_058d: Unexpected return in MoveNext()*/;
        }
Esempio n. 6
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()*/;
        }