Exemplo n.º 1
0
        protected override void Generate(ThingSetMakerParams parms, List <Thing> outThings)
        {
            tmpGenerated.Clear();
            ThingDef result3;

            if (parms.countRange.HasValue)
            {
                int num = Mathf.Max(parms.countRange.Value.RandomInRange, 1);
                for (int i = 0; i < num; i++)
                {
                    if (!TechprintUtility.TryGetTechprintDefToGenerate(parms.makingFaction, out ThingDef result, tmpGenerated))
                    {
                        break;
                    }
                    tmpGenerated.Add(result);
                    outThings.Add(ThingMaker.MakeThing(result));
                }
            }
            else if (parms.totalMarketValueRange.HasValue)
            {
                float    num2 = parms.totalMarketValueRange.Value.RandomInRange * marketValueFactor;
                ThingDef result2;
                for (float num3 = 0f; TechprintUtility.TryGetTechprintDefToGenerate(parms.makingFaction, out result2, tmpGenerated, num2 - num3) || (!tmpGenerated.Any() && TechprintUtility.TryGetTechprintDefToGenerate(parms.makingFaction, out result2, tmpGenerated)); num3 += result2.BaseMarketValue)
                {
                    tmpGenerated.Add(result2);
                    outThings.Add(ThingMaker.MakeThing(result2));
                }
            }
            else if (TechprintUtility.TryGetTechprintDefToGenerate(parms.makingFaction, out result3, tmpGenerated))
            {
                tmpGenerated.Add(result3);
                outThings.Add(ThingMaker.MakeThing(result3));
            }
            tmpGenerated.Clear();
        }
Exemplo n.º 2
0
        public override IEnumerable <Thing> GenerateThings(int forTile, Faction faction = null)
        {
            tmpGenerated.Clear();
            int countToGenerate = CountChanceUtility.RandomCount(countChances);
            int i = 0;

            while (true)
            {
                if (i < countToGenerate)
                {
                    if (!TechprintUtility.TryGetTechprintDefToGenerate(faction, out var result, tmpGenerated))
                    {
                        break;
                    }
                    tmpGenerated.Add(result);
                    foreach (Thing item in StockGeneratorUtility.TryMakeForStock(result, 1))
                    {
                        yield return(item);
                    }
                    i++;
                    continue;
                }
                tmpGenerated.Clear();
                break;
            }
        }
Exemplo n.º 3
0
        protected override bool CanGenerateSub(ThingSetMakerParams parms)
        {
            if (parms.countRange.HasValue && parms.countRange.Value.max <= 0)
            {
                return(false);
            }
            ThingDef result;

            return(TechprintUtility.TryGetTechprintDefToGenerate(parms.makingFaction, out result, null, (!parms.totalMarketValueRange.HasValue) ? float.MaxValue : (parms.totalMarketValueRange.Value.max * marketValueFactor)));
        }