local function get_gas_name(name, alternative)
  if settings.startup["ske_vesta_gases"].value then
    return name
  else
    return alternative
  end
end

-- From Nauvis
table.insert(water_tile_type_names, "ammoniacal-ocean-vesta-yellow")
table.insert(water_tile_type_names, "ammoniacal-ocean-vesta-pink")
table.insert(water_tile_type_names, "ammoniacal-ocean-vesta-lime")
table.insert(water_tile_type_names, "ammoniacal-ocean-vesta-red")
table.insert(water_tile_type_names, "ammoniacal-ocean-vesta-tritium")
table.insert(water_tile_type_names, "ammoniacal-ocean-vesta-deuterium")
--table.insert(water_tile_type_names, "brash-ice-vesta")
--table.insert(water_tile_type_names, "brash-ice-vesta-pink")
--table.insert(default_tile_type_names, "dust-flat-vesta")
--table.insert(default_tile_type_names, "dust-crests-vesta")
--table.insert(default_tile_type_names, "dust-lumpy-vesta")
--table.insert(default_tile_type_names, "dust-patchy-vesta")
local fog_enabled = true

local sounds = require("__base__.prototypes.entity.sounds")

base_tiles_util = base_tiles_util or {}
water_tile_type_names = water_tile_type_names or {}
out_of_map_tile_type_names = out_of_map_tile_type_names or {}

default_transition_group_id = default_transition_group_id or 0
water_transition_group_id = water_transition_group_id or 1
out_of_map_transition_group_id = out_of_map_transition_group_id or 2

local grass_vehicle_speed_modifier = 1.6
local dirt_vehicle_speed_modifier = 1.4
local sand_vehicle_speed_modifier = 1.8
local stone_path_vehicle_speed_modifier = 1.1
local concrete_vehicle_speed_modifier = 0.8

-- From Aquilo
local tile_trigger_effects = require("__space-age__/prototypes/tile/tile-trigger-effects")
local tile_pollution = require("__space-age__/prototypes/tile/tile-pollution-values")
local tile_collision_masks = require("__base__/prototypes/tile/tile-collision-masks")
local base_sounds = require("__base__/prototypes/entity/sounds")
local base_tile_sounds = require("__base__/prototypes/tile/tile-sounds")
local tile_sounds = require("__space-age__/prototypes/tile/tile-sounds")
local tile_graphics = require("__base__/prototypes/tile/tile-graphics")
local tile_spritesheet_layout = tile_graphics.tile_spritesheet_layout

local patch_for_inner_corner_of_transition_between_transition = tile_graphics.patch_for_inner_corner_of_transition_between_transition

local aquilo_tile_offset_frozen = 50
local aquilo_tile_offset_thawed = 60

local smooth_ice_vehicle_speed_modifier = 1
local ice_vehicle_speed_modifier = 1.4
local snow_vehicle_speed_modifier = 1.8

local tile_lightening = 35

local lava_to_out_of_map_transition = space_age_tiles_util.lava_to_out_of_map_transition
local lava_stone_transitions_between_transitions = space_age_tiles_util.lava_stone_transitions_between_transitions

local gas_red_effect = {233, 169, 174}
local gas_pink_effect = {250, 233, 248}
local gas_green_effect = {195, 237, 232}
local gas_yellow_effect = {235, 231, 187}

local gas_red_effect_brighter = {252, 119, 203}
local gas_pink_effect_brighter = {252, 245, 252}
local gas_green_effect_brighter = {230, 250, 248}
local gas_yellow_effect_brighter = {242, 240, 216}

local nitrogen_crystal_effect = {223, 240, 223}

local function lerp_color_no_alpha(a, b, amount)
  return
  {
    a[1] + amount * (b[1] - a[1]),
    a[2] + amount * (b[2] - a[2]),
    a[3] + amount * (b[3] - a[3])
  }
end

