The Table Engine
RangedWeaponScript Class Reference

Controls the behavior of ranged weapons such as bows or guns. More...

#include <ranged_weapon_script.h>

+ Inheritance diagram for RangedWeaponScript:
+ Collaboration diagram for RangedWeaponScript:

Public Member Functions

 RangedWeaponScript ()
 Constructs a RangedWeaponScript with default or initial settings. More...
 
void input () override
 Processes input to handle shooting actions. More...
 
void update () override
 Updates the state of the weapon based on input and time constraints. More...
 
- Public Member Functions inherited from Script
 Script ()
 Default constructor, initializes an empty script. More...
 
 Script (std::string name)
 Constructs a Script with a specified name. More...
 
virtual ~Script ()
 Virtual destructor to allow for cleanup in derived script classes. More...
 
std::string getName ()
 Retrieves the name of the script. More...
 
GameObjectgetOwner ()
 Retrieves the owner GameObject of this script. More...
 
void setOwner (GameObject *owner)
 Sets the owner of this script. More...
 
virtual void render ()
 Virtual method for rendering operations. Should be overridden by derived classes. More...
 

Private Attributes

bool m_shoot
 Flag to indicate whether the weapon should shoot. More...
 
int m_lastFireTimeInMs
 Timestamp of the last shooting action in milliseconds. More...
 
int m_fireRatePerSecond
 Allowed number of shots per second to control shooting frequency. More...
 
bool m_animationPlayed
 Ensures that the shooting animation plays correctly. More...
 

Additional Inherited Members

- Public Attributes inherited from Script
std::string m_name
 Name of the script, useful for identification or debugging. More...
 
GameObjectm_owner
 Pointer to the GameObject that owns this script. More...
 

Detailed Description

Controls the behavior of ranged weapons such as bows or guns.

RangedWeaponScript manages the shooting actions of weapons, checks the fire rate to prevent shooting too frequently, and ensures that necessary animations are played when shooting.

Definition at line 21 of file ranged_weapon_script.h.

Constructor & Destructor Documentation

◆ RangedWeaponScript()

RangedWeaponScript::RangedWeaponScript ( )

Constructs a RangedWeaponScript with default or initial settings.

Initializes control variables and state tracking for the ranged weapon.

Definition at line 12 of file ranged_weapon_script.cpp.

Member Function Documentation

◆ input()

void RangedWeaponScript::input ( )
overridevirtual

Processes input to handle shooting actions.

Checks for relevant user inputs, like key presses, to trigger shooting. Ensures that shooting actions respect the defined fire rate.

Reimplemented from Script.

Definition at line 19 of file ranged_weapon_script.cpp.

◆ update()

void RangedWeaponScript::update ( )
overridevirtual

Updates the state of the weapon based on input and time constraints.

Manages the timing and state changes required to control shooting frequency and animation states. This method is called each frame of the game loop to ensure responsive weapon behavior.

Reimplemented from Script.

Definition at line 33 of file ranged_weapon_script.cpp.

Member Data Documentation

◆ m_animationPlayed

bool RangedWeaponScript::m_animationPlayed
private

Ensures that the shooting animation plays correctly.

Definition at line 26 of file ranged_weapon_script.h.

◆ m_fireRatePerSecond

int RangedWeaponScript::m_fireRatePerSecond
private

Allowed number of shots per second to control shooting frequency.

Definition at line 25 of file ranged_weapon_script.h.

◆ m_lastFireTimeInMs

int RangedWeaponScript::m_lastFireTimeInMs
private

Timestamp of the last shooting action in milliseconds.

Definition at line 24 of file ranged_weapon_script.h.

◆ m_shoot

bool RangedWeaponScript::m_shoot
private

Flag to indicate whether the weapon should shoot.

Definition at line 23 of file ranged_weapon_script.h.


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