Peoplemon  0.1.0
Peoplemon 3 game source documentation
Public Member Functions | Friends | List of all members
core::map::Layer< T > Class Template Reference

Generic map layer class. Can be used for any type of layer. More...

#include <Layer.hpp>

Public Member Functions

 Layer ()
 Construct an empty layer. More...
 
void create (unsigned int width, unsigned int height, const T &val=T())
 Clears all stored data (if any) and creates the layer with the given size. More...
 
unsigned int width () const
 Returns the width of the layer in tiles. More...
 
unsigned int height () const
 Returns the height of the layer in tiles. More...
 
const T & get (unsigned int x, unsigned int y) const
 Returns the object in the layer at the given position. More...
 
T & getRef (unsigned int x, unsigned int y)
 Returns the object in the layer at the given position. More...
 
void set (unsigned int x, unsigned int y, const T &value)
 Sets the object in the layer at the position to the given value. More...
 

Friends

struct bl::serial::SerializableObject< Layer< T > >
 

Detailed Description

template<typename T>
class core::map::Layer< T >

Generic map layer class. Can be used for any type of layer.

Template Parameters
TThe underlying type representing an object in the layer

Definition at line 21 of file Layer.hpp.

Constructor & Destructor Documentation

◆ Layer()

template<typename T >
core::map::Layer< T >::Layer

Construct an empty layer.

Definition at line 88 of file Layer.hpp.

Member Function Documentation

◆ create()

template<typename T >
void core::map::Layer< T >::create ( unsigned int  width,
unsigned int  height,
const T &  val = T() 
)

Clears all stored data (if any) and creates the layer with the given size.

Parameters
widthThe width of the layer in tiles
heightThe height of the layer in tiles
valThe default value to fill the layer with

Definition at line 93 of file Layer.hpp.

◆ get()

template<typename T >
const T & core::map::Layer< T >::get ( unsigned int  x,
unsigned int  y 
) const

Returns the object in the layer at the given position.

Parameters
xThe zero indexed x coordinate in tiles
yThe zero indexed y coordinate in tiles
Returns
const T& The value at the given position

Definition at line 111 of file Layer.hpp.

◆ getRef()

template<typename T >
T & core::map::Layer< T >::getRef ( unsigned int  x,
unsigned int  y 
)

Returns the object in the layer at the given position.

Parameters
xThe zero indexed x coordinate in tiles
yThe zero indexed y coordinate in tiles
Returns
The value at the given position

Definition at line 123 of file Layer.hpp.

◆ height()

template<typename T >
unsigned int core::map::Layer< T >::height

Returns the height of the layer in tiles.

Definition at line 106 of file Layer.hpp.

◆ set()

template<typename T >
void core::map::Layer< T >::set ( unsigned int  x,
unsigned int  y,
const T &  value 
)

Sets the object in the layer at the position to the given value.

Parameters
xThe zero indexed x coordinate in tiles
yThe zero indexed y coordinate in tiles
valueThe value to set to

Definition at line 135 of file Layer.hpp.

◆ width()

template<typename T >
unsigned int core::map::Layer< T >::width

Returns the width of the layer in tiles.

Definition at line 101 of file Layer.hpp.

Friends And Related Function Documentation

◆ bl::serial::SerializableObject< Layer< T > >

template<typename T >
friend struct bl::serial::SerializableObject< Layer< T > >
friend

Definition at line 80 of file Layer.hpp.


The documentation for this class was generated from the following file: