protected override void Generate(ItemCollectionGeneratorParams parms, List <Thing> outThings)
        {
            TraderKindDef traderKindDef = parms.traderDef ?? DefDatabase <TraderKindDef> .AllDefsListForReading.RandomElement();

            Faction traderFaction = parms.traderFaction;
            int?    tile          = parms.tile;
            int     forTile       = (!tile.HasValue) ? ((Find.AnyPlayerHomeMap == null) ? ((Find.VisibleMap == null) ? (-1) : Find.VisibleMap.Tile) : Find.AnyPlayerHomeMap.Tile) : parms.tile.Value;

            for (int i = 0; i < traderKindDef.stockGenerators.Count; i++)
            {
                StockGenerator stockGenerator = traderKindDef.stockGenerators[i];
                foreach (Thing item in stockGenerator.GenerateThings(forTile))
                {
                    if (item.def.tradeability != Tradeability.Stockable)
                    {
                        Log.Error(traderKindDef + " generated carrying " + item + " which has is not Stockable. Ignoring...");
                    }
                    else
                    {
                        item.PostGeneratedForTrader(traderKindDef, forTile, traderFaction);
                        outThings.Add(item);
                    }
                }
            }
        }
Exemple #2
0
        protected override void Generate(ThingSetMakerParams parms, List <Thing> outThings)
        {
            TraderKindDef traderKindDef = parms.traderDef ?? DefDatabase <TraderKindDef> .AllDefsListForReading.RandomElement();

            Faction traderFaction = parms.traderFaction;
            int?    tile          = parms.tile;
            int     forTile       = tile.HasValue ? parms.tile.Value : ((Find.AnyPlayerHomeMap != null) ? Find.AnyPlayerHomeMap.Tile : ((Find.CurrentMap == null) ? (-1) : Find.CurrentMap.Tile));

            for (int i = 0; i < traderKindDef.stockGenerators.Count; i++)
            {
                StockGenerator stockGenerator = traderKindDef.stockGenerators[i];
                foreach (Thing item in stockGenerator.GenerateThings(forTile))
                {
                    if (!item.def.tradeability.TraderCanSell())
                    {
                        Log.Error(traderKindDef + " generated carrying " + item + " which can't be sold by traders. Ignoring...");
                    }
                    else
                    {
                        item.PostGeneratedForTrader(traderKindDef, forTile, traderFaction);
                        outThings.Add(item);
                    }
                }
            }
        }
Exemple #3
0
        protected override IEnumerable <ThingDef> AllGeneratableThingsDebugSub(ThingSetMakerParams parms)
        {
            if (parms.traderDef != null)
            {
                for (int i = 0; i < parms.traderDef.stockGenerators.Count; i++)
                {
                    _003CAllGeneratableThingsDebugSub_003Ec__Iterator0 _003CAllGeneratableThingsDebugSub_003Ec__Iterator = (_003CAllGeneratableThingsDebugSub_003Ec__Iterator0) /*Error near IL_0055: stateMachine*/;
                    StockGenerator stock = parms.traderDef.stockGenerators[i];
                    using (IEnumerator <ThingDef> enumerator = (from x in DefDatabase <ThingDef> .AllDefs
                                                                where x.tradeability.TraderCanSell() && stock.HandlesThingDef(x)
                                                                select x).GetEnumerator())
                    {
                        if (enumerator.MoveNext())
                        {
                            ThingDef t = enumerator.Current;
                            yield return(t);

                            /*Error: Unable to find new state assignment for yield return*/;
                        }
                    }
                }
            }
            yield break;
IL_0155:
            /*Error near IL_0156: Unexpected return in MoveNext()*/;
        }