local snow_map_color_low = {62, 46, 47}
local snow_map_color_high = {63, 47, 48}

local water_to_out_of_map_transition =
{
  to_tiles = out_of_map_tile_type_names,
  transition_group = out_of_map_transition_group_id,

  overlay_layer_group = "zero",
  apply_effect_color_to_overlay = true,

  background_layer_offset = 1,
  background_layer_group = "zero",
  offset_background_layer_by_tile_layer = true,

  spritesheet = "__base__/graphics/terrain/out-of-map-transition/water-out-of-map-transition-tintable.png",
  layout = tile_spritesheet_layout.transition_4_4_8_1_1,
  background_enabled = false,

  apply_waving_effect_on_masks = true,
  waving_effect_time_scale = 0.15 * 0.09,
  mask_enabled = true,
  mask_layout =
  {
    spritesheet = "__base__/graphics/terrain/masks/water-edge-transition.png",
    count = 1,
    double_side_count = 0,
    scale = 0.5,
    outer_corner_x = 64,
    side_x = 128,
    u_transition_x = 192,
    o_transition_x = 256,
    y = 0
  }
}
local ice_transitions_between_transitions =
{
  {
    transition_group1 = default_transition_group_id,
    transition_group2 = water_transition_group_id,

    spritesheet = "__skewer_planet_vesta_assets__/graphics/terrain/vesta/ice-rock2.png",
    layout = tile_spritesheet_layout.transition_3_3_3_1_0,
    background_enabled = false,
    effect_map_layout =
    {
      spritesheet = "__base__/graphics/terrain/effect-maps/water-dirt-to-land-mask.png",
      o_transition_count = 0
    },
    water_patch = {
      filename = "__space-age__/graphics/terrain/water-transitions/ice-patch.png",
      scale = 0.5,
      width = 64,
      height = 64
    }
  },
  {
    transition_group1 = default_transition_group_id,
    transition_group2 = out_of_map_transition_group_id,

    background_layer_offset = 1,
    background_layer_group = "zero",
    offset_background_layer_by_tile_layer = true,

    spritesheet = "__base__/graphics/terrain/out-of-map-transition/dirt-out-of-map-transition.png",
    layout = tile_spritesheet_layout.transition_3_3_3_1_0,
    overlay_enabled = false
  },
  {
    transition_group1 = water_transition_group_id,
    transition_group2 = out_of_map_transition_group_id,

    background_layer_offset = 1,
    background_layer_group = "zero",
    offset_background_layer_by_tile_layer = true,

    spritesheet = "__base__/graphics/terrain/out-of-map-transition/dry-dirt-shore-out-of-map-transition.png",
    layout = tile_spritesheet_layout.transition_3_3_3_1_0,
    effect_map_layout =
    {
      spritesheet = "__base__/graphics/terrain/effect-maps/water-dirt-to-out-of-map-mask.png",
      u_transition_count = 0,
      o_transition_count = 0
    }
  }
}
local ice_transitions =
{
  {
    to_tiles = water_tile_type_names,
    transition_group = water_transition_group_id,

    spritesheet = "__skewer_planet_vesta_assets__/graphics/terrain/vesta/ice-rock.png",
    layout = tile_spritesheet_layout.transition_16_16_16_4_4,
    effect_map_layout =
    {
      spritesheet = "__base__/graphics/terrain/effect-maps/water-dirt-mask.png",
      inner_corner_count = 8,
      outer_corner_count = 8,
      side_count = 8,
      u_transition_count = 2,
      o_transition_count = 1
    }
  },
  {
    to_tiles = lava_tile_type_names,
    transition_group = lava_transition_group_id,
    spritesheet = "__space-age__/graphics/terrain/water-transitions/lava-stone.png",
    lightmap_layout = { spritesheet = "__space-age__/graphics/terrain/water-transitions/lava-stone-lightmap.png" },
     -- this added the lightmap spritesheet
    layout = tile_spritesheet_layout.transition_16_16_16_4_4,
    lightmap_layout = { spritesheet = "__space-age__/graphics/terrain/water-transitions/lava-stone-lightmap.png" },
     -- this added the lightmap spritesheet
    effect_map_layout =
    {
      spritesheet = "__space-age__/graphics/terrain/effect-maps/lava-dirt-mask.png",
      inner_corner_count = 8,
      outer_corner_count = 8,
      side_count = 8,
      u_transition_count = 2,
      o_transition_count = 1
    }
  },
  {
    to_tiles = {"out-of-map","empty-space","oil-ocean-shallow"},
    transition_group = out_of_map_transition_group_id,

    background_layer_offset = 1,
    background_layer_group = "zero",
    offset_background_layer_by_tile_layer = true,

    spritesheet = "__space-age__/graphics/terrain/out-of-map-transition/volcanic-out-of-map-transition.png",
    layout = tile_spritesheet_layout.transition_4_4_8_1_1,
    overlay_enabled = false
  }
}

