private static void QuickspawnStructure() { if (DefDatabase <StructureLayoutDef> .AllDefs.Count() > 0) { List <DebugMenuOption> list = new List <DebugMenuOption>(); foreach (StructureLayoutDef localDef2 in DefDatabase <StructureLayoutDef> .AllDefs) { StructureLayoutDef localDef = localDef2; list.Add(new DebugMenuOption(localDef.defName, DebugMenuOptionMode.Tool, delegate() { if (UI.MouseCell().InBounds(Find.CurrentMap)) { RectUtils.HeightWidthFromLayout(localDef, out int h, out int w); CellRect cellRect = CellRect.CenteredOn(UI.MouseCell(), w, h); foreach (List <string> item in localDef.layouts) { GenUtils.GenerateRoomFromLayout(item, cellRect, Find.CurrentMap, localDef); } } })); } Find.WindowStack.Add(new Dialog_DebugOptionListLister(list)); } }
public override void Resolve(ResolveParams rp) { CGO.currentGenStep = "Generating single structure"; Map map = BaseGen.globalSettings.map; StructureLayoutDef rld = CGO.structureLayoutDef; foreach (List <string> item in rld.layouts) { GenUtils.GenerateRoomFromLayout(item, rp.rect, map, rld); } GenUtils.EnsureBatteriesConnectedAndMakeSense(map, tmpThings, tmpPowerNetPredicateResults, tmpCells, KThingDefOf.KCSG_PowerConduit); GenUtils.EnsurePowerUsersConnected(map, tmpThings, tmpPowerNetPredicateResults, tmpCells, KThingDefOf.KCSG_PowerConduit); GenUtils.EnsureGeneratorsConnectedAndMakeSense(map, tmpThings, tmpPowerNetPredicateResults, tmpCells, KThingDefOf.KCSG_PowerConduit); }
public override void Generate(Map map, GenStepParams parms) { StructureLayoutDef structureLayoutDef = structureLayoutDefs.RandomElement(); RectUtils.HeightWidthFromLayout(structureLayoutDef, out int h, out int w); CellRect cellRect = CellRect.CenteredOn(map.Center, w, h); GenUtils.PreClean(map, cellRect, structureLayoutDef.roofGrid, fullClear); foreach (List <string> item in structureLayoutDef.layouts) { GenUtils.GenerateRoomFromLayout(item, cellRect, map, structureLayoutDef); } if (shouldRuin) { CGO.factionSettlement = new CustomGenOption { filthTypes = filthTypes, scatterThings = scatterThings, scatterChance = scatterChance }; ResolveParams rp = new ResolveParams { faction = map.ParentFaction, rect = cellRect }; foreach (string resolver in ruinSymbolResolvers) { if (!(ruinSymbolResolvers.Contains("kcsg_randomroofremoval") && resolver == "kcsg_scatterstuffaround")) { BaseGen.symbolStack.Push(resolver, rp, null); } } } // Flood refog if (map.mapPawns.FreeColonistsSpawned.Count > 0) { FloodFillerFog.DebugRefogMap(map); } }
public override void Resolve(ResolveParams rp) { CGO.currentGenStep = "Generating structures"; foreach (KeyValuePair <CustomVector, StructureLayoutDef> keyValue in CGO.vectStruct) { CGO.currentGenStepMoreInfo = "Generating " + keyValue.Value.defName; RectUtils.HeightWidthFromLayout(keyValue.Value, out int height, out int width); IntVec3 limitMin = new IntVec3 { x = CGO.offset.x + (int)keyValue.Key.X, z = CGO.offset.z - (int)keyValue.Key.Y - height + 1 }; CellRect rect = new CellRect(limitMin.x, limitMin.z, width, height); foreach (List <string> item in keyValue.Value.layouts) { GenUtils.GenerateRoomFromLayout(item, rect, BaseGen.globalSettings.map, keyValue.Value); } if (keyValue.Value.isStorage) { ResolveParams rstock = rp; rstock.rect = new CellRect(limitMin.x, limitMin.z, width, height); BaseGen.symbolStack.Push("kcsg_storagezone", rstock, null); } } if (CGO.settlementLayoutDef.addLandingPad && ModLister.RoyaltyInstalled) { if (rp.rect.TryFindRandomInnerRect(new IntVec2(9, 9), out CellRect rect, null)) { CGO.currentGenStepMoreInfo = "Generating landing pad"; ResolveParams resolveParams = rp; resolveParams.rect = rect; BaseGen.symbolStack.Push("landingPad", resolveParams, null); BaseGen.globalSettings.basePart_landingPadsResolved++; } } BaseGen.symbolStack.Push("kcsg_gridsecondpass", rp, null); }
public override void PostMapGenerate(Map map) { if (Find.TickManager.TicksGame > 5f || chooseFrom.Count <= 0 || PrepareCarefully_Util.pcScenariosSave.Count <= 0) { return; } StructureLayoutDef structureLayoutDef; if (ModLister.GetActiveModWithIdentifier("EdB.PrepareCarefully") != null) { structureLayoutDef = PrepareCarefully_Util.pcScenariosSave.First().Key; nearMapCenter = PrepareCarefully_Util.pcScenariosSave.First().Value; } else { structureLayoutDef = chooseFrom.RandomElement(); } RectUtils.HeightWidthFromLayout(structureLayoutDef, out int h, out int w); CellRect cellRect = this.CreateCellRect(map, h, w); if (preGenClear) { GenUtils.PreClean(map, cellRect, structureLayoutDef.roofGrid, fullClear); } foreach (List <string> item in structureLayoutDef.layouts) { GenUtils.GenerateRoomFromLayout(item, cellRect, map, structureLayoutDef, spawnConduits); } if (spawnTheStartingPawn && Find.GameInitData != null) { List <List <Thing> > thingsGroups = new List <List <Thing> >(); foreach (Pawn startingAndOptionalPawn in Find.GameInitData.startingAndOptionalPawns) { thingsGroups.Add(new List <Thing>() { startingAndOptionalPawn }); } List <Thing> thingList = new List <Thing>(); foreach (ScenPart allPart in Find.Scenario.AllParts) { thingList.AddRange(allPart.PlayerStartingThings()); } int index = 0; foreach (Thing thing in thingList) { if (thing.def.CanHaveFaction) { thing.SetFactionDirect(Faction.OfPlayer); } thingsGroups[index].Add(thing); ++index; if (index >= thingsGroups.Count) { index = 0; } } IntVec3 center = map.Center; Pos offset = structureLayoutDef.spawnAtPos.RandomElement(); center.x += offset.x; center.y += offset.y; KLog.Message($"Spawning pawns and stuff at {center}"); this.DropThingGroupsAt(center, map, thingsGroups, instaDrop: (Find.GameInitData.QuickStarted || this.method != PlayerPawnsArriveMethod.DropPods), leaveSlag: true, allowFogged: false); } if (map.mapPawns.FreeColonistsSpawned.Count > 0) { FloodFillerFog.DebugRefogMap(map); } }