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);
        }
Exemple #2
0
        private static bool TryFindRandomRequestedThingDef(Map map, out ThingDef thingDef, out int count)
        {
            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 = RandomRequestCount(td, map);
                requestCountDict.Add(td, num);
                if (!PlayerItemAccessibilityUtility.PossiblyAccessible(td, num, map))
                {
                    return(false);
                }
                if (!PlayerItemAccessibilityUtility.PlayerCanMake(td, map))
                {
                    return(false);
                }
                if (td.thingSetMakerTags != null && td.thingSetMakerTags.Contains("RewardSpecial"))
                {
                    return(false);
                }
                return(true);
            };

            if ((from td in ThingSetMakerUtility.allGeneratableItems
                 where globalValidator(td)
                 select td).TryRandomElement(out thingDef))
            {
                count = requestCountDict[thingDef];
                return(true);
            }
            count = 0;
            return(false);
        }
        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);
        }