public void DoTasks(float dT) { if (CurrentTask == null) { if (Tasks.Count > 0) { if (GameScenes.MainGame.DebugKeyDown) { } StartTask(Tasks.Dequeue()); } return; } if (this.CurrentTask.Description != null) { this.Description = this.CurrentTask.Description; if (this.CurrentTask as Components.Tasks.ComplexTask != null && (this.CurrentTask as Components.Tasks.ComplexTask).CurrentTask != null) { this.Description += ": " + (this.CurrentTask as Tasks.ComplexTask).CurrentTask.Description ?? "unspecified work"; } } switch (CurrentTask.State) { case TaskState.Complete: { Console.Write(this.Name + " completed " + this.CurrentTask.Description + "."); CurrentTask.CompletedAction?.Invoke(); CurrentTask = null; if (Tasks.Count > 0) { StartTask(Tasks.Dequeue()); } break; } case TaskState.InProgress: { CurrentTask.Progress(dT); break; } case TaskState.Suspended: { CurrentTask.State = TaskState.Enqueued; // CurrentTask.Actor = null; Console.Write(this.Name + " cancels " + this.CurrentTask.Description + ": " + CurrentTask.SuspendReason); //CurrentTask.SuspendReason = ""; ParentMap.AvailableTasks.Add(CurrentTask); CurrentTask = null; break; } } }
public void StartTask(ITask task) { //TODO: add code to actually check if a task can be done at all if (task.SuspendReason != null) { } CurrentTask = task; task.State = TaskState.InProgress; task.Initialize(); int a = 1; }
public Interfaces.ITask GetTask(Interfaces.IActor actor) { Interfaces.ITask result = null; foreach (Interfaces.ITask task in AvailableTasks) { if (actor.CanDo(task)) { if (result == null || result.Priority < task.Priority) { result = task; } } } AvailableTasks.Remove(result); return(result); }
public void DeleteTask(Interfaces.ITask task) { ((AdTask)task).Delete(); }
public void UpdateTask(Interfaces.ITask task) { AdTask t = (AdTask)task; _Service.Save(t.GetUpdate()); }
public void DeleteTask(Interfaces.ITask task) { _Service.RemoveElement((XmlTask)task); }
public void UpdateTask(Interfaces.ITask task) { _Service.Save((XmlTask)task); }
internal Task(Interfaces.ITask task, Application parent) : this(task) { Parent = parent; }
internal Task(Interfaces.ITask task) { Instance = task; }