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

Detailed Description

This class extends the basic VRF munition loader to provide VREngage-specific munition loading behavior. It adds support for controlling weapon state during loading (such as lowering/raising the weapon), managing ammunition-related state properties for UI display, and handling weapon state restoration when loading from saved scenarios.

#include <vreMunitionLoader.h>

Inheritance diagram for makVre::DtVreMunitionLoader:
[legend]

Public Member Functions

 DtVreMunitionLoader (const DtString &rwName=DtString::nullString(), DtReaderWriterRegistry *parentRegistry=0)
 
 DtVreMunitionLoader (const DtVreMunitionLoader &orig, const DtString &rwName=DtString::nullString(), DtReaderWriterRegistry *parentRegistry=0)
 
const DtVreMunitionLoaderoperator= (const DtVreMunitionLoader &orig)
 
virtual ~DtVreMunitionLoader () override
 
virtual bool init (DtLocalObject *entity)
 
virtual void tick (const DtSimMunition &correctMunition, DtDetonatorFuze correctFuze, DtTime currentTime, int roundsAvailable=1) override
 
virtual void useRounds (const int nRounds) override
 
virtual void initializeClipStateProperty ()
 
virtual void disableAmmoStatePropertiesThresholding ()
 
virtual void enableAmmoStatePropertiesThresholding ()
 
virtual void load (DtTime startLoadTime, const DtSimMunition &munition, DtDetonatorFuze fuze) override
 

Protected Member Functions

virtual void setAmmoStatePropertiesThresholdAlgorithm (int thresholdAlgorithm)
 
virtual void processSetRestored (DtSimMessage *msg)
 

Static Protected Member Functions

static void setRestoredCallback (DtSimMessage *msg, void *usrData)
 

Protected Attributes

DtLocalObject * myEntity
 
bool myReinitialize
 

Constructor & Destructor Documentation

◆ DtVreMunitionLoader() [1/2]

makVre::DtVreMunitionLoader::DtVreMunitionLoader ( const DtString & rwName = DtString::nullString(),
DtReaderWriterRegistry * parentRegistry = 0 )

Constructor with optional name.

Parameters
rwNameOptional reader/writer name
parentRegistryOptional parent registry for reader/writer functionality

Creates a new munition loader with the specified name.

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

◆ DtVreMunitionLoader() [2/2]

makVre::DtVreMunitionLoader::DtVreMunitionLoader ( const DtVreMunitionLoader & orig,
const DtString & rwName = DtString::nullString(),
DtReaderWriterRegistry * parentRegistry = 0 )

Copy constructor.

Parameters
origThe source munition loader to copy from
rwNameOptional reader/writer name
parentRegistryOptional parent registry for reader/writer functionality

Creates a new munition loader as a copy of the provided original.

References DtVreMunitionLoader().

◆ ~DtVreMunitionLoader()

virtual makVre::DtVreMunitionLoader::~DtVreMunitionLoader ( )
overridevirtual

Virtual destructor.

Cleans up resources used by the munition loader.

Member Function Documentation

◆ operator=()

const DtVreMunitionLoader & makVre::DtVreMunitionLoader::operator= ( const DtVreMunitionLoader & orig)

Assignment operator.

Parameters
origThe source munition loader to copy from
Returns
Reference to this munition loader after assignment

Assigns the contents of the provided munition loader to this one.

References DtVreMunitionLoader().

◆ init()

virtual bool makVre::DtVreMunitionLoader::init ( DtLocalObject * entity)
virtual

Initializes the munition loader with an entity.

Parameters
entityPointer to the entity this loader is associated with
Returns
True if initialization was successful, false otherwise

Initializes the munition loader and sets up callbacks for state restoration. Adds the setRestoredCallback to reinitialize AmmoInClips state properties when the entity is restored from a saved scenario.

◆ tick()

virtual void makVre::DtVreMunitionLoader::tick ( const DtSimMunition & correctMunition,
DtDetonatorFuze correctFuze,
DtTime currentTime,
int roundsAvailable = 1 )
overridevirtual

Updates the munition loader state.

