private void BuildNewVoxels(IEnumerable <VoxelHandle> designations) { BuildRoomOrder order = null; foreach (var v in designations.Where(v => v.IsValid && !v.IsEmpty)) { if (IsBuildDesignation(v) || IsInRoom(v)) { continue; } // This check should be rendered pointless by the call to Verify made just // before calling this function. var above = VoxelHelpers.GetVoxelAbove(v); if (above.IsValid && !above.IsEmpty) { continue; } if (order == null) { order = GetMostLikelyDesignation(v); } if (order != null && order.ToBuild.RoomData == CurrentRoomData && !order.IsBuilt) { order.VoxelOrders.Add(new BuildVoxelOrder(order, order.ToBuild, v)); } else if (order == null) { if (CurrentRoomData == RoomLibrary.GetData("Stockpile")) { Stockpile toBuild = new Stockpile(Faction, World); DesignatedRooms.Add(toBuild); order = new BuildStockpileOrder(toBuild, this.Faction); order.VoxelOrders.Add(new BuildVoxelOrder(order, toBuild, v)); BuildDesignations.Add(order); } else if (CurrentRoomData == RoomLibrary.GetData("Treasury")) { Treasury toBuild = new Treasury(Faction, World); DesignatedRooms.Add(toBuild); order = new BuildRoomOrder(toBuild, this.Faction, Faction.World); order.VoxelOrders.Add(new BuildVoxelOrder(order, toBuild, v)); BuildDesignations.Add(order); } else { Room toBuild = RoomLibrary.CreateRoom(Faction, CurrentRoomData.Name, designations.ToList(), true, World); DesignatedRooms.Add(toBuild); order = new BuildRoomOrder(toBuild, Faction, Faction.World); order.VoxelOrders.Add(new BuildVoxelOrder(order, toBuild, v)); BuildDesignations.Add(order); } } else if (order.ToBuild.RoomData != CurrentRoomData || order.IsBuilt) { order = null; } } if (order != null) { order.WorkObjects.AddRange(Fence.CreateFences(World.ComponentManager, ContentPaths.Entities.DwarfObjects.constructiontape, order.VoxelOrders.Select(o => o.Voxel), true)); foreach (var obj in order.WorkObjects) { obj.Manager.RootComponent.AddChild(obj); } World.Master.TaskManager.AddTask(new BuildRoomTask(order)); /* * TaskManager.AssignTasks(new List<Task>() * { * new BuildRoomTask(order) * }, Faction.FilterMinionsWithCapability(World.Master.SelectedMinions, GameMaster.ToolMode.BuildZone)); */ } }