protected override void OnTriggerEvent(Task Task) { Log(LogLevels.Information, $"Task finished (TaskID={Task.TaskID}, TaskTypeID={Task.TaskTypeID})"); Log(LogLevels.Information, $"Terminating task (TaskID={Task.TaskID})"); switch (Task.TaskTypeID) { case TaskTypeIDs.Idle: Try(() => idlerModule.EndIdle(Task.WorkerID)).OrAlert($"Failed to terminate task (TaskID={Task.TaskID})"); break; case TaskTypeIDs.Produce: Try(() => producerModule.EndProduce(Task.WorkerID)).OrAlert($"Failed to terminate task (TaskID={Task.TaskID})"); break; case TaskTypeIDs.Harvest: Try(() => harvesterModule.EndHarvest(Task.WorkerID)).OrAlert($"Failed to terminate task (TaskID={Task.TaskID})"); break; case TaskTypeIDs.MoveTo: Try(() => moverModule.EndMoveTo(Task.WorkerID, Task.X, Task.Y)).OrAlert($"Failed to terminate task (TaskID={Task.TaskID})"); break; case TaskTypeIDs.Take: Try(() => takerModule.EndTake(Task.WorkerID, Task.ResourceTypeID.Value)).OrAlert($"Failed to terminate task (TaskID={Task.TaskID})"); break; case TaskTypeIDs.Store: Try(() => storerModule.EndStore(Task.WorkerID, Task.ResourceTypeID.Value)).OrAlert($"Failed to terminate task (TaskID={Task.TaskID})"); break; case TaskTypeIDs.CreateBuilding: Try(() => factoryBuilderModule.EndCreateBuilding(Task.WorkerID, Task.BuildingTypeID.Value)).OrAlert($"Failed to terminate task (TaskID={Task.TaskID})"); break; case TaskTypeIDs.Build: Try(() => factoryBuilderModule.EndBuild(Task.WorkerID)).OrAlert($"Failed to terminate task (TaskID={Task.TaskID})"); break; default: Log(LogLevels.Warning, $"Unhandled task type (TaskTypeID={Task.TaskTypeID})"); break; } Log(LogLevels.Information, $"Deleting task (TaskID={Task.TaskID})"); Try(() => taskModule.DeleteTask(Task.TaskID)).OrAlert("Failed to delete task"); Log(LogLevels.Information, $"Triggering callbacks"); if (TaskEnded != null) { TaskEnded(this, new TaskEventArgs(Task)); } }