Parameters
correctMunitionThe current munition type
correctFuzeThe current fuze type
currentTimeThe current simulation time
roundsAvailableNumber of rounds available to load (default: 1)

Updates the munition loader state based on the current time and availability. Overridden to implement VREngage-specific behavior such as lowering the gun while loading and raising it once done.

◆ useRounds()

virtual void makVre::DtVreMunitionLoader::useRounds ( const int nRounds)
overridevirtual

Uses a specified number of rounds from the magazine.

Parameters
nRoundsThe number of rounds to consume

Decrements the ammunition count by the specified number of rounds. Overridden to update the state properties with the number of rounds left in the clip for UI display and networking purposes.

◆ initializeClipStateProperty()

virtual void makVre::DtVreMunitionLoader::initializeClipStateProperty ( )
virtual

Initializes a clip state property.

Parameters
nameThe name of the weapon system for this clip

Initializes the state property used to track and display the ammunition count for the specified weapon system. This property will be used for UI display and networking to clients.

◆ disableAmmoStatePropertiesThresholding()

virtual void makVre::DtVreMunitionLoader::disableAmmoStatePropertiesThresholding ( )
virtual

Disables thresholding for ammunition state properties.

Disables the thresholding setting for clip state properties to send updates every frame. This ensures that player-controlled entities receive the most accurate data for displaying ammunition counts in the HUD.

◆ enableAmmoStatePropertiesThresholding()

virtual void makVre::DtVreMunitionLoader::enableAmmoStatePropertiesThresholding ( )
virtual

Enables thresholding for ammunition state properties.

Enables the thresholding setting for clip state properties to reduce network traffic. Updates are not sent as frequently for entities that are not under player control since precise ammunition display is less critical.

◆ load()

virtual void makVre::DtVreMunitionLoader::load ( DtTime startLoadTime,
const DtSimMunition & munition,
DtDetonatorFuze fuze )
overridevirtual

Begins loading a munition into the weapon system.

Parameters
startLoadTimeThe simulation time at which loading begins.
munitionThe munition type to be loaded.
fuzeThe fuze type to be used with the munition.

Starts the loading process for the specified munition and fuze at the given simulation time. This overrides the base implementation to also initialize the clip state property, ensuring that ammunition counts are properly tracked and updated for UI and networking. This is important for accurate display of ammunition status in the HUD and for synchronizing state across clients.

◆ setAmmoStatePropertiesThresholdAlgorithm()

virtual void makVre::DtVreMunitionLoader::setAmmoStatePropertiesThresholdAlgorithm ( int thresholdAlgorithm)
protectedvirtual

Sets the thresholding algorithm for ammunition state properties.

Parameters
thresholdAlgorithmThe threshold algorithm to use (DtThresholdPercent or DtThresholdNone)

Sets the thresholding approach for clip state properties. Set thresholdAlgorithm to DtThresholdPercent to throttle sending of state updates, or DtThresholdNone to send updates every frame.

◆ setRestoredCallback()

static void makVre::DtVreMunitionLoader::setRestoredCallback ( DtSimMessage * msg,
void * usrData )
staticprotected

Static callback for state restoration.

Parameters
msgPointer to the simulation message
usrDataUser data pointer containing the munition loader instance

Static callback function called when the entity is restored from a saved scenario. Sets the myReinitialize flag to true to trigger state property reinitialization on the next tick.

◆ processSetRestored()

virtual void makVre::DtVreMunitionLoader::processSetRestored ( DtSimMessage * msg)
protectedvirtual

Processes a state restoration message.

Parameters
msgPointer to the simulation message

Processes a state restoration message by setting the reinitialization flag.

Member Data Documentation

◆ myEntity

DtLocalObject* makVre::DtVreMunitionLoader::myEntity
protected

Pointer to the associated entity.

Stores a pointer to the entity this munition loader is associated with.

◆ myReinitialize

bool makVre::DtVreMunitionLoader::myReinitialize
protected

Reinitialization flag.

When true, the state properties will be reinitialized on the next tick. This is typically set after a state restoration operation.


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