/// <summary> /// Adds a body to the creature's list of gather designations. /// </summary> public void Gather(Body item) { var gatherTask = new GatherItemTask(item) { Priority = Task.PriorityType.High }; if (!AI.Tasks.Contains(gatherTask)) { AI.Faction.AddEntityDesignation(item, DesignationType.Gather); AI.AssignTask(gatherTask); } }
public void Gather(GameComponent item) { var task = new GatherItemTask(item) { Priority = TaskPriority.High }; if (AI.Faction == World.PlayerFaction) { World.TaskManager.AddTask(task); } else { AI.AssignTask(task); } }
public void Gather(Body item) { var task = new GatherItemTask(item) { Priority = Task.PriorityType.High }; if (AI.Faction == World.PlayerFaction) { World.Master.TaskManager.AddTask(task); } else { AI.AssignTask(task); } }
public void Gather(Body item) { GatherItemTask gatherTask = new GatherItemTask(item) { Priority = Task.PriorityType.High }; if (!AI.Tasks.Contains(gatherTask)) { if (!AI.Faction.GatherDesignations.Contains(item)) { AI.Faction.GatherDesignations.Add(item); } AI.Tasks.Add(gatherTask); } }
// This hack exists to find orphaned tasks not assigned to any dwarf, and to then // put them on the task list. public void UpdateOrphanedTasks() { orphanedTaskRateLimiter.Update(DwarfTime.LastTime); if (orphanedTaskRateLimiter.HasTriggered) { List <Task> orphanedTasks = new List <Task>(); foreach (var block in Faction.Designations.EnumerateDesignations()) { if (block.Type == DesignationType.Put) { var type = (short)(block.Tag); var task = new BuildVoxelTask(block.Voxel, VoxelLibrary.GetVoxelType(type).Name); if (!TaskManager.HasTask(task) && !Faction.Minions.Any(minion => minion.Tasks.Contains(task))) { orphanedTasks.Add(task); } } else if (block.Type == DesignationType.Dig) { var task = new KillVoxelTask(block.Voxel); if (!TaskManager.HasTask(task) && !Faction.Minions.Any(minion => minion.Tasks.Contains(task))) { orphanedTasks.Add(task); } } // TODO... other tasks here ? } foreach (var ent in Faction.Designations.EnumerateEntityDesignations()) { if (ent.Type == DesignationType.Attack) { var task = new KillEntityTask(ent.Body, KillEntityTask.KillType.Attack); if (!TaskManager.HasTask(task) && !Faction.Minions.Any(minion => minion.Tasks.Contains(task))) { orphanedTasks.Add(task); } } else if (ent.Type == DesignationType.Chop) { var task = new KillEntityTask(ent.Body, KillEntityTask.KillType.Chop); if (!TaskManager.HasTask(task) && !Faction.Minions.Any(minion => minion.Tasks.Contains(task))) { orphanedTasks.Add(task); } } else if (ent.Type == DesignationType.Wrangle) { var task = new WrangleAnimalTask(ent.Body.GetRoot().GetComponent <Creature>()); if (!TaskManager.HasTask(task) && !Faction.Minions.Any(minion => minion.Tasks.Contains(task))) { orphanedTasks.Add(task); } } else if (ent.Type == DesignationType.Gather) { var task = new GatherItemTask(ent.Body); if (!TaskManager.HasTask(task) && !Faction.Minions.Any(minion => minion.Tasks.Contains(task))) { orphanedTasks.Add(task); } } else if (ent.Type == DesignationType.Craft) { var task = new CraftItemTask(ent.Tag as CraftDesignation); if (!TaskManager.HasTask(task) && !Faction.Minions.Any(minion => minion.Tasks.Contains(task))) { orphanedTasks.Add(task); } } /// TODO ... other entity task types } if (orphanedTasks.Count > 0) { TaskManager.AssignTasksGreedy(orphanedTasks, Faction.Minions); } } }