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

Detailed Description

DtWeaponResourceLogic tracks available weapon systems and munitions, processes resource list updates from simulation state messages, and maintains weapon-related state attributes. It maps between internal system names and human-readable names, handles resource dependencies, and enables weapons based on equipment availability.

#include <weaponResourceLogic.h>

Inheritance diagram for makVre::DtWeaponResourceLogic:
[legend]

Public Member Functions

 DtWeaponResourceLogic ()
 
virtual ~DtWeaponResourceLogic () override
 
virtual bool initialize (makVre::DtPlayerStation *player, makVre::DtInitTable &config) override
 
virtual bool postInitialize () override
 
virtual void tick (double dt) override
 
virtual void shutdown () override
 
virtual const char * type () const override
 
virtual std::vector< std::string > resourceMappingKeys ()
 
virtual std::string lookUpShortName (const std::string &vrfResourceName)
 
virtual std::string lookUpDiguyHandItem (const std::string &vrfResourceName)
 
virtual std::string lookUpResourceByDeployedEquipment (const DtEntityType &equipmentType)
 
virtual bool doesHandItemMatch (const std::string &vrfResourceName, const std::string &handItem)
 
template<typename T>
lookUpField (std::string resource, const std::string &field, T defaultValue)
 
- Public Member Functions inherited from makVre::DtPlayerComponent
 DtPlayerComponent ()
 
virtual ~DtPlayerComponent ()
 
virtual void setName (const std::string &name)
 
virtual const std::string & name ()
 
virtual DtPlayerStationplayer ()
 
virtual DtAttributeHandleplayerAttributeStore ()
 
virtual const DtAttributeHandleplayerAttributeStore () const
 

Protected Member Functions

virtual makVre::DtVreMessageResult handleResourceUpdate (makVre::DtVreMessage *msg)
 
virtual void resourceChanged (const DtAttributeHandle &changed)
 
virtual void addWeaponToList (const std::string &resource)
 
virtual void removeWeaponFromList (const std::string &resource)
 
- Protected Member Functions inherited from makVre::DtPlayerComponent
virtual void initializeStateAttributes ()
 

Protected Attributes

DtInitTable myResourceMappings
 
DtAttributeHandleType< std::vector< std::string > > myResourceStore
 
DtAttributeChangeCallback myResourceCallback
 
- Protected Attributes inherited from makVre::DtPlayerComponent
std::string myName
 
DtInitTable myConfig
 
DtPlayerStationmyPlayer
 
makVrv::DtDe * myDe
 
DtEntityResolvermyResolver
 
DtAttributeCallbackManager myAttributeCallbacks
 

Constructor & Destructor Documentation

◆ DtWeaponResourceLogic()

makVre::DtWeaponResourceLogic::DtWeaponResourceLogic ( )

Constructor for DtWeaponResourceLogic.

Initializes the component with default settings

◆ ~DtWeaponResourceLogic()

virtual makVre::DtWeaponResourceLogic::~DtWeaponResourceLogic ( )
overridevirtual

Virtual destructor for DtWeaponResourceLogic.

Member Function Documentation

◆ initialize()

virtual bool makVre::DtWeaponResourceLogic::initialize ( makVre::DtPlayerStation * player,
makVre::DtInitTable & config )
overridevirtual

Initializes the weapon resource logic component.

Parameters
playerPointer to the player station this component belongs to
configConfiguration table containing resource mappings
Returns
True if initialization succeeded, false otherwise

Reads resource mappings configuration, initializes state attributes, and sets up message handlers for simulation state updates

Reimplemented from makVre::DtPlayerComponent.

References makVre::DtPlayerComponent::player().

◆ postInitialize()

virtual bool makVre::DtWeaponResourceLogic::postInitialize ( )
overridevirtual

Performs post-initialization after all components are initialized.

Returns
True if post-initialization succeeded, false otherwise

Updates the weapon list based on the current resource list

Reimplemented from makVre::DtPlayerComponent.

◆ tick()

virtual void makVre::DtWeaponResourceLogic::tick ( double dt)
overridevirtual

Called every frame to update component state.

Parameters
dtDelta time since the last frame in seconds

Current implementation is empty as updates occur through message handlers

Implements makVre::DtPlayerComponent.

◆ shutdown()

virtual void makVre::DtWeaponResourceLogic::shutdown ( )
overridevirtual

Shuts down the weapon resource logic component.

Removes message handlers and attribute change callbacks

