The Table Engine
Script Class Reference

Base class for scripting custom behaviors in game objects. More...

#include <script.h>

+ Inheritance diagram for Script:
+ Collaboration diagram for Script:

Public Member Functions

 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 input ()
 Virtual method for handling input. Should be overridden by derived classes. More...
 
virtual void update ()
 Virtual method for updating the script's state. Should be overridden by derived classes. More...
 
virtual void render ()
 Virtual method for rendering operations. Should be overridden by derived classes. More...
 

Public Attributes

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

Base class for scripting custom behaviors in game objects.

Scripts are used to define interactive or autonomous behaviors for game objects. They can handle input, update logic, and rendering specifics for the associated game object.

Definition at line 22 of file script.h.

Constructor & Destructor Documentation

◆ Script() [1/2]

Script::Script ( )

Default constructor, initializes an empty script.

Definition at line 5 of file script.cpp.

◆ Script() [2/2]

Script::Script ( std::string  name)

Constructs a Script with a specified name.

Parameters
nameName of the script.

Definition at line 6 of file script.cpp.

◆ ~Script()

Script::~Script ( )
virtual

Virtual destructor to allow for cleanup in derived script classes.

Definition at line 7 of file script.cpp.

Member Function Documentation

◆ getName()

std::string Script::getName ( )

Retrieves the name of the script.

Returns
The name of the script as a std::string.

Definition at line 9 of file script.cpp.

◆ getOwner()

GameObject * Script::getOwner ( )

Retrieves the owner GameObject of this script.

Returns
Pointer to the GameObject that owns this script.

Definition at line 13 of file script.cpp.

◆ input()

void Script::input ( )
virtual

Virtual method for handling input. Should be overridden by derived classes.

Reimplemented in RangedWeaponScript.

Definition at line 21 of file script.cpp.

◆ render()

void Script::render ( )
virtual

Virtual method for rendering operations. Should be overridden by derived classes.

Reimplemented in EnemyAIScript, and CollisionScript.

Definition at line 27 of file script.cpp.

◆ setOwner()

void Script::setOwner ( GameObject owner)

Sets the owner of this script.

Parameters
ownerPointer to the GameObject to be set as the owner of this script.

Definition at line 17 of file script.cpp.

◆ update()

void Script::update ( )
virtual

Virtual method for updating the script's state. Should be overridden by derived classes.

Reimplemented in RangedWeaponScript, ProjectileScript, PlayerInputScript, EnemyAIScript, CrosshairScript, and CollisionScript.

Definition at line 24 of file script.cpp.

Member Data Documentation

◆ m_name

std::string Script::m_name

Name of the script, useful for identification or debugging.

Definition at line 24 of file script.h.

◆ m_owner

GameObject* Script::m_owner

Pointer to the GameObject that owns this script.

Definition at line 25 of file script.h.


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