public override bool Place(Container2D <GenSpace> grid, LayoutObject obj, Theme theme, System.Random rand, out Boxing placed) { List <Bounding> options = obj.FindRectangles(GridWidth, GridLength, true, UnitTest); options = new List <Bounding>(options.Filter((bounds) => { Counter counter = new Counter(); grid.DrawRect(new Bounding(bounds, 1), FrontTest.IfThen(Draw.Count <GenSpace>(counter))); return(counter > 0); })); if (options.Count == 0) { placed = null; return(false); } #region DEBUG if (BigBoss.Debug.logging(Logs.LevelGen) && BigBoss.Debug.Flag(DebugManager.DebugFlag.FineSteps)) { BigBoss.Debug.w(Logs.LevelGen, "Options:"); if (GridWidth == 1 && GridLength == 1) { MultiMap <GenSpace> tmp = new MultiMap <GenSpace>(); tmp.PutAll(obj); foreach (Bounding bounds in options) { tmp.DrawRect(bounds, Draw.SetTo(GridType.INTERNAL_RESERVED_CUR, theme)); } tmp.ToLog(Logs.LevelGen); } else { foreach (Bounding bounds in options) { MultiMap <GenSpace> tmp = new MultiMap <GenSpace>(); tmp.PutAll(obj); tmp.DrawRect(bounds, Draw.SetTo(GridType.INTERNAL_RESERVED_CUR, theme)); tmp.ToLog(Logs.LevelGen); } } } #endregion // Place startpoints placed = null; return(false); //placed = options.Random(rand); placed.Expand(1); GridLocation side = GridLocation.BOTTOMRIGHT; foreach (GridLocation loc in GridLocationExt.Dirs().Randomize(rand)) { if (obj.DrawEdge(placed, loc, UnitTest, false)) { side = loc; break; } } obj.DrawEdge(placed, side, Draw.SetTo(GridType.StairPlace, theme), false); return(true); }
protected override bool ModifyInternal(RoomSpec spec) { UndeadTombTheme undeadTheme = spec.Theme as UndeadTombTheme; if (undeadTheme == null) { throw new ArgumentException("Theme needs to be undead themed."); } var tombCollection = undeadTheme.Tombs.SmartElement; ThemeElement tombProto = tombCollection.Proto; List <List <Bounding> > options = spec.Grids.FindRectanglesMaximized(tombProto.GridWidth + 2, tombProto.GridLength + 2, true, new StrokedAction <GenSpace>() { UnitAction = Draw.IsType <GenSpace>(GridType.Floor), StrokeAction = Draw.Walkable() }, spec.Grids.Bounding); #region DEBUG if (BigBoss.Debug.logging(Logs.LevelGen) && BigBoss.Debug.Flag(DebugManager.DebugFlag.FineSteps)) { BigBoss.Debug.printHeader(Logs.LevelGen, "Printing tomb layout options"); for (int i = 0; i < options.Count; i++) { MultiMap <GenSpace> tmp = new MultiMap <GenSpace>(spec.Grids); foreach (Bounding bound in options[i]) { tmp.DrawRect(bound.XMin, bound.XMax, bound.YMin, bound.YMax, new StrokedAction <GenSpace>() { UnitAction = Draw.SetTo(GridType.Wall, spec.Theme), StrokeAction = Draw.True <GenSpace>() }); } tmp.ToLog(Logs.LevelGen, "Option " + i); } BigBoss.Debug.printFooter(Logs.LevelGen, "Printing tomb layout options"); } #endregion while (options.Count > 0) { List <Bounding> set = options.RandomTake(spec.Random); if (set.Count > MIN_TOMBS) { foreach (Bounding tombBound in set) { GenDeploy tomb = new GenDeploy(tombCollection.Get(spec.Random)); spec.Grids.DrawRect(tombBound.XMin, tombBound.XMax, tombBound.YMin, tombBound.YMax, new StrokedAction <GenSpace>() { UnitAction = Draw.MergeIn(tomb, spec.Theme), StrokeAction = Draw.True <GenSpace>() }); } return(true); } } return(false); }
protected override bool ModifyInternal(RoomSpec spec, double scale) { spec.RoomModifiers.RemoveMod(this); BaseRoomMod baseMod = spec.RoomModifiers.BaseMods.Get(spec.Random); #region DEBUG if (BigBoss.Debug.logging(Logs.LevelGen)) { BigBoss.Debug.w(Logs.LevelGen, "Picked base mod " + baseMod); } #endregion scale *= 2d; baseMod.Modify(spec, scale); int numTombs = spec.Random.Next(2, 5) * 2; List <Bounding> largestRects = spec.Grids.FindLargestRectangles(false, new StrokedAction <GenSpace>() { UnitAction = Draw.IsType <GenSpace>(GridType.Floor) }, spec.Grids.Bounding); if (largestRects.Count == 0) { return(false); } #region DEBUG if (BigBoss.Debug.logging(Logs.LevelGen) && BigBoss.Debug.Flag(DebugManager.DebugFlag.FineSteps)) { BigBoss.Debug.w(Logs.LevelGen, "Largest Rect Options"); foreach (Bounding bounds in largestRects) { MultiMap <GenSpace> tmp = new MultiMap <GenSpace>(spec.Grids); tmp.DrawRect(bounds, new StrokedAction <GenSpace>() { UnitAction = Draw.SetTo(GridType.INTERNAL_RESERVED_BLOCKED, spec.Theme) }); tmp.ToLog(Logs.LevelGen); } } #endregion Bounding bound = largestRects.Random(spec.Random); // Place tombs int buffer = spec.Random.NextBool() ? 1 : 2; int pillarSize = 3; // Place pillars //spec.Grids.DrawRect(bound.XMin + buffer, bound.XMin + pillarSize + buffer - 1, bound.YMin + buffer, bound.YMin + pillarSize + buffer - 1, Draw.SetTo(GridType.Pillar, spec.Theme)); //spec.Grids.DrawRect(bound.XMax - 3, bound.XMin + 3, bound.YMin, bound.YMin + 3, Draw.SetTo(GridType.Pillar, spec.Theme)); //spec.Grids.DrawRect(bound.XMin, bound.XMin + 3, bound.YMin, bound.YMin + 3, Draw.SetTo(GridType.Pillar, spec.Theme)); //spec.Grids.DrawRect(bound.XMin, bound.XMin + 3, bound.YMin, bound.YMin + 3, Draw.SetTo(GridType.Pillar, spec.Theme)); // Remove more tomb mods spec.RoomModifiers.RemoveMod(new MassTombRoom(), true); return(false); }
public override bool Place(Container2D <GenSpace> grid, LayoutObject obj, Theme theme, Random rand, out Boxing placed) { int max = Math.Max(GridWidth, GridLength); List <Boxing> options = new List <Boxing>( grid.FindBoxes( GridWidth, GridLength, GridLocation.TOP, new BoxedAction <GenSpace>( frontTest.And(Draw.ContainedIn(obj)), unitTest), true, true, obj.Bounding.Expand(max)) .Filter((box) => { Counter counter = new Counter(); bool ret = grid.DrawEdge(box, box.Front, Draw.HasAround(false, Draw.And(Draw.IsType <GenSpace>(GridType.Floor), Draw.Count <GenSpace>(counter)). Or(Draw.Walkable()))); return(ret && counter > 0); })); if (options.Count == 0) { placed = null; return(false); } #region DEBUG if (BigBoss.Debug.logging(Logs.LevelGen) && BigBoss.Debug.Flag(DebugManager.DebugFlag.FineSteps)) { BigBoss.Debug.w(Logs.LevelGen, "Options:"); foreach (Boxing boxing in options) { MultiMap <GenSpace> tmp = new MultiMap <GenSpace>(); tmp.PutAll(obj); tmp.DrawRect(boxing, Draw.SetTo(GridType.INTERNAL_RESERVED_CUR, theme)); tmp.DrawEdge(boxing, boxing.Front, Draw.SetTo(GridType.INTERNAL_RESERVED_BLOCKED, theme)); tmp.ToLog(Logs.LevelGen); } } #endregion // Place startpoints placed = options.Random(rand); obj.DrawEdge(placed, placed.Front, Draw.Around(false, Draw.IsType <GenSpace>(GridType.Floor).IfThen(Draw.SetTo(GridType.StairPlace, theme)))); return(true); }