VR-Engage  2.3
Loading...
Searching...
No Matches
makVre::DtVreSetController< SetControllerBase > Class Template Reference

Detailed Description

template<typename SetControllerBase>
class makVre::DtVreSetController< SetControllerBase >
Template Parameters
SetControllerBaseThe base set controller class to extend with VR-Engage functionality

DtVreSetController is a template class that extends base set controllers with VR-Engage specific functionality for handling DtSetVreControlledRequest messages. These messages assign control of entity roles to specific VR-Engage player stations, supporting multi-station control of a single entity with different roles.

The controller also handles the publishing of resource information for player-controlled entities and provides special handling for altitude setting commands.

All VR-Engage specific set controllers should derive from this template class.

Uses Descriptor Type: DtComponentDescriptor

#include <vreSetController.h>

Inheritance diagram for makVre::DtVreSetController< SetControllerBase >:
[legend]

Classes

struct  SetVreControlledContent
 

Public Member Functions

 DtVreSetController (const DtString &name, DtLocalObject *owner, DtSimulationServices *simManager, DtComponentDescriptor *desc=nullptr, DtReaderWriterRegistry *parentRegistry=nullptr)
 
virtual ~DtVreSetController () override
 
 DtVreSetController ()=delete
 
 DtVreSetController (const DtVreSetController &orig)=delete
 
const DtVreSetController & operator= (const DtVreSetController &orig)=delete
 
virtual void setRadio (DtSimRadio *radio)
 
virtual void processSetPlayerControlled (DtSimMessage *msg)
 
virtual void processSetDisableOwnershipTransfer (DtSimMessage *msg)
 
virtual void processSetRestore (DtSimMessage *msg)
 
virtual void updatePlayerControlled (const SetVreControlledContent &change)
 
virtual void preFirstTickInit ()
 
virtual void tick ()
 
virtual void processSetAltitude (DtSimMessage *msg)
 
- Public Member Functions inherited from makVre::DtVreSimComponent< SetControllerBase >
 DtVreSimComponent (const DtString &name, DtLocalObject *owner, DtSimulationServices *simManager, DtComponentDescriptor *desc=0, DtReaderWriterRegistry *parentRegistry=0)
 
virtual ~DtVreSimComponent ()
 
bool isPlayerControlled (const std::string &role="") const
 
std::vector< std::string > controllingStations (const std::string &role) const
 
std::vector< std::string > engagedRoles () const
 
DtString entitySystemName () const
 

Static Public Member Functions

static void setPlayerControlledCallback (DtSimMessage *msg, void *usrData)
 
static void setDisableOwnershipTransferCallback (DtSimMessage *msg, void *usrData)
 
static DtSimComponent * creator (const DtString &name, DtLocalObject *owner, DtSimulationServices *simManager, DtComponentDescriptor *desc=nullptr, DtReaderWriterRegistry *parentRegistry=nullptr)
 

Protected Member Functions

void setLastVrfSimStateProperty (const DtString &simAddress)
 
virtual void processPreSave (DtLocalObject::SaveType saveType)
 
virtual void processPostSave (DtLocalObject::SaveType saveType)
 
virtual void sendAssignRolePlayerMessage (const DtString &stationId, const DtString &roleName)
 
bool isEmbarkedRoleAssignment (const DtString &stationId, const std::string &roleType, const std::string &roleName) const
 
virtual bool shouldReplayRestoredRoleAssignment (const DtString &roleName, const DtStatePropertyRoleStationItem &stationItem)
 
virtual void replayRestoredRoleAssignments ()
 

Protected Attributes

bool myWarnedAboutResource
 
bool myObjectWasTransferred = false
 
DtPropertyInterface * myDetachedRolesStateProperty = nullptr
 
boost::signals2::connection myOwnershipTransferConn
 
boost::signals2::connection myPreSaveConn
 
boost::signals2::connection myPostSaveConn
 
std::list< SetVreControlledContent > myPendingControlChanges
 

Constructor & Destructor Documentation

◆ DtVreSetController() [1/3]