local foundation_transitions =
{
  {
    to_tiles = water_tile_type_names,
    transition_group = water_transition_group_id,

    spritesheet = "__space-age__/graphics/terrain/water-transitions/foundation.png",
    layout = tile_spritesheet_layout.transition_8_8_8_4_4,
    background_enabled = false,
    effect_map_layout =
    {
      spritesheet = "__base__/graphics/terrain/effect-maps/water-stone-mask.png",
      inner_corner_count = 1,
      outer_corner_count = 1,
      side_count = 1,
      u_transition_count = 1,
      o_transition_count = 1
    }
  },
  concrete_to_out_of_map_transition
}

local foundation_transitions_between_transitions =
{
  {
    transition_group1 = default_transition_group_id,
    transition_group2 = water_transition_group_id,

    spritesheet = "__space-age__/graphics/terrain/water-transitions/foundation-transitions.png",
    layout = tile_spritesheet_layout.transition_3_3_3_1_0,
    background_enabled = false,
    effect_map_layout =
    {
      spritesheet = "__base__/graphics/terrain/effect-maps/water-stone-to-land-mask.png",
      o_transition_count = 0
    }
  },
  {
    transition_group1 = default_transition_group_id,
    transition_group2 = out_of_map_transition_group_id,

    background_layer_offset = 1,
    background_layer_group = "zero",
    offset_background_layer_by_tile_layer = true,

    spritesheet = "__base__/graphics/terrain/out-of-map-transition/concrete-out-of-map-transition-b.png",
    layout = tile_spritesheet_layout.transition_3_3_3_1_0,
  },
  {
    transition_group1 = water_transition_group_id,
    transition_group2 = out_of_map_transition_group_id,

    background_layer_offset = 1,
    background_layer_group = "zero",
    offset_background_layer_by_tile_layer = true,

    spritesheet = "__base__/graphics/terrain/out-of-map-transition/concrete-shore-out-of-map-transition.png",
    layout = tile_spritesheet_layout.transition_3_3_3_1_0,
    effect_map_layout =
    {
      spritesheet = "__base__/graphics/terrain/effect-maps/water-stone-to-out-of-map-mask.png",
      u_transition_count = 0,
      o_transition_count = 0
    }
  }
}

local concrete_transitions =
{
  {
    to_tiles = water_tile_type_names,
    transition_group = water_transition_group_id,

    spritesheet = "__base__/graphics/terrain/water-transitions/concrete.png",
    layout = tile_spritesheet_layout.transition_8_8_8_4_4,
    background_enabled = false,
    effect_map_layout =
    {
      spritesheet = "__base__/graphics/terrain/effect-maps/water-stone-mask.png",
      inner_corner_count = 1,
      outer_corner_count = 1,
      side_count = 1,
      u_transition_count = 1,
      o_transition_count = 1
    }
  },
  concrete_to_out_of_map_transition
}

