The Table Engine
|
Controls the behavior of ranged weapons such as bows or guns. More...
#include <ranged_weapon_script.h>
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... | |
![]() | |
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... | |
GameObject * | getOwner () |
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 | |
![]() | |
std::string | m_name |
Name of the script, useful for identification or debugging. More... | |
GameObject * | m_owner |
Pointer to the GameObject that owns this script. More... | |
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.
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.
|
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.
|
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.
|
private |
Ensures that the shooting animation plays correctly.
Definition at line 26 of file ranged_weapon_script.h.
|
private |
Allowed number of shots per second to control shooting frequency.
Definition at line 25 of file ranged_weapon_script.h.
|
private |
Timestamp of the last shooting action in milliseconds.
Definition at line 24 of file ranged_weapon_script.h.
|
private |
Flag to indicate whether the weapon should shoot.
Definition at line 23 of file ranged_weapon_script.h.