VR-Forces Developer's Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Modeling Resources in a System

Some models need to track consumption of resources, such as fuel or munitions.

Each DtLocalObject maintains its own set of resources in a DtSimResourceManager. Each sim component can access this manager through its DtLocalObject. A component that uses resources must look up the actual resource by resource type through the DtLocalObject's resourceManager() member. For more details on the Resource Manager, please see Resource Manager.

Once you have a pointer to the resource, you can determine its current level, and modify it as needed. For example, the DtAutomotiveActuatorComponent has a useFuel() member function, which is called in its updateRepository() member function. It decrements the fuel in the entity by a given amount, as follows:

{
if (entity()->nextFrameFuelLevelsFrozen())
{
return;
}
if (fuelResource)
{
if (fuelResource->amount() <= fuelUsed)
{
objectConsoleWarn() << trUtf8("Out of fuel.", "DtAutomotiveActuatorComponent");
fuelResource->setAmount(0.);
}
else
{
fuelResource->setAmount(fuelResource->amount() - fuelUsed);
}
}
}

The actual types and amounts of each resource are configured in the object parameter database. (For details, please see Resource Manager.)


Document ID: Generated on Thu Oct 15 21:27:02 EDT 2026 from SVN revision 296421
Copyright © 2005-2026 MAK Technologies. All Rights Reserved (www.mak.com)