|
VR-Engage
2.2
|
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>
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 DtVreMunitionLoader & | operator= (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 |
| makVre::DtVreMunitionLoader::DtVreMunitionLoader | ( | const DtString & | rwName = DtString::nullString(), |
| DtReaderWriterRegistry * | parentRegistry = 0 ) |
Constructor with optional name.
| rwName | Optional reader/writer name |
| parentRegistry | Optional parent registry for reader/writer functionality |
Creates a new munition loader with the specified name.
Referenced by DtVreMunitionLoader(), and operator=().
| makVre::DtVreMunitionLoader::DtVreMunitionLoader | ( | const DtVreMunitionLoader & | orig, |
| const DtString & | rwName = DtString::nullString(), | ||
| DtReaderWriterRegistry * | parentRegistry = 0 ) |
Copy constructor.
| orig | The source munition loader to copy from |
| rwName | Optional reader/writer name |
| parentRegistry | Optional parent registry for reader/writer functionality |
Creates a new munition loader as a copy of the provided original.
References DtVreMunitionLoader().
|
overridevirtual |
Virtual destructor.
Cleans up resources used by the munition loader.
| const DtVreMunitionLoader & makVre::DtVreMunitionLoader::operator= | ( | const DtVreMunitionLoader & | orig | ) |
Assignment operator.
| orig | The source munition loader to copy from |
Assigns the contents of the provided munition loader to this one.
References DtVreMunitionLoader().
|
virtual |
Initializes the munition loader with an entity.
| entity | Pointer to the entity this loader is associated with |
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.
|
overridevirtual |
Updates the munition loader state.
| correctMunition | The current munition type |
| correctFuze | The current fuze type |
| currentTime | The current simulation time |
| roundsAvailable | Number 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.
|
overridevirtual |
Uses a specified number of rounds from the magazine.
| nRounds | The 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.
|
virtual |
Initializes a clip state property.
| name | The 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.
|
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.
|
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.
|
overridevirtual |
Begins loading a munition into the weapon system.
| startLoadTime | The simulation time at which loading begins. |
| munition | The munition type to be loaded. |
| fuze | The 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.
|
protectedvirtual |
Sets the thresholding algorithm for ammunition state properties.
| thresholdAlgorithm | The 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.
|
staticprotected |
Static callback for state restoration.
| msg | Pointer to the simulation message |
| usrData | User 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.
|
protectedvirtual |
Processes a state restoration message.
| msg | Pointer to the simulation message |
Processes a state restoration message by setting the reinitialization flag.
|
protected |
Pointer to the associated entity.
Stores a pointer to the entity this munition loader is associated with.
|
protected |
Reinitialization flag.
When true, the state properties will be reinitialized on the next tick. This is typically set after a state restoration operation.