5#ifndef TILESON_TERRAIN_HPP
6#define TILESON_TERRAIN_HPP
9#include "../objects/PropertyCollection.hpp"
17 inline Terrain(std::string name,
int tile);
22 [[nodiscard]]
inline const std::string &
getName()
const;
23 [[nodiscard]]
inline int getTile()
const;
27 inline T
get(
const std::string &name);
45 return m_properties.
getValue<T>(name);
63 if(json.
count(
"name") > 0) m_name = json[
"name"].
get<std::string>();
else allFound =
false;
64 if(json.
count(
"tile") > 0) m_tile = json[
"tile"].get<int>();
else allFound =
false;
66 if(json.
count(
"properties") > 0 && json[
"properties"].
isArray())
68 auto &properties = json.
array(
"properties");
69 std::for_each(properties.begin(), properties.end(), [&](std::unique_ptr<IJson> &item) { m_properties.add(*item); });
109 if(m_properties.hasProperty(name))
110 return m_properties.getProperty(name);
T get(std::string_view key)
Definition IJson.hpp:82
virtual bool isArray() const =0
virtual size_t count(std::string_view key) const =0
virtual std::vector< std::unique_ptr< IJson > > array()=0
Definition PropertyCollection.hpp:15
T getValue(const std::string &name)
Definition PropertyCollection.hpp:47
Definition Property.hpp:23
Definition Terrain.hpp:14
PropertyCollection & getProperties()
Definition Terrain.hpp:97
bool parse(IJson &json)
Definition Terrain.hpp:59
tson::Property * getProp(const std::string &name)
Definition Terrain.hpp:107
T get(const std::string &name)
Definition Terrain.hpp:43
const std::string & getName() const
Definition Terrain.hpp:79
int getTile() const
Definition Terrain.hpp:88