Example #1
0
 public void AddDigDesignation(BuildOrder order)
 {
     if (order.Vox == null)
     {
         return;
     }
     DigDesignations.Add(order.Vox.QuickCompare, order);
 }
Example #2
0
        public override void OnVoxelsSelected(List <Voxel> refs, InputManager.MouseButton button)
        {
            if (button == InputManager.MouseButton.Left)
            {
                List <Task> assignments = new List <Task>();
                foreach (Voxel r in refs)
                {
                    if (r == null)
                    {
                        continue;
                    }

                    Voxel v = r;
                    if (v.IsEmpty)
                    {
                        continue;
                    }

                    if (!Player.Faction.IsDigDesignation(v) && !Player.Faction.RoomBuilder.IsInRoom(v))
                    {
                        BuildOrder d = new BuildOrder
                        {
                            Vox = r
                        };
                        Player.Faction.DigDesignations.Add(d);
                    }

                    assignments.Add(new KillVoxelTask(r));
                }

                List <CreatureAI> minions = Faction.FilterMinionsWithCapability(Player.SelectedMinions, GameMaster.ToolMode.Dig);
                TaskManager.AssignTasksGreedy(assignments, minions, 5);
                OnConfirm(minions);
            }
            else
            {
                foreach (Voxel r in refs)
                {
                    if (r == null)
                    {
                        continue;
                    }
                    Voxel v = r;

                    if (v.IsEmpty)
                    {
                        continue;
                    }

                    if (Player.Faction.IsDigDesignation(v))
                    {
                        Player.Faction.DigDesignations.Remove(Player.Faction.GetDigDesignation(v));
                    }
                }
            }
        }
Example #3
0
        public override void OnVoxelsSelected(List <VoxelHandle> refs, InputManager.MouseButton button)
        {
            if (button == InputManager.MouseButton.Left)
            {
                Player.World.Tutorial("slice");
                List <Task> assignments = new List <Task>();
                foreach (var v in refs)
                {
                    if (!v.IsValid || (v.IsEmpty && v.IsExplored))
                    {
                        continue;
                    }

                    if (!Player.Faction.Designations.IsVoxelDesignation(v, DesignationType.Dig) && !Player.Faction.RoomBuilder.IsInRoom(v))
                    {
                        BuildOrder d = new BuildOrder
                        {
                            Vox = v
                        };
                        Player.Faction.Designations.AddVoxelDesignation(v, DesignationType.Dig, d);
                    }

                    assignments.Add(new KillVoxelTask(v));
                }

                Player.TaskManager.AddTasks(assignments);
                List <CreatureAI> minions = Faction.FilterMinionsWithCapability(Player.SelectedMinions, Task.TaskCategory.Dig);
                //TaskManager.AssignTasksGreedy(assignments, minions, 5);
                OnConfirm(minions);
            }
            else
            {
                foreach (var r in refs)
                {
                    if (!r.IsValid || (r.IsEmpty && r.IsExplored))
                    {
                        continue;
                    }

                    Player.Faction.Designations.RemoveVoxelDesignation(r, DesignationType.Dig);
                }
            }
        }
Example #4
0
        public IEnumerable <Status> CheckIsDigDesignation(CreatureAI creature, string designation)
        {
            Voxel vref = creature.Blackboard.GetData <Voxel>(designation);

            if (vref != null)
            {
                BuildOrder digBuildOrder = creature.Faction.GetDigDesignation(vref);

                if (digBuildOrder != null)
                {
                    yield return(Status.Success);
                }
                else
                {
                    yield return(Status.Fail);
                }
            }

            yield return(Status.Fail);
        }
Example #5
0
        public override void OnVoxelsSelected(List <VoxelHandle> voxels, InputManager.MouseButton button)
        {
            if (button == InputManager.MouseButton.Left)
            {
                List <Task> assignedTasks = new List <Task>();

                foreach (var v in voxels.Where(v => v.IsValid))
                {
                    if (v.IsEmpty || Player.Faction.Designations.IsVoxelDesignation(v, DesignationType.Guard))
                    {
                        continue;
                    }

                    BuildOrder d = new BuildOrder
                    {
                        Vox = v
                    };

                    Player.Faction.Designations.AddVoxelDesignation(v, DesignationType.Guard, d);
                    assignedTasks.Add(new GuardZoneTask());
                }

                List <CreatureAI> minions =
                    Faction.FilterMinionsWithCapability(Player.World.Master.SelectedMinions, Task.TaskCategory.Gather);
                Player.TaskManager.AddTasks(assignedTasks);
                //TaskManager.AssignTasks(assignedTasks, minions);
                OnConfirm(minions);
            }
            else
            {
                foreach (var v in voxels.Where(v => v.IsValid))
                {
                    if (v.IsEmpty || !Player.Faction.Designations.IsVoxelDesignation(v, DesignationType.Guard))
                    {
                        continue;
                    }

                    Player.Faction.Designations.RemoveVoxelDesignation(v, DesignationType.Guard);
                }
            }
        }
