I'm working on a really simple task scheduler for a base-building game, where both player commands and independent behavior are implemented as tasks which individual AI agents prioritize based on urgency, a distance heuristic, and whatever I come up with to calculate each agent's individual suitability for that task. At its core, this seems really straightforward: there's a global TaskManager that can provide a List<Task> of every Task that needs to be executed, and has methods for AI to request a specific task, report an ongoing task as complete, or report it as failed. Since a wide variety of unrelated entities and logic can register tasks, I've handled reporting each task's success/failure by having anything that adds a new task to the schedule also register a delegate callback that gets invoked when the agent fails or finishes its task. This works perfectly well for one-time testing but I'd like to make Tasks serializable, so agents retain their current task(s) between sessions. The way I'm handling this right now is by giving all the methods that classes need to schedule tasks in an interface which includes some int GetID() which returns a serialized GUID that each class generates when it's first instantiated. Thus, when a task succeeds/fails, the manager simply iterates through every ITask interface it can see, finds one with the right ID, and hands it the Task along with a bool indicating whether it succeed or failed. That works, but it has a few drawbacks: the big one is that I'm doing tons of iteration, every time a task changes hands I'm iterating through hundreds or potentially thousands of objects to check who was using that task, and assigning a consistent ID to tons of potentially unrelated classes feels dangerously close to an antipattern. Are there obvious improvements I can be making, or a completely different pattern I should be implementing task management with? Or is this one of those cases where the current solution is clumsy but acceptable, and I shouldn't be wasting time trying to over-optimize it?