public void Update(float dT) { WM.Update(dT); foreach (Components.Stockpile p in this.Map.Stockpiles) { this.Map.AvailableTasks.AddRange(p.GenerateTasks()); p.Update(dT); } for (int i = 0; i < Map.Objects.Count; i++) { Interfaces.IActor o = Map.Objects[i] as Interfaces.IActor; if (o != null) { o.DoStuff(dT); } } if (this.State == GameState.Designate && this.dragState.IsActive && this.dragState.Complete) { this.dragState.IsActive = false; foreach (Point p in this.dragState.GetCells()) { Components.WallTest wt = new Components.WallTest(); wt.X = p.X; wt.Y = p.Y; wt.WorkRequired = 34; wt.ParentMap = this.Map; Components.Tasks.Build b = new Components.Tasks.Build(wt); b.Description = "Build wall"; this.Map.Objects.Add(wt); this.Map.AvailableTasks.Add(b); } } }
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); }