--[[ Copyright (c) 2017 Optera
 * Part of Loader Redux
 *
 * See LICENSE.md in the project directory for license information.
--]]

function make_loader_entity(name, belt,multiplier)
  local loader = data.raw["loader"][name] or optera_lib.copy_prototype(data.raw["loader"]["loader"], name)
  loader.flags = {"placeable-neutral", "placeable-player", "player-creation", "fast-replaceable-no-build-while-moving"}
  loader.icon = "__FasterLoaders__/graphics/icon/"..name..".png"
  loader.icon_size = 32
  loader.icon_mipmaps = nil

  loader.structure.direction_in.sheet = {
    filename="__FasterLoaders__/graphics/entity/"..name..".png",
    priority = "extra-high",
    width = 128,
    height = 128,
    hr_version = {
      filename="__FasterLoaders__/graphics/entity/hr-"..name..".png",
      priority = "extra-high",
      width = 256,
      height = 256,
      scale = 0.5,
    }
  }
  loader.structure.direction_out.sheet ={
    filename="__FasterLoaders__/graphics/entity/"..name..".png",
    priority = "extra-high",
    width = 128,
    height = 128,
    y = 128,
    hr_version = {
      filename="__FasterLoaders__/graphics/entity/hr-"..name..".png",
      priority = "extra-high",
      width = 256,
      height = 256,
      y = 256,
      scale = 0.5,
    }
  }
  loader.speed = belt.speed*multiplier

  -- 0.17 animations
  loader.belt_animation_set = belt.belt_animation_set
  loader.structure_render_layer = "object"

  return loader
end


data:extend({
  make_loader_entity("yellow-loader", data.raw["transport-belt"]["express-transport-belt"],2),
  make_loader_entity("red-loader", data.raw["transport-belt"]["express-transport-belt"],4),
  make_loader_entity("purple-loader", data.raw["transport-belt"]["express-transport-belt"],8),
  make_loader_entity("blue-loader", data.raw["transport-belt"]["express-transport-belt"],16),
  make_loader_entity("green-loader", data.raw["transport-belt"]["express-transport-belt"],32),
  make_loader_entity("black-loader", data.raw["transport-belt"]["express-transport-belt"],64),
  make_loader_entity("grey-loader", data.raw["transport-belt"]["express-transport-belt"],128),
  make_loader_entity("white-loader", data.raw["transport-belt"]["express-transport-belt"],256),
})
data.raw["loader"]["yellow-loader"].next_upgrade = "red-loader"
data.raw["loader"]["red-loader"].next_upgrade = "purple-loader"
data.raw["loader"]["purple-loader"].next_upgrade = "blue-loader"
data.raw["loader"]["blue-loader"].next_upgrade = "green-loader"
data.raw["loader"]["green-loader"].next_upgrade = "black-loader"
data.raw["loader"]["black-loader"].next_upgrade = "grey-loader"
data.raw["loader"]["grey-loader"].next_upgrade = "white-loader"
data.raw["loader"]["white-loader"].next_upgrade = nil

