public override void Resolve(ResolveParams rp) { if (rp.singleThingToSpawn is Pawn) { ResolveParams resolveParams = rp; resolveParams.singlePawnToSpawn = (Pawn)rp.singleThingToSpawn; BaseGen.symbolStack.Push("pawn", resolveParams); } else { if (rp.singleThingToSpawn != null && rp.singleThingToSpawn.Spawned) { return; } ThingDef thingDef = (rp.singleThingToSpawn != null) ? rp.singleThingToSpawn.def : (rp.singleThingDef ?? (from x in ItemCollectionGeneratorUtility.allGeneratableItems where x.IsWeapon || x.IsMedicine || x.IsDrug select x).RandomElement()); Rot4? nullable = rp.thingRot; IntVec3 loc = default(IntVec3); if (thingDef.category == ThingCategory.Item) { nullable = Rot4.North; if (!this.TryFindSpawnCellForItem(rp.rect, out loc)) { if (rp.singleThingToSpawn != null) { rp.singleThingToSpawn.Destroy(DestroyMode.Vanish); } return; } } else { bool flag = default(bool); bool flag2 = default(bool); loc = this.FindBestSpawnCellForNonItem(rp.rect, thingDef, ref nullable, out flag, out flag2); if ((flag || flag2) && rp.skipSingleThingIfHasToWipeBuildingOrDoesntFit.HasValue && rp.skipSingleThingIfHasToWipeBuildingOrDoesntFit.Value) { return; } } if (!nullable.HasValue) { Log.Error("Could not resolve rotation. Bug."); } Thing thing; if (rp.singleThingToSpawn == null) { ThingDef stuff = (rp.singleThingStuff == null || !rp.singleThingStuff.stuffProps.CanMake(thingDef)) ? GenStuff.RandomStuffByCommonalityFor(thingDef, (rp.faction != null) ? rp.faction.def.techLevel : TechLevel.Undefined) : rp.singleThingStuff; thing = ThingMaker.MakeThing(thingDef, stuff); Thing thing2 = thing; int? singleThingStackCount = rp.singleThingStackCount; thing2.stackCount = ((!singleThingStackCount.HasValue) ? 1 : singleThingStackCount.Value); if (thing.stackCount <= 0) { thing.stackCount = 1; } if (thing.def.CanHaveFaction && thing.Faction != rp.faction) { thing.SetFaction(rp.faction, null); } CompQuality compQuality = thing.TryGetComp <CompQuality>(); if (compQuality != null) { compQuality.SetQuality(QualityUtility.RandomBaseGenItemQuality(), ArtGenerationContext.Outsider); } if (rp.postThingGenerate != null) { rp.postThingGenerate(thing); } } else { thing = rp.singleThingToSpawn; } thing = GenSpawn.Spawn(thing, loc, BaseGen.globalSettings.map, nullable.Value, false); if (thing != null && thing.def.category == ThingCategory.Item) { thing.SetForbidden(true, false); } if (rp.postThingSpawn != null) { rp.postThingSpawn(thing); } } }