/**
 * Terrain material table — the "ground has properties" part.
 *
 * Each material is a data record the SIM owns (not the renderer). The viewport
 * only reads `color` to paint vertices; everything else (walkable, liquid,
 * future fields like friction / growth / flammability) is simulation truth that
 * creatures and, later, agents reason about.
 */
'use strict';

// Stable integer ids — stored in the terrain's material field (Uint8Array).
const MAT = Object.freeze({
  WATER: 0,
  SAND: 1,
  GRASS: 2,
  DIRT: 3,
  ROCK: 4,
  SNOW: 5,
  PATH: 6,
});

// Indexed by id. color is RGB in 0..1 for vertex coloring. Kept punchy and
// saturated on purpose — this is a game world, it should read vivid and alive,
// not a washed-out greyscale heightmap.
const MATERIALS = [
  { id: MAT.WATER, name: 'water', color: [0.10, 0.45, 0.82], walkable: false, liquid: true },
  { id: MAT.SAND, name: 'sand', color: [0.92, 0.75, 0.45], walkable: true, liquid: false },
  { id: MAT.GRASS, name: 'grass', color: [0.30, 0.75, 0.28], walkable: true, liquid: false },
  { id: MAT.DIRT, name: 'dirt', color: [0.55, 0.35, 0.20], walkable: true, liquid: false },
  { id: MAT.ROCK, name: 'rock', color: [0.62, 0.58, 0.52], walkable: true, liquid: false },
  { id: MAT.SNOW, name: 'snow', color: [0.85, 0.92, 0.97], walkable: true, liquid: false },
  // Trodden ground — the road network the worldgen lays between landmarks.
  // Warm and distinct from dirt so a path reads as *made*, not as mud.
  { id: MAT.PATH, name: 'path', color: [0.76, 0.64, 0.44], walkable: true, liquid: false },
];

function material(id) {
  return MATERIALS[id] || MATERIALS[MAT.GRASS];
}

module.exports = { MAT, MATERIALS, material };
