1 #ifndef CORE_MAPS_TILE_HPP
2 #define CORE_MAPS_TILE_HPP
4 #include <BLIB/Graphics.hpp>
5 #include <BLIB/Serialization.hpp>
6 #include <SFML/Graphics.hpp>
100 std::variant<std::monostate, bl::gfx::BatchSpriteSimple, bl::gfx::BatchSlideshowSimple,
101 std::shared_ptr<bl::gfx::Animation2D>>
106 friend struct bl::serial::SerializableObject<
Tile>;
121 if (!Serializer<core::map::Tile::IdType>::serialize(output, tile.
id()))
return false;
122 return Serializer<bool>::serialize(output, tile.
isAnimation());
128 if (!Serializer<core::map::Tile::IdType>::deserialize(input,
id))
return false;
129 if (!Serializer<bool>::deserialize(input, isAnim))
return false;
130 result.
set(
id, isAnim);
136 Serializer<bool>::size(
false);
142 struct SerializableObject<
core::map::Tile> :
public SerializableObjectBase {
143 SerializableField<1, core::map::Tile, bool>
anim;
144 SerializableField<2, core::map::Tile, core::map::Tile::IdType>
id;
147 : SerializableObjectBase(
"Tile")
148 , anim(
"anim", *this, &
core::map::Tile::isAnim, SerializableFieldBase::Required{})
149 , id(
"id", *this, &
core::map::Tile::tid, SerializableFieldBase::Required{}) {}
Core classes and functionality for both the editor and game.
bl::serial::json::Serializer< Player > Serializer
All classes and functionality used for implementing the game editor.
The primary map class that represents a usable map in the game.
Data representation of a tile in a Map TileLayer.
void step()
Triggers the animation when the tile is stepped on.
Tile(const Tile ©)=default
Copy constructs from the given tile.
IdType id() const
Returns the id of the image or animation of this tile.
static constexpr IdType Blank
Special id for blank tiles.
Tile & operator=(const Tile ©)=default
Copy constructs from the given tile.
Tile()
Makes a blank tile.
bool isAnimation() const
Returns whether this tile is an animation or not.
void set(IdType id, bool anim)
Sets the information of the tile.
static bool serialize(OutputStream &output, const core::map::Tile &tile)
static std::uint32_t size(const core::map::Tile &)
static bool deserialize(InputStream &input, core::map::Tile &result)
SerializableField< 1, core::map::Tile, bool > anim
SerializableField< 2, core::map::Tile, core::map::Tile::IdType > id
Wrapper over the core::Map class that is directly usable in a bl::gui::GUI.