Example #6
0
        public override void OnVoxelsSelected(List <Voxel> voxels, InputManager.MouseButton button)
        {
            List <Task> assignedTasks = new List <Task>();


            foreach (Voxel v in from r in voxels
                     where r != null
                     select r)
            {
                if (button == InputManager.MouseButton.Left)
                {
                    if (v.IsEmpty || Player.Faction.IsGuardDesignation(v))
                    {
                        continue;
                    }

                    BuildOrder d = new BuildOrder
                    {
                        Vox = v
                    };

                    Player.Faction.GuardDesignations.Add(d);
                    assignedTasks.Add(new GuardVoxelTask(v));
                }
                else
                {
                    if (v.IsEmpty || !Player.Faction.IsGuardDesignation(v))
                    {
                        continue;
                    }

                    Player.Faction.GuardDesignations.Remove(Player.Faction.GetGuardDesignation(v));
                }
            }

            List <CreatureAI> minions = Faction.FilterMinionsWithCapability(PlayState.Master.SelectedMinions, GameMaster.ToolMode.Gather);

            TaskManager.AssignTasks(assignedTasks, minions);
            OnConfirm(minions);
        }
Example #7
0
        public BuildOrder GetClosestGuardDesignationTo(Vector3 position)
        {
            float      closestDist  = 99999;
            BuildOrder closestVoxel = null;

            foreach (BuildOrder designation in GuardDesignations)
            {
                Voxel vref = designation.Vox;
                Voxel v    = vref;

                float d = (v.Position - position).LengthSquared();
                if (!(d < closestDist))
                {
                    continue;
                }

                closestDist  = d;
                closestVoxel = designation;
            }

            return(closestVoxel);
        }
Example #8
0
        public BuildOrder GetClosestDigDesignationTo(Vector3 position)
        {
            float      closestDist  = 99999;
            BuildOrder closestVoxel = null;

            foreach (KeyValuePair <ulong, BuildOrder> kvp in DigDesignations)
            {
                Voxel vref = kvp.Value.Vox;
                Voxel v    = vref;

                float d = (v.Position - position).LengthSquared();
                if (!(d < closestDist))
                {
                    continue;
                }

                closestDist  = d;
                closestVoxel = kvp.Value;
            }

            return(closestVoxel);
        }
Example #9
0
        public IEnumerable <Status> IncrementAssignment(CreatureAI creature, string designation, int amount)
        {
            Voxel vref = creature.Blackboard.GetData <Voxel>(designation);

            if (vref != null)
            {
                BuildOrder digBuildOrder = creature.Faction.GetDigDesignation(vref);

                if (digBuildOrder != null)
                {
                    digBuildOrder.NumCreaturesAssigned += amount;
                    yield return(Status.Success);
                }
                else
                {
                    yield return(Status.Fail);
                }
            }
            else
            {
                yield return(Status.Fail);
            }
        }
Example #10
0
        public override void OnVoxelsSelected(List<Voxel> voxels, InputManager.MouseButton button)
        {
            List<Task> assignedTasks = new List<Task>();

            foreach (Voxel v in from r in voxels
                                where r != null
                                select r)
            {
                if (button == InputManager.MouseButton.Left)
                {
                    if (v.IsEmpty || Player.Faction.IsGuardDesignation(v))
                    {
                        continue;
                    }

                    BuildOrder d = new BuildOrder
                    {
                        Vox = v
                    };

                    Player.Faction.GuardDesignations.Add(d);
                    assignedTasks.Add(new GuardVoxelTask(v));
                }
                else
                {
                    if (v.IsEmpty || !Player.Faction.IsGuardDesignation(v))
                    {
                        continue;
                    }

                    Player.Faction.GuardDesignations.Remove(Player.Faction.GetGuardDesignation(v));

                }
            }

            TaskManager.AssignTasks(assignedTasks, Faction.FilterMinionsWithCapability(PlayState.Master.SelectedMinions, GameMaster.ToolMode.Gather));
        }
Example #11
0
        public override void OnVoxelsSelected(List<Voxel> refs, InputManager.MouseButton button)
        {
            if (button == InputManager.MouseButton.Left)
            {
                List<Task> assignments = new List<Task>();
                foreach (Voxel r in refs)
                {
                    if (r == null)
                    {
                        continue;
                    }

                    Voxel v = r;
                    if (v.IsEmpty)
                    {
                        continue;
                    }

                    if(!Player.Faction.IsDigDesignation(v) && !Player.Faction.RoomBuilder.IsInRoom(v))
                    {
                        BuildOrder d = new BuildOrder
                        {
                            Vox = r
                        };
                        Player.Faction.DigDesignations.Add(d);
                    }

                    assignments.Add(new KillVoxelTask(r));
                }

                TaskManager.AssignTasksGreedy(assignments, Faction.FilterMinionsWithCapability(Player.SelectedMinions, GameMaster.ToolMode.Dig), 5);
            }
            else
            {
                foreach (Voxel r in refs)
                {
                    if (r == null)
                    {
                        continue;
                    }
                    Voxel v = r;

                    if (v.IsEmpty)
                    {
                        continue;
                    }

                    if (Player.Faction.IsDigDesignation(v))
                    {
                        Player.Faction.DigDesignations.Remove(Player.Faction.GetDigDesignation(v));
                    }
                }
            }
        }