VR-Engage  2.2
Loading...
Searching...
No Matches
makVre::DtVreScriptReactiveTaskController Class Reference

Detailed Description

DtVreScriptReactiveTaskController extends the script reactive task controller to provide role-based filtering of reactive tasks. It tracks which roles are currently engaged on an entity and enables or disables reactive task scripts based on role permissions defined in the component's descriptor. This allows for dynamic adjustment of entity behavior based on current role assignments.

#include <vreScriptReactiveTaskController.h>

Inheritance diagram for makVre::DtVreScriptReactiveTaskController:
[legend]

Public Member Functions

 DtVreScriptReactiveTaskController (const DtString &name, DtLocalObject *owner, DtSimulationServices *simManager, DtComponentDescriptor *desc, DtReaderWriterRegistry *parentRegistry)
 
virtual void tick () override
 
virtual bool shouldScriptBeEnabled (const DtString &scriptName, const std::set< std::string > &currentRoles) const
 
- Public Member Functions inherited from makVre::DtVreSimComponent< DtScriptReactiveTaskController >
 DtVreSimComponent (const DtString &name, DtLocalObject *owner, DtSimulationServices *simManager, DtComponentDescriptor *desc=0, DtReaderWriterRegistry *parentRegistry=0)
 
virtual ~DtVreSimComponent ()
 
bool isPlayerControlled (const std::string &role="") const
 
DtString entitySystemName () const
 

Static Public Member Functions

static DtSimComponent * creator (const DtString &name, DtLocalObject *owner, DtSimulationServices *simManager, DtComponentDescriptor *desc, DtReaderWriterRegistry *parentRegistry)
 

Protected Member Functions

virtual void updateReactiveTasks (const std::set< std::string > &currentRoles)
 
virtual void getRolesEngagedOnEntity (std::set< std::string > &roles)
 

Protected Attributes

DtVreScriptReactiveTaskControllerDescriptormyDescriptor
 
std::set< std::string > myLastTickRolesEngaged
 
std::map< DtString, std::vector< std::string > > myScriptIdsWithRolesToAllow
 

Private Member Functions

 DtVreScriptReactiveTaskController ()
 
 DtVreScriptReactiveTaskController (const DtVreScriptReactiveTaskController &other)
 
DtVreScriptReactiveTaskControlleroperator= (const DtVreScriptReactiveTaskController &other)
 

Constructor & Destructor Documentation

◆ DtVreScriptReactiveTaskController() [1/3]

makVre::DtVreScriptReactiveTaskController::DtVreScriptReactiveTaskController ( const DtString & name,
DtLocalObject * owner,
DtSimulationServices * simManager,
DtComponentDescriptor * desc,
DtReaderWriterRegistry * parentRegistry )

Constructor.

Parameters
nameThe name of this component
ownerThe local object that owns this component
simManagerThe simulation services manager
descComponent descriptor with configuration parameters
parentRegistryOptional parent registry for reader/writer functionality

Creates a new script reactive task controller component with the specified parameters. Initializes the role-based reactive task management system.

Referenced by DtVreScriptReactiveTaskController(), and operator=().

◆ DtVreScriptReactiveTaskController() [2/3]

makVre::DtVreScriptReactiveTaskController::DtVreScriptReactiveTaskController ( )
private

Default constructor (not implemented)

Default constructor is private and not implemented to prevent creation of instances without proper initialization.

◆ DtVreScriptReactiveTaskController() [3/3]

makVre::DtVreScriptReactiveTaskController::DtVreScriptReactiveTaskController ( const DtVreScriptReactiveTaskController & other)
private

Copy constructor (not implemented)

Copy constructor is private and not implemented to prevent copy construction.

References DtVreScriptReactiveTaskController().

Member Function Documentation

◆ tick()

virtual void makVre::DtVreScriptReactiveTaskController::tick ( )
overridevirtual

Updates the controller state each simulation frame.

Overridden to check if any reactive tasks should be enabled or disabled based on what roles are currently engaged on the entity. If the engaged roles have changed since the last tick, updates the reactive tasks accordingly.

◆ creator()

static DtSimComponent * makVre::DtVreScriptReactiveTaskController::creator ( const DtString & name,
DtLocalObject * owner,
DtSimulationServices * simManager,
DtComponentDescriptor * desc,
DtReaderWriterRegistry * parentRegistry )
static

Factory method to create a new instance of this component.

Parameters
nameThe name for the new component
ownerThe local object that will own this component
simManagerThe simulation services manager
descOptional component descriptor
parentRegistryOptional parent registry for reader/writer functionality
Returns
Pointer to the newly created component

Static factory method used by the component creation system to instantiate new instances of this component type.

◆ shouldScriptBeEnabled()

virtual bool makVre::DtVreScriptReactiveTaskController::shouldScriptBeEnabled ( const DtString & scriptName,
const std::set< std::string > & currentRoles ) const
virtual

Determines if a reactive task script should be enabled.

Parameters
scriptNameThe name of the script to check
currentRolesThe set of roles currently engaged on the entity
Returns
True if the script should be enabled, false otherwise

Determines whether a reactive task script should be enabled or disabled based on the allowed scripts configuration passed in through the descriptor and the currently engaged roles. A script is enabled if any of the current roles match the roles allowed for that script.

◆ updateReactiveTasks()

virtual void makVre::DtVreScriptReactiveTaskController::updateReactiveTasks ( const std::set< std::string > & currentRoles)
protectedvirtual

Updates all reactive tasks based on current roles.

Parameters
currentRolesThe set of roles currently engaged on the entity

Updates all the reactive tasks for the current entity by iterating through each task and calling shouldScriptBeEnabled() to determine if it should be enabled or disabled. Then applies those settings to the reactive tasks.

◆ getRolesEngagedOnEntity()

virtual void makVre::DtVreScriptReactiveTaskController::getRolesEngagedOnEntity ( std::set< std::string > & roles)
protectedvirtual

Retrieves the set of roles currently engaged on the entity.

Parameters
rolesOutput parameter to be populated with the current roles

Populates the provided set with the names of all roles currently engaged on the entity. This information is used to determine which reactive tasks should be enabled.

◆ operator=()

DtVreScriptReactiveTaskController & makVre::DtVreScriptReactiveTaskController::operator= ( const DtVreScriptReactiveTaskController & other)
private

Assignment operator (not implemented)

Returns
Reference to this object

Assignment operator is private and not implemented to prevent assignment.

References DtVreScriptReactiveTaskController().

Member Data Documentation

◆ myDescriptor

DtVreScriptReactiveTaskControllerDescriptor* makVre::DtVreScriptReactiveTaskController::myDescriptor
protected

Pointer to the component's descriptor.

Contains the configuration parameters for this component, including the mapping of scripts to their allowed roles.

◆ myLastTickRolesEngaged

std::set<std::string> makVre::DtVreScriptReactiveTaskController::myLastTickRolesEngaged
protected

Set of roles that were engaged during the last tick.

Stores the set of role names that were engaged on the entity during the previous simulation frame. Used to detect changes in engaged roles.

◆ myScriptIdsWithRolesToAllow

std::map<DtString, std::vector<std::string> > makVre::DtVreScriptReactiveTaskController::myScriptIdsWithRolesToAllow
protected

Mapping of script IDs to their allowed roles.

Maps each script ID to a vector of role names that are allowed to enable that script. A script is enabled if any of the current roles match any of the allowed roles for that script.


The documentation for this class was generated from the following file: