VR-Forces 4.0.4 Class Documentation
Triggers

Trigger (DtSimTrigger, in simTrigger.h) objects are created by When statements (DtWhenStmt) when they are executed.

Triggers register with a DtPlan object so that they can get ticked. They keep a pointer to the plan so that they can unregister when they fire and are deleted.

When a DtSimTrigger is created, it saves a pointer to the When statement that created it. When DtSimTrigger::tick() is called, the trigger uses the DtWhenStmt statement pointer to get the conditional expression so that it can test it. When the trigger condition becomes true, the following occurs:

  1. The trigger's activate() function is called. The activate() function uses its DtWhenStmt pointer to look up the matching DtWhenBlock pointer.
  2. If the trigger is a "Retask" trigger (the only kind in the VR-Forces front-end), the trigger tells the DtPlan to pushExecutionStack().

    Note:
    In a Retask trigger, a trigger behaves like an independent task. When the trigger fires, the entity stops executing the current task and begins to execute the trigger block. When the trigger is complete, the entity executes the first plan statement after the task it was executing at the time the trigger fired.
    As an alternative to the retask model, an entity could return to the task it had been executing, could consider the plan complete when it is finished with the trigger block, or could take some other action.
  3. The trigger tells the DtPlan to execute the DtWhenBlock by calling DtPlan::executeTrigger().
  4. The trigger sets its isDone flag, which indicates to the DtPlan that it should be deleted

[<< Conditional Expressions] [Home] [Top of Page]


Document ID: Generated on Fri Jun 29 16:33:32 EDT 2012 from SVN revision 116588
Copyright © 2005-2012 VT MÄK Inc. All Rights Reserved (www.mak.com)