Receiving Task Completion Reports in VR-Forces SIM

Receiving Task Completion Reports in VR-Forces SIM

Let’s say you have custom controller MyController, derived from DtSingleTaskControllerComponent (or anything derived from DtSimComponent).

Perhaps you want MyController to receive DtTaskCompleteReport.

Typically this is done in an override of DtTaskControllerComponent::registerTaskMsgCallbacks() by registering for DtTaskCompletedReportType in the entity communication interface.

It might be surprising to realize that MyController doesn’t receive the callback when tasks are complete.

This is because task completion reports are only addressed to the originator of the task.

So if the simulated object running MyController isn’t the initiator of the task, MyController won’t receive a completion report.

In other words, MyController will receive completion reports of its own subtasks.

But don’t despair! There is good news.

DtSimTaskManager has its own collection of callbacks, which get invoked before a task completed report is sent to the communication interface.

So if you really want to eavesdrop on what your simulated object is doing, try this instead:

entity()->taskManager()->addTaskCompleteCallback(…).

If you do, please remember to call:

entity()->taskManager()->removeTaskCompleteCallback(…) in MyController::~MyController() so that there are no crashes when the object is deleted!