Peoplemon  0.1.0
Peoplemon 3 game source documentation
LayerSet.hpp
Go to the documentation of this file.
1 #ifndef CORE_MAPS_LAYERSET_HPP
2 #define CORE_MAPS_LAYERSET_HPP
3 
5 #include <Core/Maps/Layer.hpp>
6 #include <Core/Maps/Tile.hpp>
7 
8 namespace core
9 {
10 namespace map
11 {
19 
27 
35 
43 
51 class LayerSet {
52 public:
57  LayerSet() = default;
58 
69  void init(unsigned int width, unsigned int height, unsigned int bottomLayerCount,
70  unsigned int ysortLayerCount, unsigned int topLayercount);
71 
78 
84  const CollisionLayer& collisionLayer() const;
85 
92 
98  const CatchLayer& catchLayer() const;
99 
105  std::vector<TileLayer>& bottomLayers();
106 
112  std::vector<TileLayer>& ysortLayers();
113 
119  std::vector<TileLayer>& topLayers();
120 
126  const std::vector<TileLayer>& bottomLayers() const;
127 
133  const std::vector<TileLayer>& ysortLayers() const;
134 
140  const std::vector<TileLayer>& topLayers() const;
141 
146  unsigned int layerCount() const;
147 
155  TileLayer& getLayer(unsigned int layer);
156 
157 private:
158  CollisionLayer collisions;
159  CatchLayer catches;
160  std::vector<TileLayer> bottom;
161  std::vector<TileLayer> ysort;
162  std::vector<TileLayer> top;
163 
164  friend struct bl::serial::SerializableObject<LayerSet>;
165 };
166 
167 } // namespace map
168 } // namespace core
169 
170 namespace bl
171 {
172 namespace serial
173 {
174 template<>
175 struct SerializableObject<core::map::LayerSet> : public SerializableObjectBase {
176  SerializableField<1, core::map::LayerSet, core::map::CollisionLayer> collisions;
177  SerializableField<2, core::map::LayerSet, core::map::CatchLayer> catches;
178  SerializableField<3, core::map::LayerSet, std::vector<core::map::TileLayer>> bottom;
179  SerializableField<4, core::map::LayerSet, std::vector<core::map::TileLayer>> ysort;
180  SerializableField<5, core::map::LayerSet, std::vector<core::map::TileLayer>> top;
181 
183  : SerializableObjectBase("LayerSet")
184  , collisions("cols", *this, &core::map::LayerSet::collisions, SerializableFieldBase::Required{})
185  , catches("catches", *this, &core::map::LayerSet::catches, SerializableFieldBase::Required{})
186  , bottom("bottom", *this, &core::map::LayerSet::bottom, SerializableFieldBase::Required{})
187  , ysort("ysort", *this, &core::map::LayerSet::ysort, SerializableFieldBase::Required{})
188  , top("top", *this, &core::map::LayerSet::top, SerializableFieldBase::Required{}) {}
189 };
190 
191 } // namespace serial
192 } // namespace bl
193 
194 #endif
Core classes and functionality for both the editor and game.
Encapsulates a set of layers for a given map height. Maps have one LayerSet per height level,...
Definition: LayerSet.hpp:51
void init(unsigned int width, unsigned int height, unsigned int bottomLayerCount, unsigned int ysortLayerCount, unsigned int topLayercount)
Creates the given number of layers and sets the proper size for each layer, initializing each layer t...
Definition: LayerSet.cpp:10
CatchLayer & catchLayer()
Returns a reference to the catchable layer for this set.
Definition: LayerSet.cpp:29
std::vector< TileLayer > & bottomLayers()
Returns a reference to the bottom tiles in this set.
Definition: LayerSet.cpp:33
std::vector< TileLayer > & topLayers()
Returns a reference to the top tiles in this set.
Definition: LayerSet.cpp:37
CollisionLayer & collisionLayer()
Returns a reference to the collision layer for this set.
Definition: LayerSet.cpp:25
TileLayer & getLayer(unsigned int layer)
Returns a reference to the given tile layer. Helper to use absolute indices to access all layer zones...
Definition: LayerSet.cpp:47
std::vector< TileLayer > & ysortLayers()
Returns a reference to the sorted tiles in this set.
Definition: LayerSet.cpp:35
LayerSet()=default
Builds a new empty layer set.
unsigned int layerCount() const
Returns the total number of layers contained.
Definition: LayerSet.cpp:39
SerializableField< 5, core::map::LayerSet, std::vector< core::map::TileLayer > > top
Definition: LayerSet.hpp:180
SerializableField< 1, core::map::LayerSet, core::map::CollisionLayer > collisions
Definition: LayerSet.hpp:176
SerializableField< 3, core::map::LayerSet, std::vector< core::map::TileLayer > > bottom
Definition: LayerSet.hpp:178
SerializableField< 2, core::map::LayerSet, core::map::CatchLayer > catches
Definition: LayerSet.hpp:177
SerializableField< 4, core::map::LayerSet, std::vector< core::map::TileLayer > > ysort
Definition: LayerSet.hpp:179