local concrete_transitions_between_transitions =
{
  {
    transition_group1 = default_transition_group_id,
    transition_group2 = water_transition_group_id,

    spritesheet = "__base__/graphics/terrain/water-transitions/concrete-transitions.png",
    layout = tile_spritesheet_layout.transition_3_3_3_1_0,
    background_enabled = false,
    effect_map_layout =
    {
      spritesheet = "__base__/graphics/terrain/effect-maps/water-stone-to-land-mask.png",
      o_transition_count = 0
    }
  },
  {
    transition_group1 = default_transition_group_id,
    transition_group2 = out_of_map_transition_group_id,

    background_layer_offset = 1,
    background_layer_group = "zero",
    offset_background_layer_by_tile_layer = true,

    spritesheet = "__base__/graphics/terrain/out-of-map-transition/concrete-out-of-map-transition-b.png",
    layout = tile_spritesheet_layout.transition_3_3_3_1_0,
  },
  {
    transition_group1 = water_transition_group_id,
    transition_group2 = out_of_map_transition_group_id,

    background_layer_offset = 1,
    background_layer_group = "zero",
    offset_background_layer_by_tile_layer = true,

    spritesheet = "__base__/graphics/terrain/out-of-map-transition/concrete-shore-out-of-map-transition.png",
    layout = tile_spritesheet_layout.transition_3_3_3_1_0,
    effect_map_layout =
    {
      spritesheet = "__base__/graphics/terrain/effect-maps/water-stone-to-out-of-map-mask.png",
      u_transition_count = 0,
      o_transition_count = 0
    }
  }
}

local function material_background(picture, count)
  return
  {
    transition = tile_graphics.generic_masked_tile_transitions1,
    material_background =
    {
      picture = picture,
      count = count,
      scale = 0.5
    }
  }
end
local item_sounds = require("__base__.prototypes.item_sounds")

