local assets =
{
	Asset("ANIM", "anim/hornucopia.zip"),
	Asset("ATLAS", "images/inventoryimages/hornucopia.xml"),
	Asset("IMAGE", "images/inventoryimages/hornucopia.tex"),
}

local function onfinished(inst)
	local fin = SpawnPrefab("minotaurhorn")
		fin.Transform:SetPosition(inst.Transform:GetWorldPosition())
    inst:Remove()
end

local function HearPanFlute(inst, musician, instrument, data)
    if musician.components.health then
		musician.components.health:DoDelta(2)
		musician.components.hunger:DoDelta(2)
		musician.components.sanity:DoDelta(2)
	end
end

local function fn(Sim)
	local inst = CreateEntity()
	inst.entity:AddTransform()
	inst.entity:AddAnimState()
	inst.entity:AddNetwork()
	MakeInventoryPhysics(inst)
	--[[
	if IsDLCEnabled(CAPY_DLC) then
		MakeInventoryFloatable(inst, "idle_water", "idle")
    end
    ]]
	inst.AnimState:SetBank("hornucopia")
    inst.AnimState:SetBuild("hornucopia")
    inst.AnimState:PlayAnimation("anim")

		inst.entity:SetPristine()

	    if not TheWorld.ismastersim then
	        return inst
	    end

	inst:AddTag("horn")

	inst:AddComponent("inspectable")
    inst:AddComponent("instrument")
    inst.components.instrument.range = TUNING.PANFLUTE_SLEEPRANGE
    inst.components.instrument:SetOnHeardFn(HearPanFlute)

	inst:AddComponent("tool")
    inst.components.tool:SetAction(ACTIONS.PLAY)

	inst:AddComponent("finiteuses")
    inst.components.finiteuses:SetMaxUses(TUNING.PANFLUTE_USES*.5)
    inst.components.finiteuses:SetUses(TUNING.PANFLUTE_USES*.5)
    inst.components.finiteuses:SetOnFinished( onfinished )
	inst.components.finiteuses:SetConsumption(ACTIONS.PLAY, 1)

	inst.entity:AddMiniMapEntity()
	inst.MiniMapEntity:SetIcon("hornucopia.tex")

    inst:AddComponent("inventoryitem")
	--inst.components.inventoryitem.imagename = "hornucopia"
	inst.components.inventoryitem.atlasname = "images/inventoryimages/hornucopia.xml"

    return inst
end

STRINGS.NAMES.HORNUCOPIA 								= "Hornucopia"
STRINGS.RECIPE_DESC.HORNUCOPIA 							= "Horn of plenty."

STRINGS.CHARACTERS.GENERIC.DESCRIBE.HORNUCOPIA 			= "A feast fit for a king!"
STRINGS.CHARACTERS.WILLOW.DESCRIBE.HORNUCOPIA 			= "The smell is otherworldly!"
STRINGS.CHARACTERS.WOLFGANG.DESCRIBE.HORNUCOPIA 		= "Is... beautiful!"
STRINGS.CHARACTERS.WENDY.DESCRIBE.HORNUCOPIA 			= "Nothing lasts forever."
STRINGS.CHARACTERS.WX78.DESCRIBE.HORNUCOPIA 			= "PORTABLE ENERGY SOURCE"
STRINGS.CHARACTERS.WICKERBOTTOM.DESCRIBE.HORNUCOPIA 	= "A symbol of abundance and nourishment."
STRINGS.CHARACTERS.WOODIE.DESCRIBE.HORNUCOPIA 			= "I don't know if I should eat from that."
STRINGS.CHARACTERS.WAXWELL.DESCRIBE.HORNUCOPIA 			= "Its contents escape time."
STRINGS.CHARACTERS.WATHGRITHR.DESCRIBE.HORNUCOPIA 	= "Fööd fröm the göds!"
STRINGS.CHARACTERS.WEBBER.DESCRIBE.HORNUCOPIA 		= "I can hear a fiesta inside!"

--if IsDLCEnabled(CAPY_DLC) then
	--STRINGS.CHARACTERS.WOODLEGS.DESCRIBE.HORNUCOPIA		= "A feast o' a true pirate!"
	--STRINGS.CHARACTERS.WALANI.DESCRIBE.HORNUCOPIA		= "Its like a restaurant in my pocket."
	--STRINGS.CHARACTERS.WARLY.DESCRIBE.HORNUCOPIA		= "A true masterpiece."
--end

return Prefab( "common/inventory/hornucopia", fn, assets)
