2021-06-07 21:48:28 +00:00
|
|
|
#include "mapobject.hpp"
|
|
|
|
|
2021-10-18 07:08:35 +00:00
|
|
|
MapObject::MapObject(uint16_t terrain_id, LandType::Value terrain_type,
|
|
|
|
uint8_t character_id, LandType::Value character_type,
|
2022-11-13 19:56:20 +00:00
|
|
|
uint32_t modifier_id, uint8_t modifier_data, const std::string &modifier_text) {
|
2021-06-07 21:48:28 +00:00
|
|
|
setTerrain(terrain_id, terrain_type);
|
2021-10-18 07:08:35 +00:00
|
|
|
if (character_id != 0)
|
2021-06-07 21:48:28 +00:00
|
|
|
setCharacter(character_id, character_type);
|
2022-11-13 19:56:20 +00:00
|
|
|
if (modifier_id != 0) {
|
|
|
|
if(!modifier_text.empty()) {
|
|
|
|
setModifier(modifier_id, modifier_text);
|
|
|
|
} else {
|
|
|
|
setModifier(modifier_id, modifier_data);
|
|
|
|
}
|
|
|
|
}
|
2021-06-07 21:48:28 +00:00
|
|
|
}
|
|
|
|
|
2021-10-18 07:08:35 +00:00
|
|
|
MapObject::MapObject(uint16_t terrain_id, uint8_t terrain_type,
|
|
|
|
uint8_t character_id, uint8_t character_type,
|
2022-11-13 19:56:20 +00:00
|
|
|
uint32_t modifier_id, uint8_t modifier_data, const std::string &modifier_text)
|
2021-10-18 07:08:35 +00:00
|
|
|
: MapObject(terrain_id, static_cast<LandType::Value>(terrain_type),
|
|
|
|
character_id, static_cast<LandType::Value>(character_type),
|
2022-11-13 19:56:20 +00:00
|
|
|
modifier_id, modifier_data, modifier_text) {}
|
2021-06-07 21:48:28 +00:00
|
|
|
|
2021-10-18 07:08:35 +00:00
|
|
|
void MapObject::setTerrain(uint16_t id, LandType::Value land_type) {
|
2021-06-07 21:48:28 +00:00
|
|
|
terrain_id = id;
|
|
|
|
terrain_type = land_type;
|
|
|
|
}
|
|
|
|
|
2021-10-18 07:08:35 +00:00
|
|
|
void MapObject::setTerrain(uint16_t id, uint8_t land_type) {
|
|
|
|
setTerrain(id, static_cast<LandType::Value>(land_type));
|
2021-06-07 21:48:28 +00:00
|
|
|
}
|
|
|
|
|
2021-10-18 07:08:35 +00:00
|
|
|
void MapObject::setCharacter(uint8_t id, LandType::Value land_type) {
|
2021-06-07 21:48:28 +00:00
|
|
|
character_id = id;
|
|
|
|
character_type = land_type;
|
2021-10-18 07:08:35 +00:00
|
|
|
if (hasModifier()) {
|
2021-06-07 21:48:28 +00:00
|
|
|
modifier_id = 0;
|
|
|
|
modifier_data = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-10-18 07:08:35 +00:00
|
|
|
void MapObject::setCharacter(uint8_t id, uint8_t land_type) {
|
|
|
|
setCharacter(id, static_cast<LandType::Value>(land_type));
|
2021-06-07 21:48:28 +00:00
|
|
|
}
|
|
|
|
|
2021-10-18 07:08:35 +00:00
|
|
|
void MapObject::setModifier(uint32_t id, uint8_t data) {
|
2021-06-07 21:48:28 +00:00
|
|
|
modifier_id = id;
|
|
|
|
modifier_data = data;
|
2021-10-18 07:08:35 +00:00
|
|
|
if (hasCharacter()) {
|
2021-06-07 21:48:28 +00:00
|
|
|
character_id = 0;
|
|
|
|
character_type = LandType::OVERWORLD;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-11-13 19:56:20 +00:00
|
|
|
void MapObject::setModifier(uint32_t id, const std::string &text) {
|
|
|
|
setModifier(id, 0);
|
|
|
|
modifier_text = text;
|
|
|
|
}
|
|
|
|
|
|
|
|
const std::string &MapObject::getModifierText() {
|
|
|
|
return modifier_text;
|
|
|
|
}
|
|
|
|
|
2021-06-07 21:48:28 +00:00
|
|
|
void MapObject::unsetTerrain() {
|
|
|
|
setTerrain(0, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
void MapObject::unsetModifier() {
|
2021-10-18 07:08:35 +00:00
|
|
|
if (hasModifier()) {
|
|
|
|
setModifier(0, 0);
|
2021-06-07 21:48:28 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void MapObject::unsetCharacter() {
|
2021-10-18 07:08:35 +00:00
|
|
|
if (hasCharacter()) {
|
|
|
|
setCharacter(0, 0);
|
2021-06-07 21:48:28 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool MapObject::hasCharacter() {
|
|
|
|
return character_id != 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool MapObject::hasModifier() {
|
|
|
|
return modifier_id != 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
uint16_t MapObject::getTerrainId() {
|
|
|
|
return terrain_id;
|
|
|
|
}
|
|
|
|
|
|
|
|
uint8_t MapObject::getCharacterId() {
|
|
|
|
return character_id;
|
|
|
|
}
|
|
|
|
|
2021-08-08 19:36:47 +00:00
|
|
|
uint32_t MapObject::getModifierId() {
|
2021-06-07 21:48:28 +00:00
|
|
|
return modifier_id;
|
|
|
|
}
|
|
|
|
|
|
|
|
LandType::Value MapObject::getTerrainType() {
|
|
|
|
return terrain_type;
|
|
|
|
}
|
|
|
|
|
|
|
|
LandType::Value MapObject::getCharacterType() {
|
|
|
|
return character_type;
|
|
|
|
}
|
|
|
|
|
|
|
|
uint8_t MapObject::getModifierData() {
|
|
|
|
return modifier_data;
|
|
|
|
}
|