Skip to content

Commit

Permalink
Added reference to Transform in component
Browse files Browse the repository at this point in the history
  • Loading branch information
FraserConnolly committed May 8, 2024
1 parent 48566a6 commit aff2758
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
15 changes: 8 additions & 7 deletions Lab1/Component.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@
#include "GameObject.h"

Component::Component ( const ComponentTypes type, GameObject & hostObject ) :
m_isEnabled ( true ), m_componentType ( type ), m_gameObject ( hostObject )
{
}
Component ( type, hostObject, true )
{ }

Component::Component ( const ComponentTypes type, GameObject & hostObject, const bool enable ) :
m_isEnabled ( enable ), m_componentType ( type ), m_gameObject ( hostObject )
{
}
Component::Component ( const ComponentTypes type, GameObject & hostObject, const bool enable ) :
m_componentType ( type ),
m_gameObject ( hostObject ),
m_transform ( hostObject.GetTransform ( ) ),
m_isEnabled ( enable )
{ }

GameObject & Component::GetGameObject ( ) const
{
Expand Down
2 changes: 2 additions & 0 deletions Lab1/Component.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include "ComponentTypes.h"

class GameObject;
class Transform;

class Component
{
Expand Down Expand Up @@ -44,6 +45,7 @@ class Component
ComponentTypes m_componentType;

GameObject & m_gameObject;
Transform & m_transform;

Component ( const ComponentTypes type, GameObject & hostObject );
Component ( const ComponentTypes type, GameObject & hostObject, const bool enable );
Expand Down

0 comments on commit aff2758

Please sign in to comment.