The Simple Plan example demonstrates the following:
- How to get objects from a scenario
- How to create plans for objects
- How to register and add a trigger statement to a plan
- How to assign a plan to an object
- How to create and register a console command
The Simple Plan example is loaded as a plugin and demonstrates plan creation and assignment of this plan to a pre-exisiting entity. It also demonstrates creating and registering a trigger area that adds a trigger statement to the object's plan when the object coincides with the area. Finally, it shows how to create and register a console command to send the plan to the specified object.
How to Run the Example
This example demonstrates how to programatically create a plan for an entity in a plugin.
Usage
In the Launcher, click the Plug-ins button to bring up the Plug-ins Selection dialog. Enable the simplePlan plugin to load.
To view the new behavior:
-
Start VR-Forces GUI and SIM.
-
Load the simplePlan.scnx scenario from the developer_toolkit_examples.
-
Verify in the GUI that the M1A2 entity does not have a plan assigned.
-
Type the "sendPlan" command in the SIM console window, and press Enter.
-
In the GUI, right-click the M1A2 entity to view that the entity has been assigned a plan.
-
Play the scenario and observe that the M1A2 entity starts executing the plan.
-
As the entitiy enters the trigger area (Area 2), the triggered action takes place before the entity resumes the original plan.
Note: In Linux - you should not use the Launcher to start the SIM and the GUI.
You need to start the vrfSim and vrfGui, manually - from two separate terminal windows.
The necessary front-end and back-end command line arguments can be copied from the Launcher UI.
Plugin Entry Points
#include <vlutil/vlPrint.h>
#include <vlutil/vlProcessControl.h>
#include <vl/hostStructs.h>
static DtCgf* theCgf = 0;
{
~DtSendPlanCommand() { };
{
DtUUID myTriggerArea(
"Area 2");
conditionalExpressionTrigger.
setArea(triggerArea->
uuid());
DtString triggerAreaDescription =
"This trigger causes the entity who passes through the area to reroute to a different waypoint.";
planBuilder.
addIfCondition(conditionalExpression, thenBlockBuilder, elseBlockBuilder);
thenBlockBuilder->addStatement(moveToAlphaTask);
elseBlockBuilder->addStatement(moveToBetaTask);
triggerBlockBuilder = planBuilder.
addTriggerStatement(conditionalExpressionTrigger, triggerAreaUuid, triggerAreaDescription,
true,
"SuspendTask",
true);
triggerBlockBuilder->addStatement(moveToGammaTask);
return true;
}
{
return "Send a message with the given text.";
};
};
static DtSendPlanCommand* theSendPlanCommand = new DtSendPlanCommand();
extern "C" {
{
info.
pluginDescription =
"This is an example of how to send a simple plan to an entity and register a trigger statement.";
}
{
return true;
}
{
theCgf = cgf;
return true;
}
}