18 const unsigned index = GetNextComponentIndex();
20 if (index != InvalidComponentIndex)
22 components[ index ].handle = T::New();
23 components[ index ].type = T::Type();
30 for (
unsigned i = 0; i < nextFreeComponentIndex; ++i)
32 if (components[ i ].type == T::Type())
34 components[ i ].handle = 0;
35 components[ i ].type = -1;
44 for (
const auto& component : components)
46 if (T::Type() == component.type)
48 return T::Get( component.handle );
65 void SetName(
const char* aName ) { name = aName; }
68 const std::string&
GetName()
const {
return name; }
80 unsigned GetNextComponentIndex();
82 static const int MaxComponents = 10;
83 unsigned nextFreeComponentIndex = 0;
84 ComponentEntry components[ MaxComponents ];
const std::string & GetName() const
Definition: GameObject.hpp:68
void SetName(const char *aName)
Definition: GameObject.hpp:65
void RemoveComponent()
Remove a component from the game object.
Definition: GameObject.hpp:28
static const unsigned InvalidComponentIndex
Invalid component index.
Definition: GameObject.hpp:13
Definition: AudioClip.hpp:4
GameObject & operator=(const GameObject &go)
void AddComponent()
Adds a component into the game object. There can be multiple components of the same type...
Definition: GameObject.hpp:16
GameObject()=default
Constructor.
std::string GetSerialized() const
GameObject is composed of components that define its behavior.
Definition: GameObject.hpp:9
T * GetComponent() const
Definition: GameObject.hpp:42