GDevelop Core
Core library for developing platforms and tools compatible with GDevelop.
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members

Represent an object of a platform. More...

#include <Object.h>

Public Member Functions

 Object (const gd::String &name, const gd::String &type, std::unique_ptr< gd::ObjectConfiguration > configuration)
 
 Object (const gd::String &name, const gd::String &type, gd::ObjectConfiguration *configuration)
 
 Object (const gd::Object &object)
 
Objectoperator= (const gd::Object &object)
 
virtual ~Object ()
 
virtual std::unique_ptr< gd::ObjectClone () const
 
gd::ObjectConfigurationGetConfiguration ()
 Return the object configuration.
 
const gd::ObjectConfigurationGetConfiguration () const
 
Common properties

Members functions related to common properties

void SetName (const gd::String &name_)
 Change the name of the object with the name passed as parameter.
 
const gd::StringGetName () const
 Return the name of the object.
 
void SetAssetStoreId (const gd::String &assetStoreId_)
 Change the asset store id of the object.
 
const gd::StringGetAssetStoreId () const
 Return the asset store id of the object.
 
void SetType (const gd::String &type_)
 Change the type of the object.
 
const gd::StringGetType () const
 Return the type of the object.
 
Behaviors management

Members functions related to behaviors management.

std::vector< gd::StringGetAllBehaviorNames () const
 Return a vector containing the names of all the behaviors used by the object.
 
BehaviorGetBehavior (const gd::String &name)
 Return a reference to the content of the behavior called name.
 
const BehaviorGetBehavior (const gd::String &name) const
 Return a reference to the content of the behavior called name.
 
bool HasBehaviorNamed (const gd::String &name) const
 Return true if object has a behavior called name.
 
void RemoveBehavior (const gd::String &name)
 Remove behavior called name.
 
bool RenameBehavior (const gd::String &name, const gd::String &newName)
 Change the name of behavior called name to newName. More...
 
gd::BehaviorAddNewBehavior (const gd::Project &project, const gd::String &type, const gd::String &name)
 Add the behavior of the specified type with the specified name. More...
 
const std::map< gd::String, std::unique_ptr< gd::Behavior > > & GetAllBehaviorContents () const
 Get a read-only access to the map containing the behaviors with their properties.
 
Variable management

Members functions related to object variables management.

const gd::VariablesContainerGetVariables () const
 Provide access to the gd::VariablesContainer member containing the object variables.
 
gd::VariablesContainerGetVariables ()
 Provide access to the gd::VariablesContainer member containing the object variables.
 
Effects management

Member functions related to effects management.

const gd::EffectsContainerGetEffects () const
 Provide access to the gd::EffectsContainer member containing the effects.
 
gd::EffectsContainerGetEffects ()
 Provide access to the gd::EffectsContainer member containing the effects.
 
Serialization

Members functions related to serialization of the object

void SerializeTo (SerializerElement &element) const
 Serialize the object. More...
 
void UnserializeFrom (gd::Project &project, const SerializerElement &element)
 Unserialize the object. More...
 
ObjectResetPersistentUuid ()
 Reset the persistent UUID, used to recognize the same object between serialization.
 
ObjectClearPersistentUuid ()
 Remove the persistent UUID - when the object no longer need to be recognized between serializations.
 

Protected Member Functions

void Init (const gd::Object &object)
 

Protected Attributes

gd::String name
 The full name of the object.
 
gd::String assetStoreId
 
std::unique_ptr< gd::ObjectConfigurationconfiguration
 
std::map< gd::String, std::unique_ptr< gd::Behavior > > behaviors
 
gd::VariablesContainer objectVariables
 List of the variables of the object.
 
gd::EffectsContainer effectsContainer
 The effects container for the object.
 
gd::String persistentUuid
 

Detailed Description

Represent an object of a platform.

Constructor & Destructor Documentation

◆ Object() [1/3]

gd::Object::Object ( const gd::String name,
const gd::String type,
std::unique_ptr< gd::ObjectConfiguration configuration 
)

Create a new object with the name passed as argument.

◆ Object() [2/3]

gd::Object::Object ( const gd::String name,
const gd::String type,
gd::ObjectConfiguration configuration 
)

Create a new object with the name passed as argument.

Object takes the ownership of the configuration.

◆ Object() [3/3]

gd::Object::Object ( const gd::Object object)
inline

Copy constructor. Calls Init().

◆ ~Object()

gd::Object::~Object ( )
virtual

Destructor.

Member Function Documentation

◆ AddNewBehavior()

gd::Behavior * gd::Object::AddNewBehavior ( const gd::Project project,
const gd::String type,
const gd::String name 
)

Add the behavior of the specified type with the specified name.

The project's current platform is used to initialize the content.

Returns
A pointer to the newly added behavior content. NULL if the creation failed.

◆ Clone()

virtual std::unique_ptr<gd::Object> gd::Object::Clone ( ) const
inlinevirtual

Must return a pointer to a copy of the object. A such method is needed to do polymorphic copies. Just redefine this method in your derived object class like this:

return gd::make_unique<MyObject>(*this);

◆ Init()

void gd::Object::Init ( const gd::Object object)
protected

Initialize object using another object. Used by copy-ctor and assign-op. Don't forget to update me if members were changed!

It's needed because there is no default copy for a map of unique_ptr like behaviors and it must be a deep copy.

◆ operator=()

Object& gd::Object::operator= ( const gd::Object object)
inline

Assignment operator. Calls Init().

◆ RenameBehavior()

bool gd::Object::RenameBehavior ( const gd::String name,
const gd::String newName 
)

Change the name of behavior called name to newName.

Returns
true if name was successfully changed

◆ SerializeTo()

void gd::Object::SerializeTo ( SerializerElement element) const

Serialize the object.

See also
DoSerializeTo

◆ UnserializeFrom()

void gd::Object::UnserializeFrom ( gd::Project project,
const SerializerElement element 
)

Unserialize the object.

See also
DoUnserializeFrom

Member Data Documentation

◆ assetStoreId

gd::String gd::Object::assetStoreId
protected

The ID of the asset if the object comes from the store.

◆ behaviors

std::map<gd::String, std::unique_ptr<gd::Behavior> > gd::Object::behaviors
protected

Contains all behaviors and their properties for the object. Behavior contents are the ownership of the object.

◆ persistentUuid

gd::String gd::Object::persistentUuid
mutableprotected

A persistent random version 4 UUID, useful for computing changesets.


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