NWengine 0.9
Loading...
Searching...
No Matches
Script Class Reference

The base class for script components. More...

#include <Script.h>

Inheritance diagram for Script:
GameComponent Serialized

Public Member Functions

 Script (GameObject *attachedObj)
 Constructs a Script object.
 
void Start () override
 Called when the script is started.
 
void Update () override
 Called every frame to update the script.
 
template<typename T >
void SetScript ()
 Sets the script to the specified type.
 
int Serialize (std::fstream *data, int offset) override
 Serializes the script data.
 
int Deserialize (std::fstream *data, int offset) override
 Deserializes the script data.
 
- Public Member Functions inherited from GameComponent
virtual void SetGameObject (void *go)
 Set the GameObject associated with the game component.
 
virtual voidGetGameObject ()
 Get the GameObject associated with the game component.
 
virtual ~GameComponent ()
 Destructor for the game component.
 
- Public Member Functions inherited from Serialized
 Serialized ()
 Default constructor for Serialized class.
 

Static Public Member Functions

static std::string GetType ()
 Gets the type of the script component.
 
- Static Public Member Functions inherited from GameComponent
static std::string GetType ()
 Get the type of the game component.
 

Public Attributes

GameObjectattachedObj = nullptr
 
Scriptablescript = nullptr
 

Static Public Attributes

static std::map< GameObject *, ScriptcomponentList
 

Detailed Description

The base class for script components.

Represents a script component that can be attached to a game object.

Constructor & Destructor Documentation

◆ Script()

Script::Script ( GameObject * attachedObj)

Constructs a Script object.

Default constructor.

Parameters
attachedObjThe GameObject to attach the script to.

Member Function Documentation

◆ Deserialize()

int Script::Deserialize ( std::fstream * data,
int offset )
overridevirtual

Deserializes the script data.

Parameters
dataThe file stream to read the data from.
offsetThe offset in the file stream.
Returns
The number of bytes read.

Reimplemented from Serialized.

◆ GetType()

static std::string Script::GetType ( )
inlinestatic

Gets the type of the script component.

Returns
The type of the script component.

◆ Serialize()

int Script::Serialize ( std::fstream * data,
int offset )
overridevirtual

Serializes the script data.

Parameters
dataThe file stream to write the data to.
offsetThe offset in the file stream.
Returns
The number of bytes written.

Reimplemented from Serialized.

◆ SetScript()

template<typename T >
void Script::SetScript ( )
inline

Sets the script to the specified type.

Template Parameters
TThe type of the script.

◆ Start()

void Script::Start ( )
overridevirtual

Called when the script is started.

Reimplemented from GameComponent.

◆ Update()

void Script::Update ( )
overridevirtual

Called every frame to update the script.

Reimplemented from GameComponent.

Member Data Documentation

◆ attachedObj

GameObject* Script::attachedObj = nullptr

The attached GameObject.

◆ componentList

std::map< GameObject *, Script > Script::componentList
static

The list of script components.

◆ script

Scriptable* Script::script = nullptr

The script object.


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