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

Class representing a game object. More...

#include <GameObject.h>

Inheritance diagram for GameObject:
Serialized

Public Member Functions

 GameObject ()
 Default constructor for GameObject.
 
 GameObject (const GameObject &other)
 Copy constructor for GameObject.
 
 ~GameObject ()
 Destructor for GameObject.
 
int Draw ()
 Draw the game object.
 
void SetDrawCallback (DrawCallback callback)
 Set the draw callback for the game object.
 
void DeleteComponent (std::string typeName)
 Delete a component from the game object.
 
void DeleteComponents ()
 Delete all components from the game object.
 
int Serialize (std::fstream *data, int offset)
 Serialize the game object.
 
int Deserialize (std::fstream *data, int offset)
 Deserialize the game object.
 
template<typename T >
TGetComponent ()
 Get a component of the specified type.
 
template<typename T >
TAddComponent ()
 Add a component of the specified type to the game object.
 
GameComponentAddComponent (std::string type)
 
GameComponentGetComponent (std::string type)
 Get a component of the specified type.
 
template<typename T >
void DeleteComponent ()
 Delete a component of the specified type.
 
- Public Member Functions inherited from Serialized
 Serialized ()
 Default constructor for Serialized class.
 

Public Attributes

std::map< std::string, GameComponent * > components
 
std::string name = "new GameObject"
 
uint32 id = 0
 
DrawCallback _drawProc = nullptr
 

Detailed Description

Class representing a game object.

Constructor & Destructor Documentation

◆ GameObject()

GameObject::GameObject ( const GameObject & other)

Copy constructor for GameObject.

Parameters
otherThe GameObject to copy.

Member Function Documentation

◆ AddComponent()

template<typename T >
T * GameObject::AddComponent ( )
inline

Add a component of the specified type to the game object.

Template Parameters
TThe type of the component.
Returns
A pointer to the added component.

◆ DeleteComponent() [1/2]

template<typename T >
void GameObject::DeleteComponent ( )
inline

Delete a component of the specified type.

Template Parameters
TThe type of the component.

◆ DeleteComponent() [2/2]

void GameObject::DeleteComponent ( std::string typeName)

Delete a component from the game object.

Parameters
typeNameThe type name of the component to delete.

◆ Deserialize()

int GameObject::Deserialize ( std::fstream * data,
int offset )
virtual

Deserialize the game object.

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

Reimplemented from Serialized.

◆ Draw()

int GameObject::Draw ( )

Draw the game object.

Returns
The layer in which the game object has been drawn.

◆ GetComponent() [1/2]

template<typename T >
T * GameObject::GetComponent ( )
inline

Get a component of the specified type.

Template Parameters
TThe type of the component.
Returns
A pointer to the component, or nullptr if the component does not exist.

◆ GetComponent() [2/2]

GameComponent * GameObject::GetComponent ( std::string type)

Get a component of the specified type.

Parameters
typeThe type of the component.
Returns
A pointer to the component, or nullptr if the component does not exist.

◆ Serialize()

int GameObject::Serialize ( std::fstream * data,
int offset )
virtual

Serialize the game object.

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

Reimplemented from Serialized.

◆ SetDrawCallback()

void GameObject::SetDrawCallback ( DrawCallback callback)

Set the draw callback for the game object.

Parameters
callbackThe draw callback to set.

Member Data Documentation

◆ _drawProc

DrawCallback GameObject::_drawProc = nullptr

The draw callback for the game object.

◆ components

std::map<std::string, GameComponent*> GameObject::components

Map of components attached to the game object.

◆ id

uint32 GameObject::id = 0

The identifier of the game object.

◆ name

std::string GameObject::name = "new GameObject"

The name of the game object.


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