data:extend({
  {
    type = "item-subgroup",
    name = "vesta-tiles",
    group = "tiles",
    order = "f"
  },
-- Vesta Foundation
	{
		type = "item",
		name = "vesta-foundation",
		icon = "__skewer_planet_vesta_assets__/graphics/icons/foundation.png",
--		subgroup = "vesta-items-artificial",
		subgroup = "terrain",
		order = "c[landfill]-e[vesta-foundation]",
		inventory_move_sound = item_sounds.metal_large_inventory_move,
		pick_sound = item_sounds.metal_large_inventory_pickup,
		drop_sound = item_sounds.metal_large_inventory_move,
		stack_size = 50,
		weight = 20*kg,
		place_as_tile =
		{
		  result = "vesta-foundation",
		  condition_size = 1,
		condition = {layers={ground_tile=true}},
		  tile_condition =
		  {
			"ammoniacal-ocean-vesta-yellow", "ammoniacal-ocean-vesta-pink", "ammoniacal-ocean-vesta-lime", "ammoniacal-ocean-vesta-red", "ammoniacal-ocean-vesta-tritium", "ammoniacal-ocean-vesta-deuterium",-- all gasous atmosphere
		  }
		}
	},
--  ammoniacal_ocean, (pinkish) Makes Helium
  {
    name = "ammoniacal-ocean-vesta-pink",
    type = "tile",
    order = "v[vesta]-a[he]",
    collision_mask = tile_collision_masks.ammoniacal_ocean(),
    subgroup = "vesta-tiles",
    fluid = get_gas_name("vesta_helium", "helium"),
    autoplace = {probability_expression = "vesta_ocean_1"},
    effect = "cloudy-vesta",
--    effect_color = {235, 186, 238},
	effect_color = gas_pink_effect_brighter,
    effect_color_secondary = gas_pink_effect,--{235, 186, 238},
    map_color = {250, 233, 248},
    particle_tints = tile_graphics.water_particle_tints,
    layer_group = "water",
    layer = 3,
        lowland_fog = fog_enabled,
    variants =
	{
		main =
		{
			{
			picture = "__skewer_planet_vesta_assets__/graphics/terrain/helium.png",
			count = 1,
			scale = 0.5,
			size = 1
			}
		},
      transition = tile_graphics.generic_masked_tile_transitions1
    },
    transitions = { water_to_out_of_map_transition },
    absorptions_per_second = tile_pollution.ice,
    trigger_effect = tile_trigger_effects.water_trigger_effect(),
    default_cover_tile = "vesta-foundation",
  },
--  ammoniacal_ocean (greenish), Makes Nitrogen
  {
    name = "ammoniacal-ocean-vesta-lime",
    type = "tile",
    order = "v[vesta]-b[ni]",
    collision_mask = tile_collision_masks.ammoniacal_ocean(),
    subgroup = "vesta-tiles",
    fluid = get_gas_name("vesta_nitrogen", "nitrogen"),
    autoplace = {probability_expression = "vesta_ocean_2"},
	effect = "cloudy-vesta",
--	effect_color = {197, 237, 232},
	effect_color = gas_green_effect_brighter,
    effect_color_secondary = gas_pink_effect,--{197, 237, 232},
    map_color = {233, 250, 248},
    particle_tints = tile_graphics.water_particle_tints,
    layer_group = "water",
    layer = 3,
        lowland_fog = fog_enabled,
    variants =
	{
		main =
		{
			{
			picture = "__skewer_planet_vesta_assets__/graphics/terrain/nitrogen.png",
			count = 1,
			scale = 0.5,
			size = 1
			}
		},
      transition = tile_graphics.generic_masked_tile_transitions1
    },
    transitions = { water_to_out_of_map_transition },
    absorptions_per_second = tile_pollution.ice,
    trigger_effect = tile_trigger_effects.water_trigger_effect(),
    default_cover_tile = "vesta-foundation",
  },
--  ammoniacal_ocean, (yellowish) Makes Carbon Dioxide
  {
    name = "ammoniacal-ocean-vesta-yellow",
    type = "tile",
    order = "v[vesta]-c[cd]",
    collision_mask = tile_collision_masks.ammoniacal_ocean(),
    subgroup = "vesta-tiles",
    fluid = get_gas_name("vesta_carbon_dioxide", "carbon-dioxide"),
    autoplace = {probability_expression = "vesta_starting_foundation_2"},
    effect = "cloudy-vesta",
--    effect_color = {235, 186, 238},
	effect_color = gas_yellow_effect_brighter,
    effect_color_secondary = gas_pink_effect,--{235, 186, 238},
    map_color = gas_yellow_effect,
    particle_tints = tile_graphics.water_particle_tints,
    layer_group = "water",
    layer = 3,
        lowland_fog = fog_enabled,
    variants =
	{
		main =
		{
			{
			picture = "__skewer_planet_vesta_assets__/graphics/terrain/carbon_dioxide.png",
			count = 1,
			scale = 0.5,
			size = 1
			}
		},
      transition = tile_graphics.generic_masked_tile_transitions1
    },
    transitions = { water_to_out_of_map_transition },
    absorptions_per_second = tile_pollution.ice,
    trigger_effect = tile_trigger_effects.water_trigger_effect(),
    default_cover_tile = "vesta-foundation",
  },
--  ammoniacal_ocean, (redish) Makes Hydrogen
  {
    name = "ammoniacal-ocean-vesta-red",
    type = "tile",
    order = "v[vesta]-d[hy]",
    collision_mask = tile_collision_masks.ammoniacal_ocean(),
    subgroup = "vesta-tiles",
    fluid = get_gas_name("vesta_hydrogen", "hydrogen"),
    autoplace = {probability_expression = "vesta_starting_foundation_3"},
    effect = "cloudy-vesta",
--    effect_color = {235, 186, 238},
	effect_color = gas_red_effect_brighter,
    effect_color_secondary = gas_pink_effect,--{235, 186, 238},
    map_color = {233, 169, 174},
    particle_tints = tile_graphics.water_particle_tints,
    layer_group = "water",
    layer = 3,
        lowland_fog = fog_enabled,
    variants =
	{
		main =
		{
			{
			picture = "__skewer_planet_vesta_assets__/graphics/terrain/hydrogen.png",
			count = 1,
			scale = 0.5,
			size = 1
			}
		},
      transition = tile_graphics.generic_masked_tile_transitions1
    },
    transitions = { water_to_out_of_map_transition },
    absorptions_per_second = tile_pollution.ice,
    trigger_effect = tile_trigger_effects.water_trigger_effect(),
    default_cover_tile = "vesta-foundation",
  },
  
 
--  ammoniacal_ocean, (cyanish) Makes Tritium
-- Originally Tritium, now methane to encourage the production chain of Tritium.
  {
    name = "ammoniacal-ocean-vesta-tritium",
    type = "tile",
    order = "v[vesta]-e[me]",
    collision_mask = tile_collision_masks.ammoniacal_ocean(),
    subgroup = "vesta-tiles",
--	fluid = "tritium",
    fluid = get_gas_name("vesta_methane", "methane"),
    autoplace = {probability_expression = "vesta_tritium_spots"},
    effect = "cloudy-vesta",
--    effect_color = {235, 186, 238},
-- Tritium cloud color
--	effect_color = {154, 245, 245},
-- Methane blue color
	effect_color = {131, 110, 189},
    effect_color_secondary = gas_pink_effect,--{235, 186, 238},
    map_color = {131, 110, 189},
    particle_tints = tile_graphics.water_particle_tints,
    layer_group = "water",
    layer = 3,
	lowland_fog = fog_enabled,
    variants =
	{
		main =
		{
			{
			picture = "__skewer_planet_vesta_assets__/graphics/terrain/methane.png",
			count = 1,
			scale = 0.5,
			size = 1
			}
		},
      transition = tile_graphics.generic_masked_tile_transitions1
    },
    transitions = { water_to_out_of_map_transition },
    absorptions_per_second = tile_pollution.ice,
    trigger_effect = tile_trigger_effects.water_trigger_effect(),
    default_cover_tile = "vesta-foundation",
  },

--  ammoniacal_ocean, (very red) Makes Deuterium
-- Originally made Deuterium, now makes Hydrogen Sulfide
  {
    name = "ammoniacal-ocean-vesta-deuterium",
    type = "tile",
    order = "v[vesta]-f[hs]",
    collision_mask = tile_collision_masks.ammoniacal_ocean(),
    subgroup = "vesta-tiles",
 --	fluid = "deuterium",
    fluid = get_gas_name("vesta_hydrogen_sulfide", "hydrogen-sulfide"),
    autoplace = {probability_expression = "vesta_deuterium_spots"},
    effect = "cloudy-vesta",
--    effect_color = {235, 186, 238},
--	effect_color = {255, 45, 45},
-- Hydrogen sulfide
	effect_color = {202, 196, 59},
    effect_color_secondary = gas_pink_effect,--{235, 186, 238},
    map_color = {202, 196, 59},
    particle_tints = tile_graphics.water_particle_tints,
    layer_group = "water",
    layer = 3,
	lowland_fog = fog_enabled,
    variants =
	{
		main =
		{
			{
			picture = "__skewer_planet_vesta_assets__/graphics/terrain/hydrogen_sulfide.png",
			count = 1,
			scale = 0.5,
			size = 1
			}
		},
      transition = tile_graphics.generic_masked_tile_transitions1
    },
    transitions = { water_to_out_of_map_transition },
    absorptions_per_second = tile_pollution.ice,
    trigger_effect = tile_trigger_effects.water_trigger_effect(),
    default_cover_tile = "vesta-foundation",
  },
 
--==============
--=== Tile Effect ===
--==============
  {
    type = "tile-effect",
    name = "brash-ice-2-vesta",
    shader = "water",
    water = {
      shader_variation = "wetland-water",
      textures =
      {
        {
          filename = "__space-age__/graphics/terrain/gleba/watercaustics.png",
          width = 512,
          height = 512
        },
        {
          filename = "__skewer_planet_vesta_assets__/graphics/terrain/vesta/nitrogen-crystal.png",
          width = 512 * 4,
          height = 512 * 2
        }
      },
      texture_variations_columns = 1,
      texture_variations_rows = 1,
      secondary_texture_variations_columns = 4,
      secondary_texture_variations_rows = 2,


      animation_speed = 0.8,
      animation_scale = { 0.40, 0.68 },
      tick_scale = 6,

      specular_lightness = { 4, 10, 1 },
      foam_color = { 8, 2, 2 },
      foam_color_multiplier = 1,

      dark_threshold = { 0.0, 0.2 },
      reflection_threshold = { 3, 2 },
      specular_threshold = { 0.0, 0.0 },

      near_zoom = 1 / 16,
      far_zoom = 1 / 16,
    }
  }, 
  
  
--==============
--==============
--==============
--=== Land Tiles ===
--==============
--==============
--==============
-- Fill tile
  {
    type = "tile",
    name = "vesta-foundation",
    order = "a[artificial]-v",
    subgroup = "artificial-tiles",
    autoplace = {probability_expression = "vesta_starting_foundation"},
    needs_correction = false,
    minable = {mining_time = 0.5, result = "vesta-foundation"},
    mined_sound = base_sounds.deconstruct_bricks(0.8),
    is_foundation = true,
    collision_mask = tile_collision_masks.ground(),
    layer = 9+1,
    layer_group = "ground-artificial",
    transition_overlay_layer_offset = 2, -- need to render border overlay on top of hazard-concrete
    decorative_removal_probability = 0.25,
    variants =
    {
      main =
      {
        {
          picture = "__space-age__/graphics/terrain/foundation/foundation-dummy.png",
          count = 1,
          size = 1
        },
        {
          picture = "__space-age__/graphics/terrain/foundation/foundation-dummy.png",
          count = 1,
          size = 2,
          probability = 0.39
        },
        {
          picture = "__space-age__/graphics/terrain/foundation/foundation-dummy.png",
          count = 1,
          size = 4,
          probability = 1
        }
      },
      transition =
      {
        overlay_layout =
        {
          inner_corner =
          {
            spritesheet = "__space-age__/graphics/terrain/foundation/foundation-inner-corner.png",
            count = 16,
            scale = 0.5
          },
          outer_corner =
          {
            spritesheet = "__space-age__/graphics/terrain/foundation/foundation-outer-corner.png",
            count = 8,
            scale = 0.5
          },
          side =
          {
            spritesheet = "__space-age__/graphics/terrain/foundation/foundation-side.png",
            count = 16,
            scale = 0.5
          },
          u_transition =
          {
            spritesheet = "__space-age__/graphics/terrain/foundation/foundation-u.png",
            count = 8,
            scale = 0.5
          },
          o_transition =
          {
            spritesheet = "__space-age__/graphics/terrain/foundation/foundation-o.png",
            count = 4,
            scale = 0.5
          }
        },
        mask_layout =
        {
          inner_corner =
          {
            spritesheet = "__space-age__/graphics/terrain/foundation/foundation-inner-corner-mask.png",
            count = 16,
            scale = 0.5
          },
          outer_corner =
          {
            spritesheet = "__space-age__/graphics/terrain/foundation/foundation-outer-corner-mask.png",
            count = 8,
            scale = 0.5
          },
          side =
          {
            spritesheet = "__space-age__/graphics/terrain/foundation/foundation-side-mask.png",
            count = 16,
            scale = 0.5
          },
          u_transition =
          {
            spritesheet = "__space-age__/graphics/terrain/foundation/foundation-u-mask.png",
            count = 8,
            scale = 0.5
          },
          o_transition =
          {
            spritesheet = "__space-age__/graphics/terrain/foundation/foundation-o-mask.png",
            count = 4,
            scale = 0.5
          }
        }
      },

      material_background =
      {
        picture = "__skewer_planet_vesta_assets__/graphics/terrain/vesta/foundation.png",
        count = 8,
        scale = 0.5
      }
    },

    transitions = foundation_transitions,
    transitions_between_transitions = foundation_transitions_between_transitions,

    walking_sound = base_tile_sounds.walking.dirt,
    build_sound = base_tile_sounds.building.concrete,
    map_color={57, 39, 26},
    scorch_mark_color = {r = 0.329, g = 0.242, b = 0.177, a = 1.000},
    vehicle_friction_modifier = 1.1,

    trigger_effect = tile_trigger_effects.concrete_trigger_effect()
  },
})

