HatchitGame
Public Member Functions | Friends | List of all members
Hatchit::Game::GameObject Class Reference

Public Member Functions

 GameObject (const GameObject &rhs)=default
 
 GameObject (GameObject &&rhs)=default
 
GameObjectoperator= (const GameObject &rhs)=default
 
GameObjectoperator= (GameObject &&rhs)=default
 
const Core::Guid & GetGuid (void) const
 Retrieve this GameObject's Guid.
 
const std::string & GetName (void) const
 Retrieve this GameObject's name.
 
TransformGetTransform (void)
 Retrieve this GameObject's Transform.
 
bool GetEnabled (void) const
 Indicates whether or not this GameObject is enabled. More...
 
void SetEnabled (bool value)
 Enables/Disables the GameObject based on the provided value. More...
 
void Enable (void)
 An inline for SetEnabled(true);.
 
void Disable (void)
 An inline for SetEnabled(false);.
 
GameObjectGetParent (void)
 Returns this GameObject's parent. More...
 
void SetParent (GameObject *parent)
 Sets the parent of this GameObject. More...
 
GameObjectGetChildAtIndex (std::size_t index)
 Returns a child GameObject located at the provided index. More...
 
void AddChild (GameObject *child)
 Adds the provided GameObject as a child of this GameObject. More...
 
void RemoveChildAtIndex (std::size_t index)
 Attempts to remove the GameObject child at the provided index. More...
 
void RemoveChild (GameObject *child)
 Attempts to remove provided GameObject from this GameObject. More...
 
void OnInit (void)
 Called when the gameobject is created to initialize all values.
 
void Update (void)
 Called once per frame while the gameobject is enabled. More...
 
void MarkForDestroy (void)
 Marks the GameObject to be destroyed the next time it would be updated. More...
 
template<typename T >
bool AddComponent (T *component)
 Attempts to attach a Component of type T. More...
 
template<typename T , typename... Args>
bool AddComponent (Args &&...args)
 Attempts to attach a Component of type T. More...
 
template<typename T >
bool RemoveComponent (void)
 Attempts to remove a Component of type T. More...
 
template<typename T >
bool HasComponent (void) const
 Test if a Component of type T is attached to this GameObject. More...
 
template<typename T1 , typename T2 , typename... Args>
bool HasComponent (void) const
 Test if Components of types T1, T2, and Args... More...
 
template<typename T >
T * GetComponent (void)
 Return a Component of type T attached to this GameObject. More...
 
template<typename... Args>
std::tuple< Args *... > GetComponents (void)
 Returns Components of type Args... More...
 
template<typename T >
bool EnableComponent (void)
 Enable a Component of type T attached to this GameObject. More...
 
template<typename... Args>
auto EnableComponents (void) -> decltype(std::make_tuple(EnableComponent< Args >()...))
 Enable Components of type Args... More...
 
template<typename T >
bool DisableComponent (void)
 Disable a Component of type T attached to this GameObject. More...
 
template<typename... Args>
auto DisableComponents (void) -> decltype(std::make_tuple(DisableComponent< Args >()...))
 Disable Components of type Args... More...
 
template<>
bool AddComponent (Component *component)
 

Friends

class Scene
 

Member Function Documentation

void GameObject::AddChild ( GameObject child)

Adds the provided GameObject as a child of this GameObject.

Parameters
childThe GameObject to child.
template<typename T >
bool GameObject::AddComponent ( T *  component)

Attempts to attach a Component of type T.

Parameters
componentThe new Component of type T to attach.
Template Parameters
TA sub-class of Component.
Returns
bool indicating if the component could be attached.
See also
AddComponent(Args&&... args)

If the component can be attached, its VOnInit and VOnEnabled will be invoked.

template<typename T , typename... Args>
bool GameObject::AddComponent ( Args &&...  args)

Attempts to attach a Component of type T.

Parameters
argsThe arguments to pass to the constructor for T.
Template Parameters
TA sub-class of Component.
Args...The arguments to provide to T's constructor.
Returns
bool indicating if the Component could be attached.
See also
AddComponent(T *component)