Reimplemented from makVre::DtPlayerComponent.

◆ type()

virtual const char * makVre::DtWeaponResourceLogic::type ( ) const
overridevirtual

Returns the type identifier for this component.

Returns
The type string for DtWeaponResourceLogic

Implements makVre::DtPlayerComponent.

◆ resourceMappingKeys()

virtual std::vector< std::string > makVre::DtWeaponResourceLogic::resourceMappingKeys ( )
virtual

Gets a list of all resource mappings keys.

Returns
Vector of strings containing all resource mapping keys

Returns the list of all keys in the resource mappings table

◆ lookUpShortName()

virtual std::string makVre::DtWeaponResourceLogic::lookUpShortName ( const std::string & vrfResourceName)
virtual

Looks up the human-readable short name for a resource.

Parameters
vrfResourceNameResource name in VRF format (possibly with system prefix)
Returns
Short name for the resource or the original name if not found

Retrieves the human-readable short name for a given resource

◆ lookUpDiguyHandItem()

virtual std::string makVre::DtWeaponResourceLogic::lookUpDiguyHandItem ( const std::string & vrfResourceName)
virtual

Looks up the diguy hand item for a resource.

Parameters
vrfResourceNameResource name in VRF format
Returns
Hand item name or "default" if not found

Retrieves the diguy hand item corresponding to a resource

◆ lookUpResourceByDeployedEquipment()

virtual std::string makVre::DtWeaponResourceLogic::lookUpResourceByDeployedEquipment ( const DtEntityType & equipmentType)
virtual

Finds a resource name by matching against an entity type.

Parameters
equipmentTypeEntity type to match against patterns
Returns
Resource name if a match is found, empty string otherwise

Finds the resource name (table key) by checking a deployed equipment type against the patterns in the "deployedEquipmentTypes" table. The pattern represents the external entity the ownship entity is currently using (such as a tripod-mounted launcher).

◆ doesHandItemMatch()

virtual bool makVre::DtWeaponResourceLogic::doesHandItemMatch ( const std::string & vrfResourceName,
const std::string & handItem )
virtual

Checks if a hand item matches a resource.

Parameters
vrfResourceNameResource name in VRF format
handItemHand item to check for a match
Returns
True if the hand item matches this resource, false otherwise

Determines if a hand item matches either the primary diguy hand item or one of the alternative items in the itemMatches list

References lookUpField().

◆ lookUpField()

template<typename T>
T makVre::DtWeaponResourceLogic::lookUpField ( std::string resource,
const std::string & field,
T defaultValue )

Looks up a field value for a resource in the resource mappings table.

Template Parameters
TType of the field value to retrieve
Parameters
resourceResource name in VRF format (possibly with system prefix)
fieldName of the field to look up
defaultValueDefault value to return if the field is not found
Returns
Value of the field or defaultValue if not found

Retrieves a field value from the resource mappings table, handling cases where the resource name may include system prefixes or contain special characters

References makVre::DtInitTable::findData(), makVre::DtLuaObject::hasField(), LOG_DEBUG, and myResourceMappings.

Referenced by doesHandItemMatch().

◆ handleResourceUpdate()

virtual makVre::DtVreMessageResult makVre::DtWeaponResourceLogic::handleResourceUpdate ( makVre::DtVreMessage * msg)
protectedvirtual

Handles resource update.

Parameters
msgResource update
Returns
Message handling result indicating if the message was handled

Processes resource updates to update resource and equipment information

◆ resourceChanged()

virtual void makVre::DtWeaponResourceLogic::resourceChanged ( const DtAttributeHandle & changed)
protectedvirtual

◆ addWeaponToList()

virtual void makVre::DtWeaponResourceLogic::addWeaponToList ( const std::string & resource)
protectedvirtual

◆ removeWeaponFromList()

virtual void makVre::DtWeaponResourceLogic::removeWeaponFromList ( const std::string & resource)
protectedvirtual

Member Data Documentation

◆ myResourceMappings

DtInitTable makVre::DtWeaponResourceLogic::myResourceMappings
protected

Configuration table containing resource mappings.

Referenced by lookUpField().

◆ myResourceStore

DtAttributeHandleType<std::vector<std::string> > makVre::DtWeaponResourceLogic::myResourceStore
protected

◆ myResourceCallback

DtAttributeChangeCallback makVre::DtWeaponResourceLogic::myResourceCallback
protected

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