59 lines
1.4 KiB
C++
59 lines
1.4 KiB
C++
#pragma once
|
|
|
|
#include <string>
|
|
#include <cstdint>
|
|
#include <ostream>
|
|
|
|
namespace XCEngine {
|
|
namespace Components {
|
|
|
|
class GameObject;
|
|
class TransformComponent;
|
|
class Scene;
|
|
|
|
class Component {
|
|
public:
|
|
virtual ~Component() = default;
|
|
|
|
virtual void Awake() {}
|
|
virtual void Start() {}
|
|
virtual void Update(float deltaTime) {}
|
|
virtual void FixedUpdate() {}
|
|
virtual void LateUpdate(float deltaTime) {}
|
|
virtual void OnEnable() {}
|
|
virtual void OnDisable() {}
|
|
virtual void OnDestroy() {}
|
|
virtual void OnCollisionEnter(GameObject* other) {}
|
|
virtual void OnCollisionStay(GameObject* other) {}
|
|
virtual void OnCollisionExit(GameObject* other) {}
|
|
virtual void OnTriggerEnter(GameObject* other) {}
|
|
virtual void OnTriggerStay(GameObject* other) {}
|
|
virtual void OnTriggerExit(GameObject* other) {}
|
|
|
|
virtual std::string GetName() const = 0;
|
|
|
|
virtual void Serialize(std::ostream& os) const {}
|
|
virtual void Deserialize(std::istream& is) {}
|
|
|
|
GameObject* GetGameObject() const { return m_gameObject; }
|
|
TransformComponent& transform() const;
|
|
Scene* GetScene() const;
|
|
|
|
bool IsEnabled() const { return m_enabled; }
|
|
void SetEnabled(bool enabled);
|
|
|
|
protected:
|
|
Component() = default;
|
|
|
|
private:
|
|
bool m_enabled = true;
|
|
|
|
protected:
|
|
GameObject* m_gameObject = nullptr;
|
|
|
|
friend class GameObject;
|
|
};
|
|
|
|
} // namespace Components
|
|
} // namespace XCEngine
|