template<typename SetControllerBase>
makVre::DtVreSetController< SetControllerBase >::DtVreSetController ( const DtString & name,
DtLocalObject * owner,
DtSimulationServices * simManager,
DtComponentDescriptor * desc = nullptr,
DtReaderWriterRegistry * parentRegistry = nullptr )

Constructor.

Creates the controller, initializes its internal state, and connects the ownership-transfer and save hooks used by its role-state bookkeeping.

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.

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

◆ ~DtVreSetController()

template<typename SetControllerBase>
virtual makVre::DtVreSetController< SetControllerBase >::~DtVreSetController ( )
overridevirtual

Virtual destructor.

Disconnects the registered signal handlers, unregisters set-data callbacks, and releases any temporarily detached role-state property.

◆ DtVreSetController() [2/3]

template<typename SetControllerBase>
makVre::DtVreSetController< SetControllerBase >::DtVreSetController ( )
delete

Default constructor (not implemented)

Default constructor is private and not implemented to prevent creation of instances without proper initialization. Here because the compiler would generate an unprotected one otherwise.

◆ DtVreSetController() [3/3]

template<typename SetControllerBase>
makVre::DtVreSetController< SetControllerBase >::DtVreSetController ( const DtVreSetController< SetControllerBase > & orig)
delete

Copy constructor (not implemented)

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

Parameters
origThe controller instance that would have been copied.

References DtVreSetController().

Member Function Documentation

◆ operator=()

template<typename SetControllerBase>
const DtVreSetController & makVre::DtVreSetController< SetControllerBase >::operator= ( const DtVreSetController< SetControllerBase > & orig)
delete

Assignment operator (not implemented)

Assignment operator is private and not implemented to prevent assignment.

Parameters
origThe controller instance that would have been assigned from.
Returns
A reference to this object. This operator is declared but not implemented.

References DtVreSetController().

◆ setRadio()

template<typename SetControllerBase>
virtual void makVre::DtVreSetController< SetControllerBase >::setRadio ( DtSimRadio * radio)
virtual

Sets the simulation radio and registers callbacks.

Overrides the base method, then registers callbacks for VR-Engage role-control and ownership-transfer requests.

Parameters
radioThe simulation radio to use for communication.

Reimplemented in makVre::DtVreHumanSetController.

◆ setPlayerControlledCallback()

template<typename SetControllerBase>
static void makVre::DtVreSetController< SetControllerBase >::setPlayerControlledCallback ( DtSimMessage * msg,
void * usrData )
static

Static callback function for player control messages.

Static function registered as a callback to handle VR-Engage control messages. Forwards the message to the appropriate instance's processSetPlayerControlled method.

Parameters
msgThe simulation message containing control-assignment information.
usrDataUser data pointer, typically pointing to an instance of this class.

◆ setDisableOwnershipTransferCallback()

template<typename SetControllerBase>
static void makVre::DtVreSetController< SetControllerBase >::setDisableOwnershipTransferCallback ( DtSimMessage * msg,
void * usrData )
static

Static callback function for ownership-transfer disable messages.

Static function registered as a callback to handle scripted ownership-transfer control messages. Forwards the message to the appropriate instance's processSetDisableOwnershipTransfer method.

Parameters
msgThe simulation message containing the disable-ownership-transfer request.
usrDataUser data pointer, typically pointing to an instance of this class.

◆ processSetPlayerControlled()

template<typename SetControllerBase>
virtual void makVre::DtVreSetController< SetControllerBase >::processSetPlayerControlled ( DtSimMessage * msg)
virtual

Processes a VR-Engage control assignment message.

Extracts the requested station, roles, role metadata, and control flag from a DtSetVreControlledRequest and queues the change so it can be applied later during tick().

Parameters
msgThe simulation message containing control-assignment information.

◆ processSetDisableOwnershipTransfer()

template<typename SetControllerBase>
virtual void makVre::DtVreSetController< SetControllerBase >::processSetDisableOwnershipTransfer ( DtSimMessage * msg)
virtual

Processes a disable-ownership-transfer request.

Reads the scripted-task variable named "value" and mirrors it into the next-frame "DisableOwnershipTransfer" state property when present.

Parameters
msgThe simulation message containing the disable-ownership-transfer request.

◆ processSetRestore()

template<typename SetControllerBase>
virtual void makVre::DtVreSetController< SetControllerBase >::processSetRestore ( DtSimMessage * msg)
virtual

Restores live ownership-transfer and role-occupancy state after an entity reset.

First delegates to the VR-Forces handler to restore entity state, then restores the live LastVrfSim value and copies the current-frame "Roles" state-property map into the next frame. This preserves the ownership return target and player control through a reset or reset-in-place operation.

Parameters
msgThe simulation message containing the restore request.

◆ setLastVrfSimStateProperty()

template<typename SetControllerBase>
void makVre::DtVreSetController< SetControllerBase >::setLastVrfSimStateProperty ( const DtString & simAddress)
protected

Creates or updates the next-frame LastVrfSim state property.

Parameters
simAddressThe VR-Forces simulation address to store.

◆ processPreSave()

template<typename SetControllerBase>
virtual void makVre::DtVreSetController< SetControllerBase >::processPreSave ( DtLocalObject::SaveType saveType)
protectedvirtual

Removes the top-level "Roles" state property before eligible saves.

This is currently limited to checkpoint saves so role occupancy is not serialized into the saved data while the surrounding checkpoint is written.

Parameters
saveTypeThe type of save operation currently in progress.

◆ processPostSave()

template<typename SetControllerBase>
virtual void makVre::DtVreSetController< SetControllerBase >::processPostSave ( DtLocalObject::SaveType saveType)
protectedvirtual

Restores the top-level "Roles" state property after eligible saves.

Reattaches the property previously detached by processPreSave() once the checkpoint save has completed.

Parameters
saveTypeThe type of save operation that has just completed.

◆ sendAssignRolePlayerMessage()

template<typename SetControllerBase>
virtual void makVre::DtVreSetController< SetControllerBase >::sendAssignRolePlayerMessage ( const DtString & stationId,
const DtString & roleName )
protectedvirtual

Sends one frontend role-assignment replay message.

Broadcasts a DtIfAssignRolePlayer message for a single station/role pair so the matching frontend station can restore its assignment state. Marks the replay so the frontend can apply its reengagement policy.

Parameters
stationIdThe station identifier that should receive the replayed assignment.
roleNameThe role name to reassign to the station.

◆ isEmbarkedRoleAssignment()

template<typename SetControllerBase>
bool makVre::DtVreSetController< SetControllerBase >::isEmbarkedRoleAssignment ( const DtString & stationId,
const std::string & roleType,
const std::string & roleName ) const
protected

Determines whether a role assignment on this entity is an embarked human role.

Checks directly embarked human objects for a matching controlling station and engaged embarked-role marker, allowing the backend to tag host-role occupancy entries without relying on frontend-provided embarkation flags.

Parameters
stationIdThe controlling station identifier stored in the role entry.
roleTypeThe top-level role-type key being updated.
roleNameThe entity-role name stored in the structured role entry.
Returns
True if the assignment represents an embarked human controlling a host role.

◆ shouldReplayRestoredRoleAssignment()

template<typename SetControllerBase>
virtual bool makVre::DtVreSetController< SetControllerBase >::shouldReplayRestoredRoleAssignment ( const DtString & roleName,
const DtStatePropertyRoleStationItem & stationItem )
protectedvirtual

Determines whether a restored station entry should emit a replay message.

The default implementation suppresses replay for embarked host-role entries because restoring the base human assignment is sufficient to re-chain the embarkation load on the frontend.

Parameters
roleNameThe top-level role-type key for the restored entry.
stationItemThe restored station entry under consideration.
Returns
True if a DtIfAssignRolePlayer message should be emitted for this entry.

Reimplemented in makVre::DtVreHumanSetController.

◆ replayRestoredRoleAssignments()

template<typename SetControllerBase>
virtual void makVre::DtVreSetController< SetControllerBase >::replayRestoredRoleAssignments ( )
protectedvirtual

Replays and clears restored role assignments from the "Roles" state property.

Scans the current-frame state properties first, then the next-frame state properties, and emits one replay message for each restored unique station/role pair that should be replayed to the frontend. After at least one message is sent, removes the restored role entries from the next-frame map so the re-engaging frontend repopulates them through its normal take-control path.

