diff --git a/core/src/TilePalette.cpp b/core/src/TilePalette.cpp new file mode 100644 index 0000000..5408305 --- /dev/null +++ b/core/src/TilePalette.cpp @@ -0,0 +1,156 @@ +#include "vf/TilePalette.h" + +namespace vf { + +namespace { + +using M = TileMaterial; +using P = TilePattern; + +TileSpec makeTile(const char* name, M material, P pattern, TileRgb base, TileRgb accent, + float noise, float scale, float density) { + TileSpec spec; + spec.name = name; + spec.material = material; + spec.pattern = pattern; + spec.base = base; + spec.accent = accent; + spec.noise = noise; + spec.scale = scale; + spec.density = density; + return spec; +} + +TileSpec runsVertical(TileSpec spec) { + spec.vertical = true; + return spec; +} + +TileSpec flipped(TileSpec spec) { + spec.flipped = true; + return spec; +} + +TileSpec cutOut(TileSpec spec) { + spec.cutout = true; + return spec; +} + +// Tiles 0..14 predate the palette. Their base colours, the three ore vein +// colours and the green lip on the grass side are copied out of the old +// render/Atlas.cpp byte for byte so the existing world keeps its look. +void appendOverworldBasics(std::vector& rows) { + rows.push_back(makeTile("grassTop", M::Foliage, P::Solid, {86, 154, 66}, {112, 182, 88}, + 0.11f, 0.45f, 0.45f)); + rows.push_back(makeTile("grassSide", M::Soil, P::EdgeBand, {112, 92, 58}, {86, 154, 66}, + 0.11f, 0.29f, 0.50f)); + rows.push_back(makeTile("dirt", M::Soil, P::Solid, {119, 88, 58}, {94, 68, 44}, + 0.11f, 0.55f, 0.55f)); + rows.push_back(makeTile("stone", M::Stone, P::Solid, {129, 129, 132}, {154, 154, 158}, + 0.11f, 0.50f, 0.42f)); + rows.push_back(makeTile("sand", M::Soil, P::Solid, {214, 199, 143}, {236, 224, 178}, + 0.11f, 0.35f, 0.45f)); + rows.push_back(runsVertical(makeTile("woodBark", M::Wood, P::Plank, {104, 78, 46}, + {70, 50, 30}, 0.11f, 0.28f, 0.60f))); + rows.push_back(makeTile("woodRings", M::Wood, P::GrowthRings, {160, 128, 78}, {114, 86, 48}, + 0.11f, 0.30f, 0.85f)); + rows.push_back(makeTile("leaves", M::Foliage, P::Splatter, {58, 122, 52}, {34, 84, 32}, + 0.11f, 0.35f, 0.50f)); + rows.push_back(makeTile("water", M::Fluid, P::Liquid, {54, 96, 168}, {104, 154, 220}, + 0.07f, 0.50f, 0.70f)); + rows.push_back(makeTile("snow", M::Crystal, P::Solid, {236, 240, 245}, {206, 218, 236}, + 0.11f, 0.40f, 0.45f)); + rows.push_back(makeTile("coalOre", M::Stone, P::OreSpeckle, {129, 129, 132}, {38, 38, 42}, + 0.11f, 0.45f, 0.34f)); + rows.push_back(makeTile("ironOre", M::Stone, P::OreSpeckle, {129, 129, 132}, {196, 156, 120}, + 0.11f, 0.38f, 0.30f)); + rows.push_back(makeTile("goldOre", M::Stone, P::OreSpeckle, {129, 129, 132}, {238, 214, 96}, + 0.11f, 0.32f, 0.27f)); + rows.push_back(makeTile("gravel", M::Stone, P::Splatter, {122, 120, 120}, {84, 82, 84}, + 0.11f, 0.25f, 0.55f)); + rows.push_back(makeTile("glowstone", M::Light, P::Dots, {242, 220, 132}, {255, 250, 212}, + 0.14f, 0.40f, 0.50f)); +} + +// Cut stone, worked wood and the deep ores. Every stone borne ore keeps the +// stone base colour and is told apart by its vein colour alone, which is how +// the three original ores already worked. +void appendBuildingAndOres(std::vector& rows) { + rows.push_back(makeTile("cobblestone", M::Stone, P::Splatter, {124, 124, 126}, {90, 90, 94}, + 0.12f, 0.45f, 0.52f)); + rows.push_back(makeTile("planks", M::Wood, P::Plank, {166, 132, 82}, {124, 94, 54}, + 0.09f, 0.35f, 0.50f)); + rows.push_back(makeTile("sandstoneTop", M::Stone, P::Solid, {224, 212, 160}, {198, 184, 132}, + 0.08f, 0.55f, 0.45f)); + rows.push_back(makeTile("sandstoneSide", M::Stone, P::Strata, {219, 206, 152}, {188, 174, 122}, + 0.08f, 0.40f, 0.35f)); + rows.push_back(makeTile("ice", M::Crystal, P::Liquid, {150, 190, 236}, {206, 230, 250}, + 0.07f, 0.40f, 0.60f)); + rows.push_back(makeTile("bedrock", M::Stone, P::Splatter, {62, 62, 66}, {22, 22, 26}, + 0.14f, 0.35f, 0.55f)); + rows.push_back(makeTile("obsidian", M::Crystal, P::Solid, {26, 20, 38}, {92, 66, 132}, + 0.12f, 0.50f, 0.60f)); + rows.push_back(makeTile("lava", M::Light, P::Liquid, {214, 84, 18}, {255, 216, 88}, + 0.10f, 0.45f, 0.75f)); + rows.push_back(makeTile("diamondOre", M::Stone, P::OreSpeckle, {129, 129, 132}, {104, 224, 222}, + 0.11f, 0.36f, 0.26f)); + rows.push_back(makeTile("redstoneOre", M::Stone, P::OreSpeckle, {129, 129, 132}, {198, 32, 32}, + 0.11f, 0.34f, 0.30f)); + rows.push_back(makeTile("emeraldOre", M::Stone, P::OreSpeckle, {129, 129, 132}, {56, 204, 104}, + 0.11f, 0.30f, 0.29f)); + rows.push_back(makeTile("lapisOre", M::Stone, P::OreSpeckle, {129, 129, 132}, {42, 72, 182}, + 0.11f, 0.40f, 0.28f)); +} + +// Workstations, the furnace pair and the whole redstone bench. Anything that +// has a hot state carries the Light material so its glow reads as emitted +// rather than painted on. +void appendUtilityAndRedstone(std::vector& rows) { + rows.push_back(flipped(makeTile("craftingTableTop", M::Wood, P::Lattice, {162, 128, 80}, + {96, 70, 42}, 0.08f, 0.10f, 0.55f))); + rows.push_back(runsVertical(makeTile("craftingTableSide", M::Wood, P::Plank, {150, 116, 72}, + {104, 76, 44}, 0.09f, 0.30f, 0.50f))); + rows.push_back(flipped(makeTile("furnaceFrontCold", M::Stone, P::EdgeBand, {122, 122, 124}, + {44, 42, 44}, 0.09f, 0.68f, 0.50f))); + rows.push_back(makeTile("furnaceSide", M::Stone, P::Solid, {118, 118, 120}, {92, 92, 96}, + 0.09f, 0.45f, 0.50f)); + rows.push_back(flipped(makeTile("furnaceFrontLit", M::Light, P::EdgeBand, {122, 122, 124}, + {248, 168, 52}, 0.14f, 0.68f, 0.50f))); + rows.push_back(makeTile("chest", M::Wood, P::Plank, {150, 110, 58}, {84, 58, 28}, + 0.09f, 0.42f, 0.45f)); + rows.push_back(cutOut(runsVertical(makeTile("torch", M::Light, P::Cross, {132, 96, 52}, + {255, 226, 140}, 0.15f, 0.55f, 0.40f)))); + rows.push_back(cutOut(makeTile("redstoneWire", M::Metal, P::Cross, {124, 20, 20}, + {216, 48, 48}, 0.10f, 0.60f, 0.50f))); + rows.push_back(cutOut(runsVertical(makeTile("redstoneTorch", M::Light, P::Cross, {124, 90, 50}, + {240, 72, 60}, 0.15f, 0.55f, 0.40f)))); + rows.push_back(makeTile("redstoneLamp", M::Metal, P::Dots, {126, 88, 50}, {84, 58, 32}, + 0.10f, 0.45f, 0.55f)); + rows.push_back(makeTile("redstoneLampLit", M::Light, P::Dots, {248, 214, 138}, {255, 244, 196}, + 0.16f, 0.45f, 0.55f)); + rows.push_back(cutOut(runsVertical(makeTile("lever", M::Wood, P::Cross, {118, 86, 50}, + {80, 56, 32}, 0.10f, 0.45f, 0.35f)))); + rows.push_back(makeTile("button", M::Stone, P::GrowthRings, {126, 126, 130}, {92, 92, 96}, + 0.09f, 0.90f, 0.75f)); + rows.push_back(makeTile("redstoneBlock", M::Metal, P::Splatter, {172, 26, 26}, {216, 60, 50}, + 0.11f, 0.40f, 0.55f)); + rows.push_back(makeTile("repeater", M::Stone, P::Dots, {166, 166, 170}, {206, 54, 44}, + 0.08f, 0.55f, 0.22f)); + rows.push_back(makeTile("comparator", M::Stone, P::Dots, {158, 160, 166}, {228, 86, 72}, + 0.08f, 0.50f, 0.30f)); + rows.push_back(makeTile("pistonFacePlate", M::Wood, P::Plank, {188, 158, 102}, {132, 104, 58}, + 0.09f, 0.50f, 0.45f)); + rows.push_back(makeTile("pistonSide", M::Stone, P::Strata, {150, 144, 132}, {108, 102, 92}, + 0.09f, 0.45f, 0.30f)); + rows.push_back(makeTile("pistonBack", M::Stone, P::Solid, {138, 132, 120}, {100, 96, 86}, + 0.09f, 0.40f, 0.50f)); + rows.push_back(makeTile("pistonStickyFace", M::Organic, P::Splatter, {150, 196, 110}, + {108, 164, 78}, 0.10f, 0.35f, 0.55f)); + rows.push_back(flipped(makeTile("pistonHead", M::Wood, P::Plank, {196, 166, 110}, + {138, 108, 60}, 0.09f, 0.55f, 0.45f))); + rows.push_back(makeTile("tntCaps", M::Fabric, P::GrowthRings, {186, 52, 40}, {120, 28, 22}, + 0.09f, 0.55f, 0.70f)); + rows.push_back(makeTile("tntFuseBand", M::Fabric, P::Strata, {206, 62, 46}, {236, 236, 236}, + 0.09f, 0.20f, 0.30f)); +} +