public static ThingDef RandomExpensiveWallStuff(Faction faction, bool notVeryFlammable = true) { ThingDef result; if (faction != null && TechLevelUtility.IsNeolithicOrWorse(faction.def.techLevel)) { result = ThingDefOf.WoodLog; } else { result = GenCollection.RandomElement <ThingDef>(from d in DefDatabase <ThingDef> .AllDefsListForReading where d.IsStuff && d.stuffProps.CanMake(ThingDefOf.Wall) && (!notVeryFlammable || d.BaseFlammability < 0.5f) && d.BaseMarketValue / d.VolumePerUnit > 8f select d); } return(result); }
public static Faction RandomCityFaction(System.Predicate <Faction> filter = null) { return((from x in Find.World.factionManager.AllFactionsListForReading where !x.def.isPlayer && !x.def.hidden && !TechLevelUtility.IsNeolithicOrWorse(x.def.techLevel) && (filter == null || filter(x)) select x).RandomElementByWeightWithFallback(f => f.def.settlementGenerationWeight)); }