public override bool Modify(SpawnSpec spec) { MultiMap <GridSpace> spawnable = new MultiMap <GridSpace>(); spec.Room.DrawAll(Draw.If <GridSpace>((g) => g.Spawnable).IfThen(Draw.AddTo(spawnable))); Value2D <GridSpace> space; if (!spawnable.GetRandom(spec.Random, out space)) { return(false); } BigBoss.DungeonMaster.SpawnNPC(space.val, space.val.Theme.Keywords); return(true); }
protected void PlaceDoors() { #region DEBUG if (BigBoss.Debug.logging(Logs.LevelGen)) { BigBoss.Debug.printHeader(Logs.LevelGen, "Place Doors"); } #endregion foreach (LayoutObject room in Objects) { #region DEBUG if (BigBoss.Debug.logging(Logs.LevelGen)) { BigBoss.Debug.printHeader(Logs.LevelGen, "Place Doors on " + room); } #endregion var potentialDoors = new MultiMap <GenSpace>(); room.Grids.DrawPotentialExternalDoors(Draw.AddTo <GenSpace>(potentialDoors)); int numDoors = Rand.Next(doorsMin, doorsMax); #region DEBUG if (BigBoss.Debug.logging(Logs.LevelGen)) { potentialDoors.ToLog(Logs.LevelGen, "Potential Doors"); BigBoss.Debug.w(Logs.LevelGen, "Number of doors to generate: " + numDoors); } #endregion foreach (Value2D <GenSpace> doorSpace in potentialDoors.GetRandom(Rand, numDoors, minDoorSpacing)) { room.Grids.SetTo(doorSpace, GridType.Door, Theme); } #region DEBUG if (BigBoss.Debug.logging(Logs.LevelGen)) { room.ToLog(Logs.LevelGen, "Room After placing doors"); BigBoss.Debug.printFooter(Logs.LevelGen, "Place Doors on " + room); } #endregion } #region DEBUG if (BigBoss.Debug.logging(Logs.LevelGen)) { BigBoss.Debug.printFooter(Logs.LevelGen, "Place Doors"); } #endregion }
public static List <Value2D <GenSpace> > PlaceSomeDoors(this Container2D <GenSpace> arr, IEnumerable <Point> points, Theme theme, System.Random rand, int desiredWallToDoorRatio = -1, Point shift = null) { if (desiredWallToDoorRatio < 0) { desiredWallToDoorRatio = LevelGenerator.desiredWallToDoorRatio; } var acceptablePoints = new MultiMap <GenSpace>(); Counter numPoints = new Counter(); DrawAction <GenSpace> call = Draw.Count <GenSpace>(numPoints).And(Draw.CanDrawDoor().IfThen(Draw.AddTo(acceptablePoints))); if (shift != null) { call = call.Shift <GenSpace>(shift.x, shift.y); } arr.DrawPoints(points, call); if (DoorRatioPicker == null) { DoorRatioPicker = new ProbabilityList <int>(); DoorRatioPicker.Add(-2, .25); DoorRatioPicker.Add(-1, .5); DoorRatioPicker.Add(0, 1); DoorRatioPicker.Add(1, .5); DoorRatioPicker.Add(2, .25); } int numDoors = numPoints / desiredWallToDoorRatio; numDoors += DoorRatioPicker.Get(rand); if (numDoors <= 0) { numDoors = 1; } List <Value2D <GenSpace> > pickedPts = acceptablePoints.GetRandom(rand, numDoors, 1); foreach (Point picked in pickedPts) { arr.SetTo(picked, GridType.Door, theme); } return(pickedPts); }
public bool PickSpawnableLocation(Level l, out Value2D <GridSpace> pick) { MultiMap <GridSpace> room = Spawnable(l, l.RoomMaps.Random(Probability.SpawnRand)); return(room.GetRandom(Probability.SpawnRand, out pick)); }