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

155 lines
3.3 KiB
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/Components/Component.h"
#include "Scene/Scene.h"
2020-04-15 02:03:56 +02:00
using namespace Seele;
Actor::Actor()
{
}
Actor::~Actor()
{
}
2022-01-12 14:40:26 +01:00
void Actor::launchStart()
2020-05-05 01:51:13 +02:00
{
2022-01-12 14:40:26 +01:00
rootComponent->launchStart();
for(auto child : children)
{
child->launchStart();
}
start();
}
Array<Job> Actor::launchTick(float deltaTime) const
{
Array<Job> result = rootComponent->launchTick(deltaTime);
for(auto child : children)
{
result.addAll(child->launchTick(deltaTime));
}
result.add(tick(deltaTime));
return result;
}
Array<Job> Actor::launchUpdate()
{
Array<Job> result = rootComponent->launchUpdate();
for(auto child : children)
{
result.addAll(child->launchUpdate());
}
result.add(update());
return result;
2020-05-05 01:51:13 +02:00
}
void Actor::notifySceneAttach(PScene scene)
{
owningScene = scene;
rootComponent->notifySceneAttach(scene);
2021-05-06 17:02:10 +02:00
for(auto child : children)
{
child->notifySceneAttach(scene);
}
2020-05-05 01:51:13 +02:00
}
PScene Actor::getScene()
{
return owningScene;
}
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);
child->notifySceneAttach(owningScene);
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);
child->notifySceneAttach(nullptr);
2020-04-15 02:03:56 +02:00
}
2022-03-19 22:45:30 +01:00
//void Actor::setAbsoluteLocation(Vector location)
//{
// rootComponent->setWorldLocation(location);
//}
//
//void Actor::setAbsoluteRotation(Quaternion rotation)
//{
// rootComponent->setAbsoluteRotation(rotation);
//}
//void Actor::setAbsoluteRotation(Vector rotation)
//{
// rootComponent->setAbsoluteRotation(rotation);
//}
//void Actor::setWorldScale(Vector scale)
//{
// rootComponent->setWorldScale(scale);
//}
2020-04-15 02:03:56 +02:00
void Actor::setRelativeLocation(Vector location)
{
rootComponent->setRelativeLocation(location);
}
2020-10-23 01:47:56 +02:00
void Actor::setRelativeRotation(Quaternion rotation)
{
rootComponent->setRelativeRotation(rotation);
}
void Actor::setRelativeRotation(Vector rotation)
2020-04-15 02:03:56 +02:00
{
rootComponent->setRelativeRotation(rotation);
}
void Actor::setRelativeScale(Vector scale)
{
rootComponent->setRelativeScale(scale);
}
2022-03-19 22:45:30 +01:00
//void Actor::addAbsoluteTranslation(Vector translation)
//{
// rootComponent->addAbsoluteTranslation(translation);
//}
//void Actor::addAbsoluteRotation(Quaternion rotation)
//{
// rootComponent->addAbsoluteRotation(rotation);
//}
//void Actor::addAbsoluteRotation(Vector rotation)
//{
// rootComponent->addAbsoluteRotation(rotation);
//}
void Actor::addRelativeLocation(Vector translation)
2020-04-15 02:03:56 +02:00
{
2022-03-19 22:45:30 +01:00
rootComponent->addRelativeLocation(translation);
2020-04-15 02:03:56 +02:00
}
2022-03-19 22:45:30 +01:00
void Actor::addRelativeRotation(Quaternion rotation)
2020-10-23 01:47:56 +02:00
{
2022-03-19 22:45:30 +01:00
rootComponent->addRelativeRotation(rotation);
2020-10-23 01:47:56 +02:00
}
2022-03-19 22:45:30 +01:00
void Actor::addRelativeRotation(Vector rotation)
2020-04-15 02:03:56 +02:00
{
2022-03-19 22:45:30 +01:00
rootComponent->addRelativeRotation(rotation);
2020-04-15 02:03:56 +02:00
}
PComponent Actor::getRootComponent()
{
return rootComponent;
}
void Actor::setRootComponent(PComponent newRoot)
{
2020-05-05 01:51:13 +02:00
if(rootComponent != nullptr)
{
rootComponent->owner = nullptr;
}
2020-04-15 02:03:56 +02:00
rootComponent = newRoot;
2020-05-05 01:51:13 +02:00
rootComponent->owner = this;
2020-04-15 02:03:56 +02:00
}
Transform Actor::getTransform() const
{
return rootComponent->getTransform();
}