Shkyera Engine
Easy to use, game engine for Python
shkyera::ScriptComponent Class Reference

A class representing a script component that can be attached to game objects. More...

#include <ScriptComponent.hpp>

Inheritance diagram for shkyera::ScriptComponent:
[legend]

Public Member Functions

void setFile (std::shared_ptr< File > file)
 Set the script file associated with this script component. More...
 
void update ()
 Update the script component. More...
 
void moveScript ()
 Move the script associated with this component. More...
 
const std::shared_ptr< FilegetFile () const
 Get the script file associated with this script component. More...
 
void addFloatVariable (std::string name)
 Add a public float variable to the script component. More...
 
void addIntVariable (std::string name)
 Add a public integer variable to the script component. More...
 
void addStringVariable (std::string name)
 Add a public string variable to the script component. More...
 
void addVec3Variable (std::string name)
 Add a public glm::vec3 variable to the script component. More...
 
std::vector< PublicFloat > & getFloatVariables ()
 Get a reference to the vector of public float variables. More...
 
std::vector< PublicInt > & getIntVariables ()
 Get a reference to the vector of public integer variables. More...
 
std::vector< PublicString > & getStringVariables ()
 Get a reference to the vector of public string variables. More...
 
std::vector< PublicVec3 > & getVec3Variables ()
 Get a reference to the vector of public glm::vec3 variables. More...
 
 Component (std::shared_ptr< GameObject > object)
 Constructor to initialize a component with a shared pointer to a game object. More...
 
- Public Member Functions inherited from shkyera::Component
 Component (std::shared_ptr< GameObject > object)
 Constructor to initialize a component with a shared pointer to a game object. More...
 
std::shared_ptr< GameObjectgetObject ()
 Get the shared pointer to the game object to which this component is attached. More...
 

Static Public Member Functions

static std::shared_ptr< ScriptComponentaddScript (std::shared_ptr< GameObject > object, std::shared_ptr< File > file)
 Add a script component to a game object and attach a script file. More...
 
static void addScript (std::shared_ptr< ScriptComponent > script)
 Add an existing script component to the list of managed scripts. More...
 
static void removeScript (std::shared_ptr< ScriptComponent > script)
 Remove a script component from the list of managed scripts. More...
 
static std::vector< std::shared_ptr< ScriptComponent > > getScripts ()
 Get a list of all managed script components. More...
 
static void moveScripts ()
 Move all scripts to their respective destinations. More...
 

Static Public Attributes

static std::string SCRIPT_DESTINATION = "src/python/shkyera"
 The destination directory for scripts (static member). More...
 

Static Private Member Functions

static void verifyScripts ()
 Verify the existence of script files and components. More...
 

Private Attributes

std::shared_ptr< File_file
 The associated script file. More...
 
std::vector< PublicFloat_floatVariables
 List of public float variables. More...
 
std::vector< PublicInt_intVariables
 List of public integer variables. More...
 
std::vector< PublicString_stringVariables
 List of public string variables. More...
 
std::vector< PublicVec3_vec3Variables
 List of public glm::vec3 variables. More...
 

Static Private Attributes

static std::vector< std::shared_ptr< ScriptComponent > > _scripts = {}
 List of managed script components. More...
 

Additional Inherited Members

- Protected Attributes inherited from shkyera::Component
std::shared_ptr< GameObject_object
 The game object to which this component is attached. More...
 

Detailed Description

A class representing a script component that can be attached to game objects.

This class extends the Component class and provides functionality for handling scripts, including adding script variables and managing script files.

Member Function Documentation

◆ addFloatVariable()

void shkyera::ScriptComponent::addFloatVariable ( std::string  name)

Add a public float variable to the script component.

Parameters
nameThe name of the float variable to add.

◆ addIntVariable()

void shkyera::ScriptComponent::addIntVariable ( std::string  name)

Add a public integer variable to the script component.

Parameters
nameThe name of the integer variable to add.

◆ addScript() [1/2]

std::shared_ptr< ScriptComponent > shkyera::ScriptComponent::addScript ( std::shared_ptr< GameObject object,
std::shared_ptr< File file 
)
static

