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); }
public static Barracks GenerateBarracks(GenerationRandom genRan, Barracks barr, out BuildingVoxels vox, BuildingGenerationPlan plan) { vox = new BuildingVoxels(barr.Width, World.ChunkHeight, barr.Height); ChooseWallBounds(genRan, barr); BuildingGenerator.ConnectBoundingWall(vox, barr.BoundingWall, Voxel.stone); Tile[,] tileMap = new Tile[barr.Width, barr.Height]; BuildingGenerator.ChooseEntrancePoint(genRan, vox, barr, plan); BuildingGenerator.SetTiles(tileMap, 0, 0, barr.Width / 2, barr.Height - 1, Tile.STONE_FLOOR); BuildingGenerator.SetTiles(tileMap, barr.Width / 2, 0, barr.Width / 2 - 1, barr.Height - 1, Tile.DIRT); List <NPCJob> jobs = new List <NPCJob>(); for (int x = 2; x < barr.Height; x += 3) { Vector3 pos = new Vector3(barr.Width - 2, 0, x); float rotation = Vec2i.Angle(Vec2i.Forward, BuildingGenerator.GetWallPointDirection(barr, new Vec2i(barr.Width - 2, x))); TrainingDummy obj = new TrainingDummy().SetPosition(pos).SetRotation(rotation) as TrainingDummy; if (BuildingGenerator.AddObject(barr, vox, obj)) { jobs.Add(new NPCJobSoldier(barr)); } } WorkBuildingData wbd = new WorkBuildingData(jobs.ToArray()); barr.SetWorkBuildingData(wbd); barr.SetBuilding(tileMap); return(barr); }
public void SetWorkBuildingData(WorkBuildingData data) { WBD = data; }