2024-02-25 14:46:47 +00:00
|
|
|
#pragma once
|
2023-06-20 04:33:09 +00:00
|
|
|
|
|
|
|
#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;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|