#pragma once #include "Actor/Map/GameMapLayer.h" #include "Asset/Asset_Script.h" #include "Actor/Map/Tile.h" #include #include #include class BaseObject; class GameMapCamera; class GameMap { struct BackGroundAni { std::string filename; std::string layer; std::string order; }; struct MapAni { std::string filename; std::string layer; int XPos; int YPos; int ZPos; }; struct MapNpc { int id; std::string direction; int XPos; int YPos; int ZPos; }; struct MapMoveArea { int town; int area; }; using MapInfoBody = std::variant< int, std::string, std::vector, std::vector, std::vector, std::vector, std::vector, std::vector>; public: // 地图信息 std::unordered_map _MapInfo; // 地图路径 std::string _MapPath; // 地图文件夹 std::string _MapDir; // 地图宽度 int _MapLength = 0; // 地图高度 int _MapHeight = 0; // 可行区域 std::vector _MovableArea; // 调试模式 bool _DebugMode = false; public: // 图层Map 图层类型 显示对象 std::unordered_map> _LayerMap; // 所属场景 Scene *_Scene = nullptr; // 背景层移动速率 int BackgroundMoveSpeed = 103; // 地图Y轴偏移量 int MapOffsetY = 0; public: GameMap(/* args */); ~GameMap(); void LoadMap(std::string mapName); void InitConfiguration(std::string mapName); void InitTile(); void InitBackgroundAnimation(); void InitMapAnimation(); void InitVirtualMovableArea(); void Enter(Scene *scene); void HandleEvents(SDL_Event *e); void Update(float deltaTime); void AddObject(RefPtr object); public: // 检查是否可移动 VecPos3 CheckIsItMovable(VecPos3 CurPos, VecPos3 PosOffset); };