SwitchGame/source/EngineFrame/Component/Component.h

60 lines
1.7 KiB
C
Raw Normal View History

2025-09-15 11:28:54 +08:00
#pragma once
#include "Tool/IntrusiveList.hpp"
#include "Tool/RefPtr.h"
#include "Tool/RefObject.h"
#include "Tool/TagGed.h"
#include <SDL.h>
class Actor;
class Component : public RefObject, public TagGed, protected IntrusiveListValue<RefPtr<Component>>
{
2025-09-18 15:21:43 +08:00
friend IntrusiveList<RefPtr<Component>>;
public:
using IntrusiveListValue<RefPtr<Component>>::GetNext;
using IntrusiveListValue<RefPtr<Component>>::GetPrev;
2025-09-15 11:28:54 +08:00
private:
/* data */
std::string m_Name;
2025-09-18 15:21:43 +08:00
2025-09-15 11:28:54 +08:00
public:
Component(/* args */);
~Component();
virtual void Init();
virtual void HandleEvents(SDL_Event *e);
virtual void Update(float deltaTime);
virtual void Render(float deltaTime);
virtual void Clear();
void SetName(std::string name);
2025-09-18 15:21:43 +08:00
virtual void OnAdded(Actor *actor);
// 设置渲染层级
void SetRenderZOrder(int zOrder);
// 获取渲染层级
int GetRenderZOrder();
// 重新排列组件
void ReorderComponents();
2025-09-15 11:28:54 +08:00
2025-09-19 12:18:57 +08:00
// 设置迭代的坐标
virtual void SetIterationPos(VecPos pos);
// 获取迭代的坐标
VecPos GetIterationPos();
// 设置迭代的缩放
virtual void SetIterationScale(VecSize scale);
// 获取迭代的缩放
VecSize GetIterationScale();
// 设置迭代的旋转角度
virtual void SetIterationAngle(float angle);
// 获取迭代的旋转角度
float GetIterationAngle();
2025-09-15 11:28:54 +08:00
public:
2025-09-18 15:21:43 +08:00
Actor *Parent = nullptr; // 指向父对象的指针,用于访问父对象
2025-09-19 12:18:57 +08:00
int RenderZOrder = 0; // 渲染层级
VecPos IterationPos = {0, 0}; // 迭代的坐标
VecSize IterationScale = {0, 0}; // 迭代的缩放
float IterationAngle = 0.0f; // 迭代的旋转角度
2025-09-15 11:28:54 +08:00
};