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); }