osb/source/game/StarDungeonImagePart.hpp

43 lines
929 B
C++
Raw Normal View History

2023-06-20 04:33:09 +00:00
#ifndef STAR_DUNGEON_IMAGE_PART_HPP
#define STAR_DUNGEON_IMAGE_PART_HPP
#include "StarDungeonGenerator.hpp"
namespace Star {
namespace Dungeon {
STAR_CLASS(ImagePartReader);
STAR_CLASS(ImageTileset);
class ImagePartReader : public PartReader {
public:
ImagePartReader(ImageTilesetConstPtr tileset) : m_tileset(tileset) {}
virtual void readAsset(String const& asset) override;
virtual Vec2U size() const override;
virtual void forEachTile(TileCallback const& callback) const override;
virtual void forEachTileAt(Vec2I pos, TileCallback const& callback) const override;
private:
List<pair<String, ImageConstPtr>> m_images;
ImageTilesetConstPtr m_tileset;
};
class ImageTileset {
public:
ImageTileset(Json const& tileset);
Tile const* getTile(Vec4B color) const;
private:
unsigned colorAsInt(Vec4B color) const;
Map<unsigned, Tile> m_tiles;
};
}
}
#endif