Platform Data Engine 0.0.1
A data-driven game engine for platformers
PlatformDataEngine::GameObject Class Reference

The base container class for a gameplay related object, it's drawable, transformable and components can be added to modify the funcionality. These classes are defined by the user in a json file. More...

#include <GameObject.h>

Inheritance diagram for PlatformDataEngine::GameObject:
PlatformDataEngine::Alive PlatformDataEngine::Networkable

Public Member Functions

 GameObject (bool isDef=false)
 Constructor, keep in mind this is called when creating a gameObject definition as well as an instance. Definitions are loaded in memory as simple gameObjects so they can be instantiated using the copy constructor and std::make_shared()
 
 GameObject (const GameObject &other)
 Copy constructor More...
 
void init ()
 Calls init() for every component in this gameObject and itself
 
void update (const float &dt, const float &elapsedTime)
 Runs the update loop for every component in this gameObject and itself More...
 
void networkSerialize (PDEPacket &output)
 Called every time an object is sent to a client More...
 
void networkDeserialize (PDEPacket &input)
 Called every time an object is recieved from a client More...
 
void networkSerializeInit (PDEPacket &output)
 Called when an object is sent to the clients for the first time More...
 
void networkDeserializeInit (PDEPacket &input)
 Called when an object is recieved on a client for the first time More...
 
void draw (sf::RenderTarget &target, sf::RenderStates states) const
 Drawcall, never call explicitly More...
 
void loadDefinition (const std::string &filename)
 Loads a gameObject definition from a json file More...
 
void registerComponentHierarchy (std::shared_ptr< GameObject > self)
 Adds the gameObject pointer as the parent for each component this object owns More...
 
bool isDefinition () const
 
void setIsDefinition (bool isDef)
 
int getZlayer () const
 
void setZlayer (int zLayer)
 
void addChild (std::shared_ptr< GameObject > gameObject)
 
void setParent (std::shared_ptr< GameObject > gameObject)
 
void setIsUI (bool isUI)
 
bool getIsUI () const
 
void setConnection (std::shared_ptr< Connection > conn)
 
std::shared_ptr< ConnectiongetConnection () const
 
std::shared_ptr< GameObjectgetParent ()
 
void setAlreadyReplicated (bool replicated)
 
std::string getId () const
 
void setId (const std::string &id)
 
void setName (const std::string &name)
 
void destroySelf ()
 
std::string getType () const
 
void setType (const std::string &type)
 
bool getDestroyed () const
 
std::vector< std::shared_ptr< GameObject > > getChildren () const
 
void setNetworked (bool networked)
 
bool getNetworked ()
 
void setHasBeenSent (const std::string &id)
 
bool getHasBeenSent (const std::string &id) const
 
void sortChildZ ()
 Makes sure children are in the correct Z order for drawing
 
template<typename T >
std::shared_ptr< T > findComponentOfType () const
 
void onDeath ()
 
void onDamage (float currentHP)
 
- Public Member Functions inherited from PlatformDataEngine::Alive
 Alive ()
 Constructor
 
void damage (float damageAmount)
 Deals damage and checks for death More...
 
float getHealth () const
 
void setHealth (float hp)
 
virtual void networkSerializeInit (PDEPacket &output)=0
 Called when an object is sent to the clients for the first time More...
 
virtual void networkDeserializeInit (PDEPacket &input)=0
 Called when an object is recieved on a client for the first time More...
 
virtual void networkSerialize (PDEPacket &output)=0
 Called every time an object is sent to a client More...
 
virtual void networkDeserialize (PDEPacket &input)=0
 Called every time an object is recieved from a client More...
 

Additional Inherited Members

virtual void onDeath ()=0
 
virtual void onDamage (float currentHP)=0
 
- Protected Attributes inherited from PlatformDataEngine::Alive
float m_HP
 

Detailed Description

The base container class for a gameplay related object, it's drawable, transformable and components can be added to modify the funcionality. These classes are defined by the user in a json file.

Constructor & Destructor Documentation

◆ GameObject()

GameObject::GameObject ( const GameObject other)

Copy constructor

Parameters
otherother object

Member Function Documentation

◆ draw()

void GameObject::draw ( sf::RenderTarget &  target,
sf::RenderStates  states 
) const

Drawcall, never call explicitly

Parameters
target
states

◆ loadDefinition()

void GameObject::loadDefinition ( const std::string &  filename)

Loads a gameObject definition from a json file

Parameters
filenamegame object definition .json filename

◆ networkDeserialize()

void GameObject::networkDeserialize ( PDEPacket input)
virtual

Called every time an object is recieved from a client

Parameters
input

Implements PlatformDataEngine::Networkable.

◆ networkDeserializeInit()

void GameObject::networkDeserializeInit ( PDEPacket input)
virtual

Called when an object is recieved on a client for the first time

Parameters
input

Implements PlatformDataEngine::Networkable.

◆ networkSerialize()

void GameObject::networkSerialize ( PDEPacket output)
virtual

Called every time an object is sent to a client

Parameters
output

Implements PlatformDataEngine::Networkable.

◆ networkSerializeInit()

void GameObject::networkSerializeInit ( PDEPacket output)
virtual

Called when an object is sent to the clients for the first time

Parameters
output

Implements PlatformDataEngine::Networkable.

◆ onDamage()

void GameObject::onDamage ( float  currentHP)
virtual

◆ onDeath()

void GameObject::onDeath ( )
virtual

◆ registerComponentHierarchy()

void GameObject::registerComponentHierarchy ( std::shared_ptr< GameObject self)

Adds the gameObject pointer as the parent for each component this object owns

Parameters
selfa pointer to the new parent, usually "this" as a shared pointer

◆ update()

void GameObject::update ( const float &  dt,
const float &  elapsedTime 
)

Runs the update loop for every component in this gameObject and itself

Parameters
dtdelta time
elapsedTimeelapsed time (since game started)

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