mirror of
https://github.com/barkeser2002/flower.git
synced 2026-09-25 14:56:14 +03:00
57 lines
1009 B
C++
57 lines
1009 B
C++
#pragma once
|
|
|
|
#include "Pch.h"
|
|
#include "../Core/Core.h"
|
|
#include "../RuntimeModule.h"
|
|
|
|
namespace Flower
|
|
{
|
|
class SceneNode;
|
|
|
|
class Component
|
|
{
|
|
ARCHIVE_DECLARE;
|
|
|
|
#pragma region SerializeField
|
|
////////////////////////////// Serialize area //////////////////////////////
|
|
protected:
|
|
std::weak_ptr<SceneNode> m_node;
|
|
|
|
////////////////////////////// Serialize area //////////////////////////////
|
|
#pragma endregion SerializeField
|
|
|
|
public:
|
|
Component() = default;
|
|
Component(std::shared_ptr<SceneNode> sceneNode) :
|
|
m_node(sceneNode)
|
|
{
|
|
|
|
}
|
|
|
|
virtual ~Component() { }
|
|
|
|
void setNode(std::weak_ptr<SceneNode> node)
|
|
{
|
|
m_node = node;
|
|
}
|
|
|
|
bool isValid() const { return m_node.lock().get(); }
|
|
|
|
std::shared_ptr<SceneNode> getNode()
|
|
{
|
|
CHECK(isValid());
|
|
return m_node.lock();
|
|
}
|
|
|
|
public:
|
|
void markDirty();
|
|
|
|
virtual void init() { }
|
|
|
|
// Tick function should call every frame.
|
|
virtual void tick(const RuntimeModuleTickData& tickData) {}
|
|
|
|
virtual void release() { }
|
|
};
|
|
}
|