local function frozen_concrete(base_name, item_name, transition_merge_tile)
  local frozen_name = "frozen-" .. base_name
  local base_prototype = data.raw.tile[base_name]
  base_prototype.frozen_variant = frozen_name
  local frozen_concrete = table.deepcopy(base_prototype)
  frozen_concrete.order = "z[frozen-concrete]-" .. frozen_name
  frozen_concrete.subgroup = "aquilo-tiles"
  frozen_concrete.name = frozen_name
  frozen_concrete.can_be_part_of_blueprint = true
  frozen_concrete.placeable_by = { item = item_name, count = 1}
  frozen_concrete.layer = base_prototype.layer + 1
  frozen_concrete.sprite_usage_surface = "aquilo"
  frozen_concrete.variants =
  {
    material_background =
    {
      picture = "__space-age__/graphics/terrain/aquilo/"..frozen_name..".png",
      count = 8,
      scale = 0.5
    },
    transition = tile_graphics.generic_texture_on_concrete_transition
  }
  frozen_concrete.transition_merges_with_tile = transition_merge_tile
  frozen_concrete.transitions = nil
  frozen_concrete.transitions_between_transitions = nil
  frozen_concrete.thawed_variant = base_name
  frozen_concrete.frozen_variant = nil
  frozen_concrete.walking_sound = tile_sounds.walking.frozen_concrete
  data:extend({ frozen_concrete })
