GDevelop Core
Core library for developing platforms and tools compatible with GDevelop.
|
Defines a container of gd::InitialInstances. More...
#include <InitialInstancesContainer.h>
Public Member Functions | |
InitialInstancesContainer * | Clone () const |
Return a pointer to a copy of the container. A such method is needed as the IDE may want to store copies of some containers and so need a way to do polymorphic copies. More... | |
void | Create (const InitialInstancesContainer &source) |
Instances management | |
Members functions related to managing the instances | |
std::size_t | GetInstancesCount () const |
Return the number of instances. | |
void | IterateOverInstances (InitialInstanceFunctor &func) |
Apply func to each instance of the container. More... | |
void | IterateOverInstancesWithZOrdering (InitialInstanceFunctor &func, const gd::String &layer) |
InitialInstance & | InsertInitialInstance (const InitialInstance &instance) |
Insert the specified instance into the list and return a a reference to the newly added instance. | |
InitialInstance & | InsertNewInitialInstance () |
Insert a new blank instance at the end of the list and return a a reference to the newly added instance. | |
void | RemoveInstance (const gd::InitialInstance &instance) |
Remove the specified instance. | |
void | RemoveAllInstancesOnLayer (const gd::String &layerName) |
Remove all instances from layer layerName. | |
void | MoveInstancesToLayer (const gd::String &fromLayer, const gd::String &toLayer) |
Move the instances on layer fromLayer to layer toLayer. | |
void | RemoveInitialInstancesOfObject (const gd::String &objectName) |
Remove instances of object named objectName. | |
void | RenameInstancesOfObject (const gd::String &oldName, const gd::String &newName) |
Change instances with object's name oldName to newName. | |
std::size_t | GetLayerInstancesCount (const gd::String &layerName) const |
Return the number of instances on the layer named layerName. | |
bool | SomeInstancesAreOnLayer (const gd::String &layerName) const |
Return true if there is at least one instance on the layer named layerName. | |
bool | HasInstancesOfObject (const gd::String &objectName) const |
Return true if there is at least one instance of the given object. | |
bool | IsInstancesCountOfObjectGreaterThan (const gd::String &objectName, const std::size_t minInstanceCount) const |
Return true if there is at least N instances of the given object. | |
void | Clear () |
Remove all instances. | |
Saving and loading | |
Members functions related to saving and loading the object. | |
virtual void | SerializeTo (SerializerElement &element) const |
Serialize instances container. | |
virtual void | UnserializeFrom (const SerializerElement &element) |
Unserialize the instances container. | |
Defines a container of gd::InitialInstances.
The container is notably able to ensure that pointers to the elements of the container are not invalidated when a change occurs (through InsertNewInitialInstance or RemoveInstance for example).
Thus, the implementations uses a std::list for holding the instances. In this way, the container is not required to provide a direct access to element based on an index. Instead, the method IterateOverInstances is used to perform operations.
|
inline |
Return a pointer to a copy of the container. A such method is needed as the IDE may want to store copies of some containers and so need a way to do polymorphic copies.
Typical implementation example:
void gd::InitialInstancesContainer::Create | ( | const InitialInstancesContainer & | source | ) |
Must construct the class from the source A such method is needed as the IDE may want to store copies of some containers and so need a way to do polymorphic copies.
Typical implementation example:
void gd::InitialInstancesContainer::IterateOverInstances | ( | gd::InitialInstanceFunctor & | func | ) |
Apply func to each instance of the container.
void gd::InitialInstancesContainer::IterateOverInstancesWithZOrdering | ( | gd::InitialInstanceFunctor & | func, |
const gd::String & | layer | ||
) |
Get the instances on the specified layer, sort them regarding their Z order and then apply func on them.
func | The functor to be applied. |
layer | The layer |