加入 Node节点类 还未测试新框架
This commit is contained in:
@@ -1,22 +1,65 @@
|
||||
#pragma once
|
||||
#include "Asset/AssetManager.h"
|
||||
#include "EngineFrame/Component/Sprite.h"
|
||||
class Tile : public Sprite
|
||||
#include "EngineFrame/Component/Canvas.h"
|
||||
class GameMap;
|
||||
class Tile : public Actor
|
||||
{
|
||||
struct ImgKey
|
||||
{
|
||||
std::string img;
|
||||
int index;
|
||||
|
||||
using TileInfoBody = std::variant<
|
||||
int,
|
||||
std::string>;
|
||||
|
||||
private:
|
||||
std::unordered_map<std::string, TileInfoBody> m_data;
|
||||
bool operator<(const ImgKey &other) const
|
||||
{
|
||||
if (img != other.img)
|
||||
{
|
||||
return img < other.img; // 字符串按字典序比较
|
||||
}
|
||||
return index < other.index; // 字符串相同则比较index
|
||||
}
|
||||
};
|
||||
struct DrawInfo
|
||||
{
|
||||
ImgKey texture;
|
||||
SDL_FRect rect = {0, 0, 0, 0};
|
||||
};
|
||||
|
||||
public:
|
||||
Tile(/* args */);
|
||||
Tile(std::string Path);
|
||||
using TileInfoBody = std::variant<int,std::string>;
|
||||
using TileInfo = std::unordered_map<std::string, TileInfoBody>;
|
||||
|
||||
private:
|
||||
/**纹理 */
|
||||
RefPtr<Texture> m_texture = nullptr;
|
||||
/**FBO */
|
||||
GLuint m_fbo = 0;
|
||||
/**地图父对象 */
|
||||
GameMap* m_parentMap;
|
||||
|
||||
/**绘制纹理集 */
|
||||
std::map<ImgKey, RefPtr<Texture>> m_imgMap;
|
||||
/**绘制队列 */
|
||||
std::vector<DrawInfo> m_drawQueue;
|
||||
|
||||
/**渲染大小 */
|
||||
SDL_Rect m_srcRect;
|
||||
SDL_FRect m_rect;
|
||||
|
||||
/**大纹理构造完成Flag */
|
||||
bool m_isBuild = false;
|
||||
|
||||
/**Tile横轴个数 */
|
||||
int m_tileX = 0;
|
||||
|
||||
public:
|
||||
Tile(GameMap *parentMap, std::vector<std::string> normal,std::vector<std::string> ex);
|
||||
~Tile();
|
||||
|
||||
void SetPos(Vec2 pos) override;
|
||||
void InitTile(std::string Path,int Index);
|
||||
void InitExTile(std::string Path, int Index);
|
||||
void InitInfo(std::string Path, TileInfo &m_data);
|
||||
|
||||
void InitInfo(std::string Path);
|
||||
void PreRender() override;
|
||||
void Render() override;
|
||||
// void SetPos(Vec2 pos) override;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user