2025-09-15 11:28:54 +08:00
|
|
|
#include "Actor.h"
|
|
|
|
|
#include "EngineFrame/Scene/Scene.h"
|
2025-09-18 15:21:43 +08:00
|
|
|
#include <algorithm>
|
2025-09-15 11:28:54 +08:00
|
|
|
|
|
|
|
|
Actor::Actor()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Actor::~Actor()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Actor::Init()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Actor::HandleEvents(SDL_Event *e)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Actor::Update(float deltaTime)
|
|
|
|
|
{
|
|
|
|
|
Actor_base::Update(deltaTime);
|
|
|
|
|
RefPtr<Component> child = m_Components.GetFirst();
|
|
|
|
|
while (child)
|
|
|
|
|
{
|
2025-09-18 15:21:43 +08:00
|
|
|
if (child->hasTag(Tag::UPDATE))
|
|
|
|
|
child->Update(deltaTime);
|
|
|
|
|
if (child->hasTag(Tag::RENDER))
|
|
|
|
|
{
|
|
|
|
|
}
|
2025-09-15 11:28:54 +08:00
|
|
|
child = child->GetNext();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Actor::Render(float deltaTime)
|
|
|
|
|
{
|
|
|
|
|
Actor_base::Render(deltaTime);
|
|
|
|
|
RefPtr<Component> child = m_Components.GetFirst();
|
|
|
|
|
while (child)
|
|
|
|
|
{
|
2025-09-18 15:21:43 +08:00
|
|
|
if (child->hasTag(Tag::RENDER))
|
|
|
|
|
child->Render(deltaTime);
|
2025-09-15 11:28:54 +08:00
|
|
|
child = child->GetNext();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Actor::Clear()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Actor::AddComponent(RefPtr<Component> Component)
|
|
|
|
|
{
|
|
|
|
|
m_Components.PushBack(Component);
|
2025-09-18 15:21:43 +08:00
|
|
|
Component->OnAdded(this);
|
|
|
|
|
Component->ReorderComponents();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Actor::RemoveComponent(RefPtr<Component> Component)
|
|
|
|
|
{
|
|
|
|
|
Component->Parent = nullptr;
|
|
|
|
|
m_Components.Remove(Component);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Actor::SetPos(SDL_Point pos)
|
|
|
|
|
{
|
|
|
|
|
this->Pos = pos;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SDL_Point Actor::GetPos()
|
|
|
|
|
{
|
|
|
|
|
return this->Pos;
|
|
|
|
|
}
|