Files
Seele/src/Engine/Actor/Actor.cpp
T

44 lines
817 B
C++
Raw Normal View History

2020-04-15 02:03:56 +02:00
#include "Actor.h"
2020-05-05 01:51:13 +02:00
#include "Scene/Scene.h"
2020-04-15 02:03:56 +02:00
using namespace Seele;
Actor::Actor(PScene scene)
: Entity(scene)
2020-04-15 02:03:56 +02:00
{
scene->attachComponent<Component::Transform>(identifier);
2020-04-15 02:03:56 +02:00
}
2020-04-15 02:03:56 +02:00
Actor::~Actor()
{
}
2022-01-12 14:40:26 +01:00
2020-04-15 02:03:56 +02:00
void Actor::setParent(PActor newParent)
{
2022-04-13 13:01:35 +02:00
if(parent != nullptr)
{
parent->removeChild(this);
}
2020-04-15 02:03:56 +02:00
parent = newParent;
}
void Actor::addChild(PActor child)
{
children.add(child);
2020-05-05 01:51:13 +02:00
child->setParent(this);
2020-04-15 02:03:56 +02:00
}
2022-04-13 13:01:35 +02:00
void Actor::removeChild(PActor child)
2020-04-15 02:03:56 +02:00
{
children.remove(children.find(child), false);
2020-05-05 01:51:13 +02:00
child->setParent(nullptr);
2020-04-15 02:03:56 +02:00
}
const Component::Transform& Actor::getTransform() const
2020-04-15 02:03:56 +02:00
{
return scene->accessComponent<Component::Transform>(identifier);
2020-04-15 02:03:56 +02:00
}
//Component::Transform& Actor::getTransform()
//{
// return scene->accessComponent<Component::Transform>(identifier);
//}