/** * Saves the tile to a YAML node. * @return YAML node. */ YAML::Node Tile::save() const { YAML::Node node; node["position"] = _pos; for (int i = 0; i < 4; i++) { node["mapDataID"].push_back(_mapDataID[i]); node["mapDataSetID"].push_back(_mapDataSetID[i]); } if (_smoke) node["smoke"] = _smoke; if (_fire) node["fire"] = _fire; if (_discovered[0] || _discovered[1] || _discovered[2]) { for (int i = 0; i < 3; i++) { node["discovered"].push_back(_discovered[i]); } } if (isUfoDoorOpen(1)) { node["openDoorWest"] = true; } if (isUfoDoorOpen(2)) { node["openDoorNorth"] = true; } return node; }
/** * Saves the tile to a YAML node. * @return YAML node. */ YAML::Node Tile::save() const { YAML::Node node; node["position"] = _pos; for (int i = 0; i < 4; i++) { node["mapDataID"].push_back(_mapDataID[i]); node["mapDataSetID"].push_back(_mapDataSetID[i]); } if (_smoke) node["smoke"] = _smoke; if (_fire) node["fire"] = _fire; if (_discovered[O_FLOOR] || _discovered[O_WESTWALL] || _discovered[O_NORTHWALL]) { for (int i = O_FLOOR; i <= O_NORTHWALL; i++) { node["discovered"].push_back(_discovered[i]); } } if (isUfoDoorOpen(O_WESTWALL)) { node["openDoorWest"] = true; } if (isUfoDoorOpen(O_NORTHWALL)) { node["openDoorNorth"] = true; } return node; }
/** * Saves the tile to binary. * @param buffer pointer to buffer. */ void Tile::saveBinary(Uint8** buffer) const { serializeInt(buffer, serializationKey._mapDataID, _mapDataID[0]); serializeInt(buffer, serializationKey._mapDataID, _mapDataID[1]); serializeInt(buffer, serializationKey._mapDataID, _mapDataID[2]); serializeInt(buffer, serializationKey._mapDataID, _mapDataID[3]); serializeInt(buffer, serializationKey._mapDataSetID, _mapDataSetID[0]); serializeInt(buffer, serializationKey._mapDataSetID, _mapDataSetID[1]); serializeInt(buffer, serializationKey._mapDataSetID, _mapDataSetID[2]); serializeInt(buffer, serializationKey._mapDataSetID, _mapDataSetID[3]); serializeInt(buffer, serializationKey._smoke, _smoke); serializeInt(buffer, serializationKey._fire, _fire); Uint8 boolFields = (_discovered[0]?1:0) + (_discovered[1]?2:0) + (_discovered[2]?4:0); boolFields |= isUfoDoorOpen(1) ? 8 : 0; // west boolFields |= isUfoDoorOpen(2) ? 0x10 : 0; // north? serializeInt(buffer, serializationKey.boolFields, boolFields); }
int Tile::closeUfoDoor() { int retval = 0; for (int part = 0; part < 4; part++) { if (isUfoDoorOpen(part)) { _currentFrame[part] = 0; retval = 1; } } return retval; }
int Tile::closeUfoDoor() { int retval = 0; for (int part = O_FLOOR; part <= O_NORTHWALL; ++part) { if (isUfoDoorOpen((TilePart)part)) { _currentFrame[part] = 0; retval = 1; } } return retval; }