require ("sound-util")
require ("circuit-connector-sprites")
require ("util")
require ("__space-age__.prototypes.entity.circuit-network")
require ("__space-age__.prototypes.entity.space-platform-hub-cockpit")
local item_sounds = require("__base__.prototypes.item_sounds")
local item_tints = require("__base__.prototypes.item-tints")
local hit_effects = require("__base__.prototypes.entity.hit-effects")
local sounds = require("__base__.prototypes.entity.sounds")
local space_age_sounds = require ("__space-age__.prototypes.entity.sounds")
local meld = require("meld")
local simulations = require("__space-age__.prototypes.factoriopedia-simulations")

local entity_shift = util.by_pixel(0, 114)
data:extend({
  {
    type = "projectile",
    name = "fusion-missile",
    flags = {"not-on-map"},
    hidden = true,
    acceleration = 0.06,
    turn_speed = 0.01,
    turning_speed_increases_exponentially_with_projectile_speed = true,
    action =
    {
      type = "direct",
      action_delivery =
      {
        type = "instant",
        target_effects =
        {
          {
            type = "create-entity",
            entity_name = "big-explosion",
            only_when_visible = true
          },
          {
            type = "damage",
            damage = {amount = 400, type = "explosion"}
          },
          {
            type = "create-entity",
            entity_name = "medium-scorchmark-tintable",
            check_buildability = true
          },
          {
            type = "invoke-tile-trigger",
            repeat_count = 1
          },
          {
            type = "destroy-decoratives",
            from_render_layer = "decorative",
            to_render_layer = "object",
            include_soft_decoratives = true, -- soft decoratives are decoratives with grows_through_rail_path = true
            include_decals = false,
            invoke_decorative_trigger = true,
            decoratives_with_trigger_only = false, -- if true, destroys only decoratives that have trigger_effect set
            radius = 5 -- large radius for demostrative purposes
          },
          {
            type = "nested-result",
            action =
            {
              type = "area",
              radius = 7.5,
              action_delivery =
              {
                type = "instant",
                target_effects =
                {
                  {
                    type = "damage",
                    damage = {amount = 300, type = "explosion"}
                  },
                  {
                    type = "create-entity",
                    entity_name = "explosion",
                    only_when_visible = true
                  }
                }
              }
            }
          }
        }
      }
    },
    animation = require("__skewer_planet_vesta__.prototypes.entity.rocket-projectile-pictures").animation({1, 0.2, 0.2}),
    shadow = require("__skewer_planet_vesta__.prototypes.entity.rocket-projectile-pictures").shadow,
    smoke = require("__skewer_planet_vesta__.prototypes.entity.rocket-projectile-pictures").smoke,
  },
  {
    type = "ammo",
    name = "fusion-missile",
	icon="__skewer_planet_vesta__/graphics/icons/fusion-missile.png",
    ammo_category = "rocket",
    ammo_type =
    {
      action =
      {
        type = "direct",
        action_delivery =
        {
          type = "projectile",
          projectile = "fusion-missile",
          starting_speed = 0.1,
          source_effects =
          {
            type = "create-entity",
            entity_name = "explosion-hit",
            only_when_visible = true
          }
        }
      }
    },
    subgroup = "ammo",
	order = "d[rocket-launcher]-c[fusion-missile]",
    inventory_move_sound = item_sounds.ammo_large_inventory_move,
    pick_sound = item_sounds.ammo_large_inventory_pickup,
    drop_sound = item_sounds.ammo_large_inventory_move,
    stack_size = 100,
    weight = 40*kg
  },
--Recipe
	{
		type = "recipe",
		name = "fusion-missile",
		category = "cryogenics",
		group = "combat",
		subgroup = "ammo",
		order = "d[rocket-launcher]-c[fusion-missile]",
		icon_size = 64,
		icon="__skewer_planet_vesta__/graphics/icons/fusion-missile.png",
		enabled = false,
		energy_required = 1,
		ingredients =
		{
			{type = "fluid", name = "fusion-plasma", amount = 1},
			{type = "item", name = "steel-plate", amount = 2},
			{type = "item", name = "copper-cable", amount = 10},
		},
		results = 
		{
			{type = "item", name = "fusion-missile", amount=5},
			{type = "fluid", name = "fluoroketone-hot", amount = 1, ignored_by_stats = 1, ignored_by_productivity = 999},
--			{type = "fluid", name = "fusion-plasma", amount = 1, ignored_by_stats = 1, ignored_by_productivity = 1},
		},
		allow_productivity = true,
		auto_recycle= false,
		crafting_machine_tint =
		{
		  primary = {r = 0.85, g = 0.16, b = 0.77, a = 1.000}, -- #fff400ff
		  secondary = {r = 1, g = 0.15, b = 0.16, a = 1.000}, -- #ffd92bff
		  tertiary = {r = 1.0, g = 0.4, b = 0.48, a = 1.000}, -- #dfdd98ff
		  quaternary = {r = 0.7, g = 0.75, b = 1, a = 1.000}, -- #dfdd98ff
		}
	},
})