2018-09-25 01:12:29 +01:00
|
|
|
#include "block.h"
|
2018-09-23 00:47:28 +01:00
|
|
|
|
2021-02-14 17:37:51 +00:00
|
|
|
Block::Block() : tile(0), collision(0), elevation(0) { }
|
2018-09-23 00:47:28 +01:00
|
|
|
|
2021-02-14 17:37:51 +00:00
|
|
|
Block::Block(uint16_t tile, uint16_t collision, uint16_t elevation) :
|
|
|
|
tile(tile),
|
|
|
|
collision(collision),
|
|
|
|
elevation(elevation)
|
|
|
|
{ }
|
2020-04-27 01:38:20 +01:00
|
|
|
|
2021-02-14 17:37:51 +00:00
|
|
|
Block::Block(uint16_t word) :
|
|
|
|
tile(word & 0x3ff),
|
|
|
|
collision((word >> 10) & 0x3),
|
|
|
|
elevation((word >> 12) & 0xf)
|
|
|
|
{ }
|
|
|
|
|
|
|
|
Block::Block(const Block &other) :
|
|
|
|
tile(other.tile),
|
|
|
|
collision(other.collision),
|
|
|
|
elevation(other.elevation)
|
|
|
|
{ }
|
2018-09-23 00:47:28 +01:00
|
|
|
|
2021-02-14 17:37:51 +00:00
|
|
|
Block &Block::operator=(const Block &other) {
|
|
|
|
tile = other.tile;
|
|
|
|
collision = other.collision;
|
|
|
|
elevation = other.elevation;
|
|
|
|
return *this;
|
2018-09-23 00:47:28 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
uint16_t Block::rawValue() {
|
|
|
|
return static_cast<uint16_t>(
|
|
|
|
(tile & 0x3ff) +
|
|
|
|
((collision & 0x3) << 10) +
|
|
|
|
((elevation & 0xf) << 12));
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Block::operator ==(Block other) {
|
|
|
|
return (tile == other.tile) && (collision == other.collision) && (elevation == other.elevation);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Block::operator !=(Block other) {
|
|
|
|
return !(operator ==(other));
|
|
|
|
}
|