private static void SketchGen() { List <DebugMenuOption> list = new List <DebugMenuOption>(); foreach (SketchResolverDef item in DefDatabase <SketchResolverDef> .AllDefs.Where((SketchResolverDef x) => x.isRoot)) { SketchResolverDef localResolver = item; if (localResolver == SketchResolverDefOf.Monument || localResolver == SketchResolverDefOf.MonumentRuin) { List <DebugMenuOption> sizeOpts = new List <DebugMenuOption>(); for (int i = 1; i <= 60; i++) { int localIndex = i; sizeOpts.Add(new DebugMenuOption(localIndex.ToString(), DebugMenuOptionMode.Tool, delegate { RimWorld.SketchGen.ResolveParams parms2 = default(RimWorld.SketchGen.ResolveParams); parms2.sketch = new Sketch(); parms2.monumentSize = new IntVec2(localIndex, localIndex); RimWorld.SketchGen.SketchGen.Generate(localResolver, parms2).Spawn(Find.CurrentMap, UI.MouseCell(), null, Sketch.SpawnPosType.Unchanged, Sketch.SpawnMode.Normal, wipeIfCollides: false, clearEdificeWhereFloor: false, null, dormant: false, buildRoofsInstantly: true); })); } list.Add(new DebugMenuOption(item.defName, DebugMenuOptionMode.Action, delegate { Find.WindowStack.Add(new Dialog_DebugOptionListLister(sizeOpts)); })); } else { list.Add(new DebugMenuOption(item.defName, DebugMenuOptionMode.Tool, delegate { RimWorld.SketchGen.ResolveParams parms = default(RimWorld.SketchGen.ResolveParams); parms.sketch = new Sketch(); RimWorld.SketchGen.SketchGen.Generate(localResolver, parms).Spawn(Find.CurrentMap, UI.MouseCell(), null, Sketch.SpawnPosType.Unchanged, Sketch.SpawnMode.Normal, wipeIfCollides: false, clearEdificeWhereFloor: false, null, dormant: false, buildRoofsInstantly: true); })); } } Find.WindowStack.Add(new Dialog_DebugOptionListLister(list)); }
public override void Resolve(ResolveParams rp) { Map map = BaseGen.globalSettings.map; CellRect cellRect = CellRect.Empty; RimWorld.SketchGen.ResolveParams parms = default(RimWorld.SketchGen.ResolveParams); parms.sketch = new Sketch(); parms.monumentOpen = false; parms.monumentSize = new IntVec2(rp.rect.Width, rp.rect.Height); parms.allowMonumentDoors = false; parms.allowWood = false; parms.allowFlammableWalls = false; if (rp.allowedMonumentThings != null) { parms.allowedMonumentThings = rp.allowedMonumentThings; } else { parms.allowedMonumentThings = new ThingFilter(); parms.allowedMonumentThings.SetAllowAll(null, includeNonStorable: true); } parms.allowedMonumentThings.SetAllow(ThingDefOf.Drape, allow: false); Sketch sketch = RimWorld.SketchGen.SketchGen.Generate(SketchResolverDefOf.Monument, parms); sketch.Spawn(map, rp.rect.CenterCell, null, Sketch.SpawnPosType.Unchanged, Sketch.SpawnMode.Normal, wipeIfCollides: true, clearEdificeWhereFloor: true, null, dormant: false, buildRoofsInstantly: true); CellRect rect = SketchGenUtility.FindBiggestRect(sketch, (IntVec3 x) => sketch.TerrainAt(x) != null && !sketch.ThingsAt(x).Any((SketchThing y) => y.def == ThingDefOf.Wall)).MovedBy(rp.rect.CenterCell); for (int i = 0; i < sketch.Things.Count; i++) { if (sketch.Things[i].def == ThingDefOf.Wall) { IntVec3 c = sketch.Things[i].pos + rp.rect.CenterCell; cellRect = ((!cellRect.IsEmpty) ? CellRect.FromLimits(Mathf.Min(cellRect.minX, c.x), Mathf.Min(cellRect.minZ, c.z), Mathf.Max(cellRect.maxX, c.x), Mathf.Max(cellRect.maxZ, c.z)) : CellRect.SingleCell(c)); } } if (!rect.IsEmpty) { ResolveParams resolveParams = rp; resolveParams.rect = rect; if (rp.allowedMonumentThings != null) { resolveParams.allowedMonumentThings = rp.allowedMonumentThings; } else { resolveParams.allowedMonumentThings = new ThingFilter(); resolveParams.allowedMonumentThings.SetAllowAll(null, includeNonStorable: true); } if (ModsConfig.RoyaltyActive) { resolveParams.allowedMonumentThings.SetAllow(ThingDefOf.Drape, allow: false); } BaseGen.symbolStack.Push("interior_ancientTemple", resolveParams); } if (rp.makeWarningLetter.HasValue && rp.makeWarningLetter.Value) { int nextSignalTagID = Find.UniqueIDsManager.GetNextSignalTagID(); string signalTag = "ancientTempleApproached-" + nextSignalTagID; SignalAction_Letter obj = (SignalAction_Letter)ThingMaker.MakeThing(ThingDefOf.SignalAction_Letter); obj.signalTag = signalTag; obj.letter = LetterMaker.MakeLetter("LetterLabelAncientShrineWarning".Translate(), "AncientShrineWarning".Translate(), LetterDefOf.ThreatBig, new TargetInfo(cellRect.CenterCell, map)); GenSpawn.Spawn(obj, cellRect.CenterCell, map); RectTrigger obj2 = (RectTrigger)ThingMaker.MakeThing(ThingDefOf.RectTrigger); obj2.signalTag = signalTag; obj2.Rect = cellRect.ExpandedBy(1).ClipInsideMap(map); obj2.destroyIfUnfogged = true; GenSpawn.Spawn(obj2, cellRect.CenterCell, map); } }
protected override bool CanResolveInt(ResolveParams parms) { return(true); }