public static void GenerateImpliedDefs_PreResolve() { IEnumerable <ThingDef> enumerable = ThingDefGenerator_Buildings.ImpliedBlueprintAndFrameDefs().Concat(ThingDefGenerator_Meat.ImpliedMeatDefs()).Concat(ThingDefGenerator_Corpses.ImpliedCorpseDefs()) .Concat(ThingDefGenerator_Leather.ImpliedLeatherDefs()); foreach (ThingDef item in enumerable) { item.PostLoad(); DefDatabase <ThingDef> .Add(item); } DirectXmlCrossRefLoader.ResolveAllWantedCrossReferences(FailMode.Silent); foreach (TerrainDef item2 in TerrainDefGenerator_Stone.ImpliedTerrainDefs()) { item2.PostLoad(); DefDatabase <TerrainDef> .Add(item2); } foreach (RecipeDef item3 in RecipeDefGenerator.ImpliedRecipeDefs()) { item3.PostLoad(); DefDatabase <RecipeDef> .Add(item3); } foreach (PawnColumnDef item4 in PawnColumnDefgenerator.ImpliedPawnColumnDefs()) { item4.PostLoad(); DefDatabase <PawnColumnDef> .Add(item4); } }
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); } } } }
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()*/; }