Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- SurfaceFormat::ColorGrid renderWorldByPurity(const World &world) {
- return renderWorld(world, [](const Tile& t) {
- if (t.hasTile) {
- const Properties::TileProperty &tprop = t.getTileProperties();
- if (tprop.givesItem == Properties::GivesItem::ALWAYS) {
- return tprop.attributes.biome & (int) Properties::Biome::CRIMSON
- ? SurfaceFormat::RGBA(255, 0, 0, 255)
- : tprop.attributes.biome & (int) Properties::Biome::CORRUPTION
- ? SurfaceFormat::RGBA(128, 0, 255, 255)
- : tprop.attributes.biome & (int) Properties::Biome::HALLOW
- ? SurfaceFormat::RGBA(64, 128, 255, 255)
- : SurfaceFormat::RGBA(32, 200, 64, 255);
- }
- }
- if (t.liquidAmount > 0 && t.liquidType != LiquidType::NONE) {
- return t.liquidType == LiquidType::WATER
- ? SurfaceFormat::RGBA(0, 0, 255, t.liquidAmount * 255 / 8)
- : t.liquidType == LiquidType::HONEY
- ? SurfaceFormat::RGBA(255, 255, 0, t.liquidAmount * 255 / 8)
- : SurfaceFormat::RGBA(255, 0, 0, t.liquidAmount * 255 / 8);
- }
- return SurfaceFormat::RGBA(255, 255, 255, 255);
- });
- }
- // ==============================================================================
- // Select lines 15-22, Refactor—→Extract method. Result:
- // ==============================================================================
- SurfaceFormat::RGBA getLiquidColor(const Tile &t);
- SurfaceFormat::ColorGrid renderWorldByPurity(const World &world) {
- return renderWorld(world, [](const Tile& t) {
- if (t.hasTile) {
- const Properties::TileProperty &tprop = t.getTileProperties();
- if (tprop.givesItem == Properties::GivesItem::ALWAYS) {
- return tprop.attributes.biome & (int) Properties::Biome::CRIMSON
- ? SurfaceFormat::RGBA(255, 0, 0, 255)
- : tprop.attributes.biome & (int) Properties::Biome::CORRUPTION
- ? SurfaceFormat::RGBA(128, 0, 255, 255)
- : tprop.attributes.biome & (int) Properties::Biome::HALLOW
- ? SurfaceFormat::RGBA(64, 128, 255, 255)
- : SurfaceFormat::RGBA(32, 200, 64, 255);
- }
- }
- return getLiquidColor(t);
- });
- }
- SurfaceFormat::ColorGrid getLiquidColor(const Tile &t) {
- if (t.liquidAmount > 0 && t.liquidType != LiquidType::NONE) {
- return t.liquidType == LiquidType::WATER
- ? this->RGBA(0, 0, 255, t.liquidAmount * 255 / 8)
- : t.liquidType == LiquidType::HONEY
- ? this->RGBA(255, 255, 0, t.liquidAmount * 255 / 8)
- : this->RGBA(255, 0, 0, t.liquidAmount * 255 / 8);
- }
- return this->RGBA(255, 255, 255, 255);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement