|
VR-Engage
2.3
|
| SetControllerBase | The 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>
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 |
| 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.
| name | The name of this component. |
| owner | The local object that owns this component. |
| simManager | The simulation services manager. |
| desc | Component descriptor with configuration parameters. |
| parentRegistry | Optional parent registry for reader/writer functionality. |
Referenced by DtVreSetController(), and operator=().
|
overridevirtual |
Virtual destructor.
Disconnects the registered signal handlers, unregisters set-data callbacks, and releases any temporarily detached role-state property.
|
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.
|
delete |
Copy constructor (not implemented)
Copy constructor is private and not implemented to prevent copy construction.
| orig | The controller instance that would have been copied. |
References DtVreSetController().
|
delete |
Assignment operator (not implemented)
Assignment operator is private and not implemented to prevent assignment.
| orig | The controller instance that would have been assigned from. |
References DtVreSetController().
|
virtual |
Sets the simulation radio and registers callbacks.
Overrides the base method, then registers callbacks for VR-Engage role-control and ownership-transfer requests.
| radio | The simulation radio to use for communication. |
Reimplemented in makVre::DtVreHumanSetController.
|
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.
| msg | The simulation message containing control-assignment information. |
| usrData | User data pointer, typically pointing to an instance of this class. |
|
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.
| msg | The simulation message containing the disable-ownership-transfer request. |
| usrData | User data pointer, typically pointing to an instance of this class. |
|
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().
| msg | The simulation message containing control-assignment information. |
|
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.
| msg | The simulation message containing the disable-ownership-transfer request. |
|
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.
| msg | The simulation message containing the restore request. |
|
protected |
Creates or updates the next-frame LastVrfSim state property.
| simAddress | The VR-Forces simulation address to store. |
|
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.
| saveType | The type of save operation currently in progress. |
|
protectedvirtual |
Restores the top-level "Roles" state property after eligible saves.
Reattaches the property previously detached by processPreSave() once the checkpoint save has completed.
| saveType | The type of save operation that has just completed. |
|
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.
| stationId | The station identifier that should receive the replayed assignment. |
| roleName | The role name to reassign to the station. |
|
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.
| stationId | The controlling station identifier stored in the role entry. |
| roleType | The top-level role-type key being updated. |
| roleName | The entity-role name stored in the structured role entry. |
|
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.
| roleName | The top-level role-type key for the restored entry. |
| stationItem | The restored station entry under consideration. |
Reimplemented in makVre::DtVreHumanSetController.
|
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.
|
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.
| change | The queued control change to apply. |
|
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.
|
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.
|
virtual |
Processes altitude setting messages with enhanced terrain handling.
| msg | The 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.
|
static |
Factory method to create a new instance of this component.
| name | The name for the new component |
| owner | The local object that will own this component |
| simManager | The simulation services manager |
| desc | Optional component descriptor |
| parentRegistry | Optional parent registry for reader/writer functionality |
Static factory method used by the component creation system to instantiate new instances of this component type.
|
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.
|
protected |
True once the entity has completed a convert-to-local handoff.
|
protected |
Temporarily detached top-level "Roles" state property during checkpoint save.
|
protected |
Connection for ownership-transfer notifications from the local object.
|
protected |
Connection for pre-save notifications from the local object.
|
protected |
Connection for post-save notifications from the local object.
|
protected |
FIFO queue of pending role-control changes to apply during tick().