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); }
private static bool TryFindRandomRequestedThingDef(Map map, out ThingDef thingDef, out int count) { IncidentWorker_QuestTradeRequest.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 = IncidentWorker_QuestTradeRequest.RandomRequestCount(td, map); IncidentWorker_QuestTradeRequest.requestCountDict.Add(td, num); return(PlayerItemAccessibilityUtility.PossiblyAccessible(td, num, map) && PlayerItemAccessibilityUtility.PlayerCanMake(td, map) && (td.thingSetMakerTags == null || !td.thingSetMakerTags.Contains("RewardSpecial"))); }; if ((from td in ThingSetMakerUtility.allGeneratableItems where globalValidator(td) select td).TryRandomElement(out thingDef)) { count = IncidentWorker_QuestTradeRequest.requestCountDict[thingDef]; return(true); } count = 0; return(false); }