This commit is contained in:
2026-02-08 16:20:50 +08:00
parent 0ae47e5d6a
commit 8b88904ef7
72 changed files with 5963 additions and 2038 deletions

View File

@@ -1,9 +1,12 @@
#pragma once
#include "Asset/AssetManager.h"
#include "EngineFrame/Component/Canvas.h"
#include "EngineFrame/Component/Sprite.h"
class GameMap;
class Tile : public Actor
class Tile : public Canvas
{
public:
struct ImgKey
{
std::string img;
@@ -20,46 +23,40 @@ class Tile : public Actor
};
struct DrawInfo
{
ImgKey texture;
SDL_FRect rect = {0, 0, 0, 0};
ImgKey sprite_;
glm::vec2 pos;
};
public:
using TileInfoBody = std::variant<int,std::string>;
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;
/**父对象地图 */
GameMap *m_parentMap;
/**绘制精灵集 */
std::map<ImgKey, RefPtr<Sprite>> m_imgMap;
/**绘制队列 */
std::vector<DrawInfo> m_drawQueue;
/**渲染大小 */
SDL_Rect m_srcRect;
SDL_FRect m_rect;
/**大纹理构造完成Flag */
bool m_isBuild = false;
/**基础地板宽度 */
float m_BasicTileWidth = 0;
/**基础地板高度 */
float m_BasicTileHeight = 0;
/**Ex地板高度 */
float m_ExTileHeight = 0;
/**Tile横轴个数 */
int m_tileX = 0;
/**横向地板数量 */
int m_Tile_X_Count = 0;
/**纵向最大偏移 */
float m_tileY = 0;
public:
Tile(GameMap *parentMap, std::vector<std::string> normal,std::vector<std::string> ex);
Tile(GameMap *parentMap, std::vector<std::string> normal, std::vector<std::string> ex);
~Tile();
void InitTile(std::string Path,int Index);
void InitTile(std::string Path, int Index);
void InitExTile(std::string Path, int Index);
void InitInfo(std::string Path, TileInfo &m_data);
void PreRender() override;
void Render() override;
// void SetPos(Vec2 pos) override;
void DrawTile();
};