Exemplo n.º 1
0
        private void BuildNewVoxels(IEnumerable <Voxel> refs)
        {
            BuildRoomOrder      order        = null;
            IEnumerable <Voxel> designations = refs as IList <Voxel> ?? refs.ToList();
            IEnumerable <Voxel> nonEmpty     = designations.Select(r => r).Where(v => !v.IsEmpty);

            foreach (Voxel v in nonEmpty)
            {
                if (IsBuildDesignation(v) || IsInRoom(v))
                {
                    continue;
                }


                if (!v.GetVoxelAbove().IsEmpty)
                {
                    continue;
                }

                if (order == null)
                {
                    order = GetMostLikelyDesignation(v);
                }

                if (order != null)
                {
                    order.VoxelOrders.Add(new BuildVoxelOrder(order, order.ToBuild, v));
                }
                else
                {
                    if (CurrentRoomData != RoomLibrary.GetData("Stockpile"))
                    {
                        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
                    {
                        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);
                    }
                }
            }

            if (order != null)
            {
                order.CreateFences(World.ComponentManager);
                TaskManager.AssignTasks(new List <Task>()
                {
                    new BuildRoomTask(order)
                }, Faction.FilterMinionsWithCapability(World.Master.SelectedMinions, GameMaster.ToolMode.Build));
            }
        }
Exemplo n.º 2
0
        private void BuildNewVoxels(IEnumerable <VoxelHandle> designations)
        {
            Room toBuild = RoomLibrary.CreateRoom(Faction, CurrentRoomData.Name, World);
            var  order   = new BuildRoomOrder(toBuild, Faction, Faction.World);

            BuildDesignations.Add(order);
            DesignatedRooms.Add(toBuild);

            foreach (var v in designations.Where(v => v.IsValid && !v.IsEmpty))
            {
                order.VoxelOrders.Add(new BuildVoxelOrder(order, order.ToBuild, v));
            }

            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));
        }
Exemplo n.º 3
0
        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));
                 */
            }
        }