FastEngine 0.9.3
A multiplayer oriented 2D engine made with Vulkan.
Loading...
Searching...
No Matches
fge::ObjectData Class Reference

Data wrapper representing an Object in a Scene. More...

#include <C_scene.hpp>

Public Member Functions

 ObjectData (fge::Scene *boundScene, fge::ObjectPtr &&newObj, fge::ObjectSid newSid=std::numeric_limits< fge::ObjectSid >::max(), fge::ObjectPlan newPlan=fge::ObjectPlan { 100 }, fge::ObjectType newType=fge::ObjectType::TYPE_OBJECT)
 
fge::ObjectreleaseObject ()
 Release the Object handled by the smart pointer.
 
fge::ScenegetScene () const
 Get the current bound Scene.
 
fge::ObjectgetObject () const
 Get the Object pointer.
 
template<class TObject >
TObject * getObject () const
 Get the Object pointer and cast it.
 
fge::ObjectSid getSid () const
 Get the SID of the Object.
 
fge::ObjectPlan getPlan () const
 Get the plan of the Object.
 
fge::ObjectType getType () const
 Get the type of the Object.
 
void setPlanDepth (fge::ObjectPlanDepth depth) const
 Set the plan depth of the Object.
 
fge::ObjectPlanDepth getPlanDepth () const
 Get the plan depth of the Object.
 
void setParent (fge::ObjectDataShared const &object) const
 Set an parent object.
 
void clearParent () const
 Clear the parent object.
 
fge::ObjectDataWeak getParent () const
 Get the parent object.
 
bool isBound () const
 Check if the Object is bound to a Scene.
 
bool isClass (std::string_view const className) const
 Check if the Object is a specific class.
 
bool operator== (fge::ObjectSid const &sid) const
 Comparison with another SID.
 
bool operator== (fge::Object const *ptr) const
 Comparison with another object pointer.
 

Static Public Member Functions

static bool isValid (fge::ObjectDataShared const &data)
 check if the provided shared pointer Object is valid.
 
static fge::ObjectDataShared isValid (fge::ObjectDataWeak const &data)
 check if the provided weak pointer Object is valid.
 

Friends

class fge::Scene
 

Detailed Description

Data wrapper representing an Object in a Scene.

This is the class used to store data relating to an Object in a Scene. There is :

  • the bound scene of the object.
  • the object.
  • the SID of the object
  • the plan of the object
  • the type of the object
  • the plan depth of the object

Member Function Documentation

◆ clearParent()

void fge::ObjectData::clearParent ( ) const
inline

Clear the parent object.

◆ getObject() [1/2]

fge::Object * fge::ObjectData::getObject ( ) const
inlinenodiscard

Get the Object pointer.

Returns
The Object pointer

◆ getObject() [2/2]

template<class TObject >
TObject * fge::ObjectData::getObject ( ) const
inlinenodiscard

Get the Object pointer and cast it.

Template Parameters
TObjectThe wanted Object type
Returns
The Object pointer

◆ getParent()

fge::ObjectDataWeak fge::ObjectData::getParent ( ) const
inlinenodiscard

Get the parent object.

Returns
A weak pointer to the parent object

◆ getPlan()

fge::ObjectPlan fge::ObjectData::getPlan ( ) const
inlinenodiscard

Get the plan of the Object.

The plan determine the draw order of the Object. If the plan is 0, the Object will be drawn first.

Returns
The plan of the Object.

◆ getPlanDepth()

fge::ObjectPlanDepth fge::ObjectData::getPlanDepth ( ) const
inlinenodiscard

Get the plan depth of the Object.

A plan depth is an index representing the position of the object in a plan. If the depth is 0, the object is drawn before everyone else.

The depth plan is generated by the Scene everytime it is drawn.

This data is considered as dynamic, this means that it is local only and generated by the Scene and should not be saved.

Returns
The plan depth of the object.

◆ getScene()

fge::Scene * fge::ObjectData::getScene ( ) const
inlinenodiscard

Get the current bound Scene.

Returns
The bound Scene pointer or nullptr if there is no Scene

◆ getSid()

fge::ObjectSid fge::ObjectData::getSid ( ) const
inlinenodiscard

Get the SID of the Object.

An SID (for static identifier) is an unique id for every object in your scene.

Returns
The SID of the object

◆ getType()

fge::ObjectType fge::ObjectData::getType ( ) const
inlinenodiscard

Get the type of the Object.

The type determine how the Object is synchronised on the network.

  • TYPE_OBJECT: a normal object that will be synchronised between client and server
  • TYPE_DECAY: an object that will be sent from the server but not synchronised
  • TYPE_GUI: an object that is client only and will be not destroyed by a full synchronisation
Returns
The type of the Object.

◆ isBound()

bool fge::ObjectData::isBound ( ) const
inlinenodiscard

Check if the Object is bound to a Scene.

Returns
true if the Object is bound, false otherwise

◆ isClass()

bool fge::ObjectData::isClass ( std::string_view const className) const
inlinenodiscard

Check if the Object is a specific class.

Parameters
classNameThe class name
Returns
True if the Object is the specified class, False otherwise

◆ isValid() [1/2]

static bool fge::ObjectData::isValid ( fge::ObjectDataShared const & data)
inlinestaticnodiscard

check if the provided shared pointer Object is valid.

For an shared pointer Object to be considered valid he need to not be nullptr and have a bound Scene.

Parameters
dataThe shared pointer Object
Returns
true if the Object is valid or false otherwise

◆ isValid() [2/2]

static fge::ObjectDataShared fge::ObjectData::isValid ( fge::ObjectDataWeak const & data)
inlinestaticnodiscard

check if the provided weak pointer Object is valid.

Parameters
dataThe weak pointer Object
Returns
The shared pointer Object if valid or nullptr otherwise

◆ operator==() [1/2]

bool fge::ObjectData::operator== ( fge::Object const * ptr) const
inlinenodiscard

Comparison with another object pointer.

Returns
True if same address, False otherwise

◆ operator==() [2/2]

bool fge::ObjectData::operator== ( fge::ObjectSid const & sid) const
inlinenodiscard

Comparison with another SID.

Returns
True if same SID, False otherwise

◆ releaseObject()

fge::Object * fge::ObjectData::releaseObject ( )
inlinenodiscard

Release the Object handled by the smart pointer.

This method should only be useful if you use a custom Object handler to handle your objects.

Warning
This is your responsibility to destroy the Object after a call to this method.
Returns
The pointer of the Object

◆ setParent()

void fge::ObjectData::setParent ( fge::ObjectDataShared const & object) const
inline

Set an parent object.

Parameters
objectThe parent object

◆ setPlanDepth()

void fge::ObjectData::setPlanDepth ( fge::ObjectPlanDepth depth) const
inline

Set the plan depth of the Object.

Parameters
depthThe new depth
See also
getPlanDepth

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