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;
|
|
|
|
|
|
2022-11-15 12:19:11 +01:00
|
|
|
Actor::Actor(PScene scene)
|
|
|
|
|
: Entity(scene)
|
2020-04-15 02:03:56 +02:00
|
|
|
{
|
2023-01-21 18:43:21 +01:00
|
|
|
attachComponent<Component::Transform>();
|
2020-04-15 02:03:56 +02:00
|
|
|
}
|
2022-11-15 12:19:11 +01: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
|
|
|
}
|
2023-01-21 18:43:21 +01:00
|
|
|
|
|
|
|
|
Component::Transform& Actor::getTransform()
|
2020-04-15 02:03:56 +02:00
|
|
|
{
|
2023-01-21 18:43:21 +01:00
|
|
|
return accessComponent<Component::Transform>();
|
2020-04-15 02:03:56 +02:00
|
|
|
}
|
2020-11-03 01:18:30 +01:00
|
|
|
|