Exemple #4
0
 protected override IEnumerable <ThingDef> AllGeneratableThingsDebugSub(ThingSetMakerParams parms)
 {
     if (parms.traderDef != null)
     {
         for (int i = 0; i < parms.traderDef.stockGenerators.Count; i++)
         {
             StockGenerator stock = parms.traderDef.stockGenerators[i];
             foreach (ThingDef item in DefDatabase <ThingDef> .AllDefs.Where((ThingDef x) => x.tradeability.TraderCanSell() && stock.HandlesThingDef(x)))
             {
                 yield return(item);
             }
         }
     }
 }
        protected override void Generate(ThingSetMakerParams parms, List <Thing> outThings)
        {
            TraderKindDef traderKindDef = parms.traderDef ?? DefDatabase <TraderKindDef> .AllDefsListForReading.RandomElement <TraderKindDef>();

            Faction traderFaction = parms.traderFaction;
            int?    tile          = parms.tile;
            int     forTile;

            if (tile != null)
            {
                forTile = parms.tile.Value;
            }
            else if (Find.AnyPlayerHomeMap != null)
            {
                forTile = Find.AnyPlayerHomeMap.Tile;
            }
            else if (Find.CurrentMap != null)
            {
                forTile = Find.CurrentMap.Tile;
            }
            else
            {
                forTile = -1;
            }
            for (int i = 0; i < traderKindDef.stockGenerators.Count; i++)
            {
                StockGenerator stockGenerator = traderKindDef.stockGenerators[i];
                foreach (Thing thing in stockGenerator.GenerateThings(forTile))
                {
                    if (!thing.def.tradeability.TraderCanSell())
                    {
                        Log.Error(string.Concat(new object[]
                        {
                            traderKindDef,
                            " generated carrying ",
                            thing,
                            " which can't be sold by traders. Ignoring..."
                        }), false);
                    }
                    else
                    {
                        thing.PostGeneratedForTrader(traderKindDef, forTile, traderFaction);
                        outThings.Add(thing);
                    }
                }
            }
        }
Exemple #6
0
        protected override void Generate(ItemCollectionGeneratorParams parms, List <Thing> outThings)
        {
            TraderKindDef traderKindDef = parms.traderDef ?? DefDatabase <TraderKindDef> .AllDefsListForReading.RandomElement <TraderKindDef>();

            Faction traderFaction = parms.traderFaction;
            int?    tile          = parms.tile;
            int     forTile;

            if (tile.HasValue)
            {
                forTile = parms.tile.Value;
            }
            else if (Find.AnyPlayerHomeMap != null)
            {
                forTile = Find.AnyPlayerHomeMap.Tile;
            }
            else if (Find.VisibleMap != null)
            {
                forTile = Find.VisibleMap.Tile;
            }
            else
            {
                forTile = -1;
            }
            for (int i = 0; i < traderKindDef.stockGenerators.Count; i++)
            {
                StockGenerator stockGenerator = traderKindDef.stockGenerators[i];
                foreach (Thing current in stockGenerator.GenerateThings(forTile))
                {
                    if (current.def.tradeability != Tradeability.Stockable)
                    {
                        Log.Error(string.Concat(new object[]
                        {
                            traderKindDef,
                            " generated carrying ",
                            current,
                            " which has is not Stockable. Ignoring..."
                        }));
                    }
                    else
                    {
                        current.PostGeneratedForTrader(traderKindDef, forTile, traderFaction);
                        outThings.Add(current);
                    }
                }
            }
        }
 protected override IEnumerable <ThingDef> AllGeneratableThingsDebugSub(ThingSetMakerParams parms)
 {
     if (parms.traderDef == null)
     {
         yield break;
     }
     for (int i = 0; i < parms.traderDef.stockGenerators.Count; i++)
     {
         StockGenerator stock = parms.traderDef.stockGenerators[i];
         foreach (ThingDef t in from x in DefDatabase <ThingDef> .AllDefs
                  where x.tradeability.TraderCanSell() && stock.HandlesThingDef(x)
                  select x)
         {
             yield return(t);
         }
     }
     yield break;
 }