public override void Resolve(ResolveParams rp) { Map map = BaseGen.globalSettings.map; ItemCollectionGeneratorDef itemCollectionGeneratorDef = rp.itemCollectionGeneratorDef ?? ItemCollectionGeneratorDefOf.RandomGeneralGoods; ItemCollectionGeneratorParams?itemCollectionGeneratorParams = rp.itemCollectionGeneratorParams; ItemCollectionGeneratorParams parms; if (itemCollectionGeneratorParams.HasValue) { parms = rp.itemCollectionGeneratorParams.Value; } else { parms = default(ItemCollectionGeneratorParams); parms.count = new int?(rp.rect.Cells.Count((IntVec3 x) => x.Standable(map) && x.GetFirstItem(map) == null)); parms.techLevel = new TechLevel?((rp.faction == null) ? TechLevel.Spacer : rp.faction.def.techLevel); } List <Thing> list = itemCollectionGeneratorDef.Worker.Generate(parms); for (int i = 0; i < list.Count; i++) { ResolveParams resolveParams = rp; resolveParams.singleThingToSpawn = list[i]; BaseGen.symbolStack.Push("thing", resolveParams); } }
public override void Resolve(ResolveParams rp) { Map map = BaseGen.globalSettings.map; if (rp.stockpileConcreteContents != null) { this.CalculateFreeCells(rp.rect, 0f); int num = 0; for (int i = rp.stockpileConcreteContents.Count - 1; i >= 0; i--) { if (num >= this.cells.Count) { break; } GenSpawn.Spawn(rp.stockpileConcreteContents[i], this.cells[num], map); num++; } for (int j = rp.stockpileConcreteContents.Count - 1; j >= 0; j--) { if (!rp.stockpileConcreteContents[j].Spawned) { rp.stockpileConcreteContents[j].Destroy(DestroyMode.Vanish); } } rp.stockpileConcreteContents.Clear(); } else { ItemCollectionGeneratorDef itemCollectionGeneratorDef = rp.itemCollectionGeneratorDef ?? Rand.Element <ItemCollectionGeneratorDef>(ItemCollectionGeneratorDefOf.RandomGeneralGoods, ItemCollectionGeneratorDefOf.Weapons, ItemCollectionGeneratorDefOf.Apparel, ItemCollectionGeneratorDefOf.RawResources); ItemCollectionGeneratorParams?itemCollectionGeneratorParams = rp.itemCollectionGeneratorParams; ItemCollectionGeneratorParams value; if (itemCollectionGeneratorParams.HasValue) { value = rp.itemCollectionGeneratorParams.Value; } else { value = default(ItemCollectionGeneratorParams); value.techLevel = new TechLevel?((rp.faction == null) ? TechLevel.Spacer : rp.faction.def.techLevel); if (itemCollectionGeneratorDef.Worker is ItemCollectionGenerator_Standard) { float?stockpileMarketValue = rp.stockpileMarketValue; float value2 = (!stockpileMarketValue.HasValue) ? Mathf.Min((float)this.cells.Count * 120f, 1800f) : stockpileMarketValue.Value; value.totalMarketValue = new float?(value2); } } int?count = value.count; if (!count.HasValue) { this.CalculateFreeCells(rp.rect, 0.41f); value.count = new int?(this.cells.Count); } ResolveParams resolveParams = rp; resolveParams.itemCollectionGeneratorDef = itemCollectionGeneratorDef; resolveParams.itemCollectionGeneratorParams = new ItemCollectionGeneratorParams?(value); BaseGen.symbolStack.Push("itemCollection", resolveParams); } }
private void CalculatePossibleItemCollectionGenerators(TechLevel techLevel) { this.possibleItemCollectionGenerators.Clear(); if (techLevel >= ThingDefOf.AIPersonaCore.techLevel) { ItemCollectionGeneratorDef standard = ItemCollectionGeneratorDefOf.Standard; ItemCollectionGeneratorParams second = default(ItemCollectionGeneratorParams); second.extraAllowedDefs = Gen.YieldSingle <ThingDef>(ThingDefOf.AIPersonaCore); second.count = new int?(1); this.possibleItemCollectionGenerators.Add(new Pair <ItemCollectionGeneratorDef, ItemCollectionGeneratorParams>(standard, second)); if (Rand.Chance(0.25f) && !this.PlayerOrItemStashHasAIPersonaCore()) { return; } } //if (techLevel >= ThingDefOf.MechSerumNeurotrainer.techLevel) //{ // ItemCollectionGeneratorDef standard2 = ItemCollectionGeneratorDefOf.Standard; // ItemCollectionGeneratorParams second2 = default(ItemCollectionGeneratorParams); // second2.extraAllowedDefs = Gen.YieldSingle<ThingDef>(ThingDefOf.MechSerumNeurotrainer); // second2.count = new int?(ItemCollectionGenerator_ItemStashQuest.NeurotrainersCountRange.RandomInRange); // this.possibleItemCollectionGenerators.Add(new Pair<ItemCollectionGeneratorDef, ItemCollectionGeneratorParams>(standard2, second2)); //} List <ThingDef> allGeneratableItems = ItemCollectionGeneratorUtility.allGeneratableItems; for (int i = 0; i < allGeneratableItems.Count; i++) { ThingDef thingDef = allGeneratableItems[i]; if (techLevel >= thingDef.techLevel && thingDef.itemGeneratorTags != null && thingDef.itemGeneratorTags.Contains(ItemCollectionGeneratorUtility.SpecialRewardTag)) { ItemCollectionGeneratorDef standard3 = ItemCollectionGeneratorDefOf.Standard; ItemCollectionGeneratorParams second3 = default(ItemCollectionGeneratorParams); second3.extraAllowedDefs = Gen.YieldSingle <ThingDef>(thingDef); second3.count = new int?(1); this.possibleItemCollectionGenerators.Add(new Pair <ItemCollectionGeneratorDef, ItemCollectionGeneratorParams>(standard3, second3)); } } ItemCollectionGeneratorParams second4 = default(ItemCollectionGeneratorParams); second4.count = new int?(ThingsCountRange.RandomInRange); second4.totalMarketValue = new float?(TotalMarketValueRange.RandomInRange); second4.techLevel = new TechLevel?(techLevel); this.possibleItemCollectionGenerators.Add(new Pair <ItemCollectionGeneratorDef, ItemCollectionGeneratorParams>(ItemCollectionGeneratorDefOf.Weapons, second4)); this.possibleItemCollectionGenerators.Add(new Pair <ItemCollectionGeneratorDef, ItemCollectionGeneratorParams>(ItemCollectionGeneratorDefOf.RawResources, second4)); this.possibleItemCollectionGenerators.Add(new Pair <ItemCollectionGeneratorDef, ItemCollectionGeneratorParams>(ItemCollectionGeneratorDefOf.Apparel, second4)); // Added !!! this.possibleItemCollectionGenerators.Add(new Pair <ItemCollectionGeneratorDef, ItemCollectionGeneratorParams>(ItemCollectionGeneratorDefOf.AncientTempleContents, second4)); }