Game Development Reference
In-Depth Information
{
pCurrProcess->VOnSuccess();
StrongProcessPtr pChild = pCurrProcess->RemoveChild();
if (pChild)
AttachProcess(pChild);
else
++successCount; // only counts if the whole chain completed
break;
}
case Process::FAILED :
{
pCurrProcess->VOnFail();
++failCount;
break;
}
case Process::ABORTED :
{
pCurrProcess->VOnAbort();
++failCount;
break;
}
}
// remove the process and destroy it
m_processList.erase(thisIt);
}
}
return ((successCount << 16) | failCount);
}
This function loops through every process in the list. If the process is in the
UNINITIALIZED state, it calls VOnInit() on the process. Then, if the process is in
the RUNNING state, it calls VOnUpdate() . Note that VOnInit() typically sets the
state to RUNNING , so the process will get initialized and run its first update in the
same frame, assuming VOnInit() succeeded.
The next block checks to see if the process has died. If so, it checks the exact state and
calls the appropriate exit function, allowing the process to perform any exit logic. A
successful process will have its child attached to the process list before being removed.
Failed processes will simply be removed, causing their children to be destroyed.
Recall that nearly 100 percent of the game code could be inside various overloads of
Process::VOnUpdate() . This game code can, and will, cause game processes and
objects to be deleted, all the more reason that this system uses smart pointers.
 
Search WWH ::




Custom Search