This method constructs the Component of type T using the provided args. If the Component can be attached, its VOnInit and VOnEnabled will be invoked.

template<typename T >
bool GameObject::DisableComponent ( void  )

Disable a Component of type T attached to this GameObject.

Template Parameters
TA sub-class of Component.
Returns
true if the Component was successfully disabled.
See also
DisableCompenents()
template<typename... Args>
auto Hatchit::Game::GameObject::DisableComponents ( void  ) -> decltype(std::make_tuple(DisableComponent<Args>()...))
inline

Disable Components of type Args...

attached to this GameObject.

Template Parameters
Args...Sub-classes of Component.
Returns
A std::tuple of bools indicating if a Component was successfully disabled.
template<typename T >
bool GameObject::EnableComponent ( void  )

Enable a Component of type T attached to this GameObject.

Template Parameters
TA sub-class of Component.
Returns
true if the Component was successfully enabled.
See also
EnableComponents()
template<typename... Args>
auto Hatchit::Game::GameObject::EnableComponents ( void  ) -> decltype(std::make_tuple(EnableComponent<Args>()...))
inline

Enable Components of type Args...

attached to this GameObject.

Template Parameters
Args...Sub-classes of Component.
Returns
A std::tuple of bools indicating if a Component was successfully enabled.
See also
EnableComponent()
GameObject * GameObject::GetChildAtIndex ( std::size_t  index)

Returns a child GameObject located at the provided index.

Parameters
indexThe index of the particular GameObject to locate.
Returns
The pointer to the child GameObject, or a nullptr if it could not located.
template<typename T >
T * GameObject::GetComponent ( void  )

Return a Component of type T attached to this GameObject.

Template Parameters
TA sub-class of Component.
Returns
Pointer to the Component, or nullptr if the Component was not present.
See also
GetComponents()
template<typename... Args>
std::tuple< Args *... > GameObject::GetComponents ( void  )

Returns Components of type Args...

attached to this GameObject.

Template Parameters
Args...Sub-classes of Component.
Returns
A std::tuple of Component pointers, or nullptr if a Component was not present.
See also
GetComponent()
bool GameObject::GetEnabled ( void  ) const

Indicates whether or not this GameObject is enabled.

Returns
bool indicating if this GameObject is enabled.
GameObject * GameObject::GetParent ( void  )

Returns this GameObject's parent.

Returns
A pointer to the parent GameObject.
template<typename T >
bool GameObject::HasComponent ( void  ) const

Test if a Component of type T is attached to this GameObject.

Template Parameters
TA sub-class of Component.
Returns
true if there is a Component of type T attached.
template<typename T1 , typename T2 , typename... Args>
bool GameObject::HasComponent ( void  ) const

Test if Components of types T1, T2, and Args...

are attached to this GameObject.

Template Parameters
T1A sub-class of Component.
T2A sub-class of Component.
Args...Sub-classes of Component.
Returns
true if all Components are present.
void GameObject::MarkForDestroy ( void  )

Marks the GameObject to be destroyed the next time it would be updated.

this also calls VOnDestroy, as the GameObject is to be treated as if it doesn't exist after this point

void GameObject::RemoveChild ( GameObject child)

Attempts to remove provided GameObject from this GameObject.

Parameters
childThe GameObject to remove.
void GameObject::RemoveChildAtIndex ( std::size_t  index)

Attempts to remove the GameObject child at the provided index.

Parameters
indexThe index of the GameObject to remove.
template<typename T >
bool GameObject::RemoveComponent ( void  )

Attempts to remove a Component of type T.

Template Parameters
TA sub-class of Component.
Returns
bool indicating if the Component could be removed.

This method will invoke the VOnDisabled and VOnDestroy methods of the Component before deleting it.

void GameObject::SetEnabled ( bool  value)

Enables/Disables the GameObject based on the provided value.

Parameters
valueThe new value of m_enabled.
void GameObject::SetParent ( GameObject parent)

Sets the parent of this GameObject.

Parameters
parentThe new GameObject parent pointer.
void GameObject::Update ( void  )

Called once per frame while the gameobject is enabled.

Updates all components first, then all child gameobjects.


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