mirror of
https://github.com/barkeser2002/flower.git
synced 2026-09-25 18:56:16 +03:00
47 lines
872 B
C++
47 lines
872 B
C++
#pragma once
|
|
|
|
#include <util/util.h>
|
|
#include <asset/asset_archive.h>
|
|
|
|
namespace engine
|
|
{
|
|
class SceneNode;
|
|
|
|
class Component
|
|
{
|
|
public:
|
|
Component() = default;
|
|
Component(std::shared_ptr<SceneNode> sceneNode) : m_node(sceneNode) { }
|
|
|
|
virtual ~Component() = default;
|
|
|
|
// Interface.
|
|
virtual void init() { }
|
|
virtual void onGameBegin() { }
|
|
virtual void onGamePause() { }
|
|
virtual void onGameContinue() { }
|
|
virtual void onGameStop() { }
|
|
virtual void tick(const RuntimeModuleTickData& tickData) {}
|
|
virtual void release() { }
|
|
|
|
// Change owner node.
|
|
void setNode(std::weak_ptr<SceneNode> node);
|
|
|
|
// Get owner node.
|
|
std::shared_ptr<SceneNode> getNode();
|
|
|
|
// Component is valid or not.
|
|
bool isValid() const;
|
|
|
|
// Mark dirty.
|
|
void markDirty();
|
|
|
|
protected:
|
|
ARCHIVE_DECLARE;
|
|
|
|
// Component host node.
|
|
std::weak_ptr<SceneNode> m_node;
|
|
};
|
|
}
|
|
|