Add a script component to a game object and attach a script file.

Parameters
objectA shared pointer to the game object.
fileA shared pointer to the script file.
Returns
A shared pointer to the created script component.

◆ addScript() [2/2]

void shkyera::ScriptComponent::addScript ( std::shared_ptr< ScriptComponent script)
static

Add an existing script component to the list of managed scripts.

Parameters
scriptA shared pointer to the script component to add.

◆ addStringVariable()

void shkyera::ScriptComponent::addStringVariable ( std::string  name)

Add a public string variable to the script component.

Parameters
nameThe name of the string variable to add.

◆ addVec3Variable()

void shkyera::ScriptComponent::addVec3Variable ( std::string  name)

Add a public glm::vec3 variable to the script component.

Parameters
nameThe name of the glm::vec3 variable to add.

◆ Component()

shkyera::Component::Component

Constructor to initialize a component with a shared pointer to a game object.

Parameters
objectA shared pointer to the game object to which this component is attached.

◆ getFile()

const std::shared_ptr< File > shkyera::ScriptComponent::getFile ( ) const

Get the script file associated with this script component.

Returns
A shared pointer to the script file.

◆ getFloatVariables()

std::vector< PublicFloat > & shkyera::ScriptComponent::getFloatVariables ( )

Get a reference to the vector of public float variables.

Returns
A reference to the vector of public float variables.

◆ getIntVariables()

std::vector< PublicInt > & shkyera::ScriptComponent::getIntVariables ( )

Get a reference to the vector of public integer variables.

Returns
A reference to the vector of public integer variables.

◆ getScripts()

std::vector< std::shared_ptr< ScriptComponent > > shkyera::ScriptComponent::getScripts ( )
static

Get a list of all managed script components.

Returns
A vector of shared pointers to script components.

◆ getStringVariables()

std::vector< PublicString > & shkyera::ScriptComponent::getStringVariables ( )

Get a reference to the vector of public string variables.

Returns
A reference to the vector of public string variables.

◆ getVec3Variables()

std::vector< PublicVec3 > & shkyera::ScriptComponent::getVec3Variables ( )

Get a reference to the vector of public glm::vec3 variables.

Returns
A reference to the vector of public glm::vec3 variables.

◆ moveScript()

void shkyera::ScriptComponent::moveScript ( )

Move the script associated with this component.

◆ moveScripts()

void shkyera::ScriptComponent::moveScripts ( )
static

Move all scripts to their respective destinations.

◆ removeScript()

void shkyera::ScriptComponent::removeScript ( std::shared_ptr< ScriptComponent script)
static

Remove a script component from the list of managed scripts.

Parameters
scriptA shared pointer to the script component to remove.

◆ setFile()

void shkyera::ScriptComponent::setFile ( std::shared_ptr< File file)

Set the script file associated with this script component.

Parameters
fileA shared pointer to the script file.

◆ update()

void shkyera::ScriptComponent::update ( )

Update the script component.

TODO: Implement more types

◆ verifyScripts()

void shkyera::ScriptComponent::verifyScripts ( )
staticprivate

Verify the existence of script files and components.

Member Data Documentation

◆ _file

std::shared_ptr<File> shkyera::ScriptComponent::_file
private

The associated script file.

◆ _floatVariables

std::vector<PublicFloat> shkyera::ScriptComponent::_floatVariables
private

List of public float variables.

◆ _intVariables

std::vector<PublicInt> shkyera::ScriptComponent::_intVariables
private

List of public integer variables.

◆ _scripts

std::vector< std::shared_ptr< ScriptComponent > > shkyera::ScriptComponent::_scripts = {}
staticprivate

List of managed script components.

◆ _stringVariables

std::vector<PublicString> shkyera::ScriptComponent::_stringVariables
private

List of public string variables.

◆ _vec3Variables

std::vector<PublicVec3> shkyera::ScriptComponent::_vec3Variables
private

List of public glm::vec3 variables.

◆ SCRIPT_DESTINATION

std::string shkyera::ScriptComponent::SCRIPT_DESTINATION = "src/python/shkyera"
inlinestatic

The destination directory for scripts (static member).


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