/// <summary> /// /// </summary> /// <param name="_type"></param> /// <param name="wloc"></param> /// <param name="_height"></param> /// <param name="initiallyOwned"></param> public VarHeightBuilding(VarHeightBuildingContribution _type, WorldLocator wloc, int _height, bool initiallyOwned) { this.type = _type; this.height = _height; int Y = type.Size.Height; int X = type.Size.Width; int Z = height; this.baseLocation = wloc.location; voxels = new VoxelImpl[X, Y, Z]; for (int z = 0; z < Z; z++) { for (int y = 0; y < Y; y++) { for (int x = 0; x < X; x++) { WorldLocator wl = new WorldLocator(wloc.world, baseLocation + new Distance(x, y, z)); voxels[x, y, z] = new VoxelImpl(this, (byte)x, (byte)y, (byte)z, wl); } } } if (wloc.world == WorldDefinition.World) { this.subsidiary = new SubsidiaryCompany(this, initiallyOwned); } if (type.Population != null) { stationListener = new StationListenerImpl( new MultiplierPopulation(height, type.Population), baseLocation); } }
/// <summary> /// Returns true if the construction of this voxel can advance one step. /// /// This method is used to make sure that the construction of the entire /// building will proceed with some degree of order. /// </summary> /// <returns></returns> private bool canProceed() { Time ct = World.world.clock; if (ct.isWeekend) { return(false); // no construction work during the weekends } int h = ct.hour; if (h < 9 || 17 < h) { return(false); // no work during the night } VoxelImpl b = this.below; VoxelImpl a = this.above; State sa = 0, sb = 0; if (b != null) { sb = getMinFloorState(location.z - 1); } if (a != null) { sa = getMinFloorState(location.z + 1); } if (b != null && b.state < State.bone2) { // can't construct this voxel unless the voxel below is done to a certain degree. return(false); } if (b != null && sb <= this.state) { // can't go faster than the floor below return(false); } if (this.state == State.bone1 && b != null && sb < State.bone3) { // the walling can't start unless bones are built on top of it return(false); } if (this.state == State.bone2 && a != null && sa < State.bone1) { // the walling can't complete unless bones are built on top of it return(false); } if (this.state == State.bone3 && a != null && sa < State.bone3) { // the final exterior work won't start until the voxel above reaches to State.bone3. return(false); } return(true); }
/// <summary> /// Builds a new construction site. /// </summary> /// <param name="baseLoc">North-western voxel at the ground level.</param> /// <param name="type">structure to build</param> public ConstructionSite(Location _baseLoc, EventHandler _completionHandler, Distance size) { this.baseLoc = _baseLoc; this.completionHandler = _completionHandler; voxels = new VoxelImpl[size.x, size.y, size.z]; for (int h = 0; h < size.z; h++) { for (int x = 0; x < size.x; x++) { for (int y = 0; y < size.y; y++) { Location l = new Location(baseLoc.x + x, baseLoc.y + y, baseLoc.z + h); if (World.world.isInsideWorld(l)) { voxels[x, y, h] = new VoxelImpl(this, l, new bool[] { y != 0, x != size.x - 1, y != size.y - 1, x != 0 }); } } } } uncompletedVoxels = size.volume; }