17#ifndef _FGE_C_TILESET_HPP_INCLUDED
18#define _FGE_C_TILESET_HPP_INCLUDED
20#include "FastEngine/fge_extern.hpp"
22#include "FastEngine/C_propertyList.hpp"
23#include "FastEngine/accessor/C_texture.hpp"
31using TileId = int32_t;
70 using TileListType = std::set<fge::TileData, std::less<>>;
93 [[nodiscard]] std::string
const&
getName()
const;
166 [[nodiscard]] TileId
getLocalId(fge::Vector2i
const& position)
const;
199 [[nodiscard]] TileListType::const_iterator begin()
const;
200 [[nodiscard]] TileListType::const_iterator end()
const;
248 fge::Vector2i g_tileSize;
249 fge::Vector2i g_offset{0, 0};
250 TileListType g_tiles;
251 TileId g_firstGid{1};
256FGE_API
void to_json(nlohmann::json& j,
fge::TileSet const& p);
257FGE_API
void from_json(nlohmann::json
const& j,
fge::TileSet& p);
259FGE_API
void to_json(nlohmann::json& j,
fge::TileData const& p);
260FGE_API
void from_json(nlohmann::json
const& j,
fge::TileData& p);
A class that map a string to a Property.
Definition C_propertyList.hpp:35
This class is a wrapper for the texture manager to allow easy manipulation.
Definition C_texture.hpp:36
A class that represent a set of tiles that can be used in a TileLayer.
Definition C_tileset.hpp:68
bool isGidContained(TileId gid) const
Check if the global id is in the tileset.
void setFirstGid(TileId gid)
Set the first global id of the tileset.
void setTileSize(fge::Vector2i const &tileSize)
Set the tile size of the TileSet.
void slice()
Slice the texture into tiles.
void clearTiles()
Clear the tiles.
fge::RectInt computeTextureRect(TileId id) const
Compute the supposed texture rectangle with a local id.
fge::Vector2i const & getTileSize() const
Get the tile size of the TileSet.
fge::Vector2i const & getOffset() const
Get the offset in pixel of the TileSet.
int getRows() const
Return the number of rows in the texture.
void setName(std::string name)
Set the name of the TileSet.
fge::TileData const * getTile(TileId id) const
Retrieve a tile by its local id.
TileId getLocalId(fge::Vector2i const &position) const
Get the local id of a tile by its grid position.
TileId getFirstGid() const
Get the first global id of the tileset.
void setTexture(fge::Texture texture)
Set the texture of the TileSet.
int getColumns() const
Return the number of columns in the texture.
TileId getLocalId(TileId gid) const
Get the local id of a tile by its global id.
std::string const & getName() const
Get the name of the TileSet.
bool valid() const
Check if the TileSet have a valid Texture.
std::size_t getTileCount() const
Get the total number of tiles in the TileSet.
std::optional< fge::RectInt > getTextureRect(TileId id) const
Get the texture rectangle of a tile by its local id.
fge::Texture const & getTexture() const
Get the texture of the TileSet.
void setOffset(fge::Vector2i const &offset)
Set the offset in pixel of the TileSet.
A tile structure that contain mostly the texture rectangle and data.
Definition C_tileset.hpp:41