60 lines
1.7 KiB
C++
60 lines
1.7 KiB
C++
#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>>
|
|
{
|
|
friend IntrusiveList<RefPtr<Component>>;
|
|
|
|
public:
|
|
using IntrusiveListValue<RefPtr<Component>>::GetNext;
|
|
using IntrusiveListValue<RefPtr<Component>>::GetPrev;
|
|
|
|
private:
|
|
/* data */
|
|
std::string m_Name;
|
|
|
|
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);
|
|
virtual void OnAdded(Actor *actor);
|
|
// 设置渲染层级
|
|
void SetRenderZOrder(int zOrder);
|
|
// 获取渲染层级
|
|
int GetRenderZOrder();
|
|
// 重新排列组件
|
|
void ReorderComponents();
|
|
|
|
// 设置迭代的坐标
|
|
virtual void SetIterationPos(VecPos pos);
|
|
// 获取迭代的坐标
|
|
VecPos GetIterationPos();
|
|
// 设置迭代的缩放
|
|
virtual void SetIterationScale(VecSize scale);
|
|
// 获取迭代的缩放
|
|
VecSize GetIterationScale();
|
|
// 设置迭代的旋转角度
|
|
virtual void SetIterationAngle(float angle);
|
|
// 获取迭代的旋转角度
|
|
float GetIterationAngle();
|
|
|
|
public:
|
|
Actor *Parent = nullptr; // 指向父对象的指针,用于访问父对象
|
|
int RenderZOrder = 0; // 渲染层级
|
|
VecPos IterationPos = {0, 0}; // 迭代的坐标
|
|
VecSize IterationScale = {0, 0}; // 迭代的缩放
|
|
float IterationAngle = 0.0f; // 迭代的旋转角度
|
|
};
|