end

frozen_concrete("stone-path", "stone-brick", "stone-path")
frozen_concrete("concrete", "concrete", "concrete")
frozen_concrete("hazard-concrete-left", "hazard-concrete", "concrete")
frozen_concrete("hazard-concrete-right", "hazard-concrete", "concrete")
frozen_concrete("refined-concrete", "refined-concrete", "refined-concrete")
frozen_concrete("refined-hazard-concrete-left", "refined-hazard-concrete", "refined-concrete")
frozen_concrete("refined-hazard-concrete-right", "refined-hazard-concrete", "refined-concrete")

data:extend(
{
  {
    type = "tile-effect",
    name = "cloudy-vesta",
    shader = "water",
    water =
    {
      textures =
      {{
        filename = "__skewer_planet_vesta_assets__/graphics/terrain/vesta/water-noise.png",
        width = 960,
        height = 960
      }},
      specular_lightness = { 0.15, 0.15, 0.15 },
      foam_color = nitrogen_crystal_effect,
      foam_color_multiplier = 1.0,

      animation_speed = 0.15,
      animation_scale = { 0.006, 0.006 },

      dark_threshold = { 0.707, 0.789 },
      reflection_threshold = { 0.05, 0.05 },
      specular_threshold = { 0.15, 0.12 },
      tick_scale = 0.15,

      near_zoom = 2
    }
  }
})