◆ updatePlayerControlled()

template<typename SetControllerBase>
virtual void makVre::DtVreSetController< SetControllerBase >::updatePlayerControlled ( const SetVreControlledContent & change)
virtual

Applies one queued role-occupancy change to the entity state.

Updates the next-frame "Roles" state-property map by adding or removing the requesting station from each role entry in the change payload.

Parameters
changeThe queued control change to apply.

◆ preFirstTickInit()

template<typename SetControllerBase>
virtual void makVre::DtVreSetController< SetControllerBase >::preFirstTickInit ( )
virtual

Initializes the controller before the first tick.

Performs initialization that must happen before the first tick but after the component is fully constructed. Creates or refreshes the LastVrfSim state property on full-capability simulators and calls the base class preFirstTickInit(). Preserves existing role assignments during ownership handoff. Otherwise, replays restored role assignments to the frontend and clears those entries so successful re-engagement republishes them through the normal control-acquisition path.

◆ tick()

template<typename SetControllerBase>
virtual void makVre::DtVreSetController< SetControllerBase >::tick ( )
virtual

Updates the controller state each simulation frame.

Applies at most one queued role-control change per frame. If the entity is not player controlled, the base controller tick continues to run normally; otherwise the base tick is skipped so CGF control logic does not take over.

◆ processSetAltitude()

template<typename SetControllerBase>
virtual void makVre::DtVreSetController< SetControllerBase >::processSetAltitude ( DtSimMessage * msg)
virtual

Processes altitude setting messages with enhanced terrain handling.

Parameters
msgThe simulation message containing altitude setting information

Overrides the base method to correctly handle setting altitude of 0 m above terrain. Provides special handling for altitude values of 0, which are interpreted as "place the entity directly on the terrain" rather than "place at 0 MSL". Also handles terrain clamping appropriately.

Reimplemented in makVre::DtVreAirVehicleSetController.

◆ creator()

template<typename SetControllerBase>
static DtSimComponent * makVre::DtVreSetController< SetControllerBase >::creator ( const DtString & name,
DtLocalObject * owner,
DtSimulationServices * simManager,
DtComponentDescriptor * desc = nullptr,
DtReaderWriterRegistry * parentRegistry = nullptr )
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
A pointer to the newly created component. Ownership is transferred to the caller or component-creation framework that requested it.

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

Member Data Documentation

◆ myWarnedAboutResource

template<typename SetControllerBase>
bool makVre::DtVreSetController< SetControllerBase >::myWarnedAboutResource
protected

Flag indicating if a resource warning has been logged.

Tracks whether a warning about exceeding the maximum resource string size has already been logged, to prevent spamming the log with the same warning.

◆ myObjectWasTransferred

template<typename SetControllerBase>
bool makVre::DtVreSetController< SetControllerBase >::myObjectWasTransferred = false
protected

True once the entity has completed a convert-to-local handoff.

◆ myDetachedRolesStateProperty

template<typename SetControllerBase>
DtPropertyInterface* makVre::DtVreSetController< SetControllerBase >::myDetachedRolesStateProperty = nullptr
protected

Temporarily detached top-level "Roles" state property during checkpoint save.

◆ myOwnershipTransferConn

template<typename SetControllerBase>
boost::signals2::connection makVre::DtVreSetController< SetControllerBase >::myOwnershipTransferConn
protected

Connection for ownership-transfer notifications from the local object.

◆ myPreSaveConn

template<typename SetControllerBase>
boost::signals2::connection makVre::DtVreSetController< SetControllerBase >::myPreSaveConn
protected

Connection for pre-save notifications from the local object.

◆ myPostSaveConn

template<typename SetControllerBase>
boost::signals2::connection makVre::DtVreSetController< SetControllerBase >::myPostSaveConn
protected

Connection for post-save notifications from the local object.

◆ myPendingControlChanges

template<typename SetControllerBase>
std::list<SetVreControlledContent> makVre::DtVreSetController< SetControllerBase >::myPendingControlChanges
protected

FIFO queue of pending role-control changes to apply during tick().


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