public static Blacksmith GenerateBlacksmith(GenerationRandom genRan, Blacksmith smith, out BuildingVoxels vox, BuildingGenerationPlan plan) { vox = new BuildingVoxels(smith.Width, World.ChunkHeight, smith.Height); ChooseWallBounds(genRan, smith); BuildingGenerator.ConnectBoundingWall(vox, smith.BoundingWall, Voxel.stone); Tile[,] tileMap = new Tile[smith.Width, smith.Height]; //Make the whole floor stone BuildingGenerator.SetTiles(tileMap, 0, 0, smith.Width - 1, smith.Height - 1, Tile.STONE_FLOOR); Vec2i outSideMin = null; Vec2i outSideMax = null; //Find the outdoor part and make the floor dirt for (int i = 0; i < smith.BoundingWall.Length; i++) { Vec2i p = smith.BoundingWall[i]; //If this boundry point does not lie on any of the edges, then it is indented into the //building. This means this point defines the outside region of the building. if ((p.x != 0 && p.x != smith.Width - 1) && (p.z != 0 && p.z != smith.Height - 1)) { //We get the 2 neigboring wall points, as these define the outside region Vec2i nm1 = smith.BoundingWall[(i - 1 + smith.BoundingWall.Length) % smith.BoundingWall.Length]; Vec2i np1 = smith.BoundingWall[(i + 1) % smith.BoundingWall.Length]; int minX = Mathf.Min(p.x, nm1.x, np1.x); int minZ = Mathf.Min(p.z, nm1.z, np1.z); int maxX = Mathf.Max(p.x, nm1.x, np1.x); int maxZ = Mathf.Max(p.z, nm1.z, np1.z); BuildingGenerator.SetTiles(tileMap, minX, minZ, maxX - minX, maxZ - minZ, Tile.DIRT); outSideMin = new Vec2i(minX, minZ); outSideMax = new Vec2i(maxX, maxZ); break; } } smith.SetBuilding(tileMap); PlaceOutsideObjects(genRan, smith, vox, outSideMin, outSideMax); BuildingGenerator.ChooseEntrancePoint(genRan, vox, smith, plan); BuildingGenerator.AddWindow(genRan, vox, smith); BuildingGenerator.AddWindow(genRan, vox, smith); BuildingGenerator.AddWindow(genRan, vox, smith, autoReattempt: false); BuildingGenerator.AddWindow(genRan, vox, smith, autoReattempt: false); BuildingGenerator.PlaceObjectAgainstWall(genRan, new Chest(), 0, vox, smith, .1f, attemptsCount: 20, distToEntr: 4); BuildingGenerator.PlaceObjectAgainstWall(genRan, new WeaponStand(), 0, vox, smith, 0.1f, distToEntr: 4); BuildingGenerator.PlaceObjectAgainstWall(genRan, new ArmourStand(), 0, vox, smith, .1f, distToEntr: 4); WorkBuildingData wbd = new WorkBuildingData(new NPCJob[] { new NPCJobMerchant(smith), new NPCJobBlackSmith(smith), new NPCJobBlackSmith(smith) }); smith.SetWorkBuildingData(wbd); for (int i = 0; i < 10; i++) { smith.Inventory.AddItem(new Shirt(new ItemMetaData().SetColor(Color.blue))); } return(smith); }
/// <summary> /// Generates the simplest type of house - a shack /// A shack is made of either (cobble?) stone or wood, /// it consists of only 1 room, with basic objects inside (bed, chair, table) /// </summary> /// <param name="house"></param> /// <param name="vox"></param> /// <returns></returns> public static House GenerateShack(GenerationRandom genRan, House house, out BuildingVoxels vox, BuildingGenerationPlan plan) { vox = new BuildingVoxels(house.Width, World.ChunkHeight, house.Height); Tile[,] floor = new Tile[house.Width, house.Height]; BuildingGenerator.BuildBoundingWallRect(vox, house.Width, house.Height, 6, Voxel.wood); //BuildingGenerator.ConnectBoundingWall(vox, house.BoundingWall, Voxel.wood, 5); BuildingGenerator.SetTiles(floor, 0, 0, house.Width - 1, house.Height - 1, Tile.STONE_FLOOR); house.SetBuilding(floor); BuildingGenerator.ChooseEntrancePoint(genRan, vox, house, plan); BuildingGenerator.AddWindow(genRan, vox, house, size: genRan.RandomInt(1, 4), autoReattempt: true); BuildingGenerator.AddWindow(genRan, vox, house, size: genRan.RandomInt(1, 4), autoReattempt: true); BuildingGenerator.AddWindow(genRan, vox, house, size: genRan.RandomInt(1, 4), autoReattempt: false); BuildingGenerator.AddWindow(genRan, vox, house, size: genRan.RandomInt(1, 4), autoReattempt: false); BuildingGenerator.AddWindow(genRan, vox, house, size: genRan.RandomInt(1, 4), autoReattempt: false); house.InsideWallPoints = BuildingGenerator.FindInsideWallBoundryPoints(vox, house); /*foreach (Vec2i v in house.InsideWallPoints) * { * //house.AddObjectReference(new Chest().SetPosition(v)); * WorldObjectData bed = new Bed().SetPosition(v); * bed.SetRotation(Vec2i.Angle(Vec2i.Forward, BuildingGenerator.GetWallPointDirection(house, v))); * if(!house.ObjectIntersects(bed)) * house.AddObjectReference(bed); * }*/ BuildingGenerator.PlaceObjectAgainstWall(genRan, new DoubleBed(), 0, vox, house, .3f, distToEntr: 4, attemptsCount: 40); BuildingGenerator.PlaceObjectAgainstWall(genRan, new Chest(), 0, vox, house, 0.1f, distToEntr: 3, attemptsCount: 40); for (int i = 0; i < house.BoundingWall.Length; i++) { BuildingGenerator.PlaceObjectAgainstWall(genRan, new WallTorch(), 1.5f, vox, house, 0f, requireWallBacking: true); } house.AddExternalObject(new BuildingInternalNoWalkFloor(new Vector3(1, 0, 1), new Vector3(house.Width - 2, 5, house.Height - 2))); BuildingGenerator.AddRoof(genRan, vox, house, Voxel.thatch); BuildingSubworldBuilder b = new BuildingSubworldBuilder(house, vox, plan); b.CreateSubworld(); //ChunkData[,] subChunks = new ChunkData[1, 1]; return(house); }
public static Tavern GenerateTavern(GenerationRandom genRan, Tavern tavern, out BuildingVoxels vox, BuildingGenerationPlan plan) { vox = new BuildingVoxels(tavern.Width, World.ChunkHeight, tavern.Height); BuildingGenerator.BuildBoundingWallRect(vox, tavern.Width, tavern.Height, 6, Voxel.wood); BuildingGenerator.ChooseEntrancePoint(genRan, vox, tavern, plan); Tile[,] tileMap = new Tile[tavern.Width, tavern.Height]; BuildingGenerator.SetTiles(tileMap, 0, 0, tavern.Width, tavern.Height, Tile.WOOD_FLOOR); tavern.SetBuilding(tileMap); BuildingGenerator.AddWindow(genRan, vox, tavern, autoReattempt: true); BuildingGenerator.AddWindow(genRan, vox, tavern, autoReattempt: true); BuildingGenerator.AddWindow(genRan, vox, tavern, autoReattempt: true); BuildingGenerator.AddWindow(genRan, vox, tavern, autoReattempt: false); BuildingGenerator.AddWindow(genRan, vox, tavern, autoReattempt: false); FirePlace fp = new FirePlace(); BuildingGenerator.PlaceObjectAgainstWall(genRan, fp, 0, vox, tavern, 0, true, 4, true, 20); BuildingGenerator.PlaceObjectAgainstWall(genRan, new WallTorch(), 1.5f, vox, tavern, 0, true, 2); NPCJob[] jobs = new NPCJob[] { new NPCJobMerchant(tavern, "Tavern Keep"), new NPCJobMerchant(tavern, "Tavern Keep") }; tavern.SetWorkBuildingData(new WorkBuildingData(jobs)); BuildingGenerator.AddRoof(genRan, vox, tavern, Voxel.thatch); return(tavern); }