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


local function onequiphat(inst, owner)
    owner.AnimState:OverrideSymbol("swap_hat", "venus_flowerglass", "swap_glass")
		owner.AnimState:Show("HAT")
		owner.AnimState:Show("HAT_HAIR")
		owner.AnimState:Hide("HAIR_NOHAT")
		owner.AnimState:Hide("HAIR")
		
		if owner:HasTag("player") then
			owner.AnimState:Hide("HEAD")
			owner.AnimState:Show("HEAD_HAIR")
		end
		
		if inst.components.fueled then
			inst.components.fueled:StartConsuming()        
		end

end

local function onunequiphat(inst, owner)
		owner.AnimState:Hide("HAT")
		owner.AnimState:Hide("HAT_HAIR")
		owner.AnimState:Show("HAIR_NOHAT")
		owner.AnimState:Show("HAIR")

		if owner:HasTag("player") then
			owner.AnimState:Show("HEAD")
			owner.AnimState:Hide("HEAD_HAIR")
		end
end

local function opentop_onequip(inst, owner)
        owner.AnimState:OverrideSymbol("swap_hat", "venus_flowerglass", "swap_glass")
		owner.AnimState:Show("HAT")
		owner.AnimState:Hide("HAT_HAIR")
		owner.AnimState:Show("HAIR_NOHAT")
		owner.AnimState:Show("HAIR")
		
		owner.AnimState:Show("HEAD")
		owner.AnimState:Hide("HEAD_HAIR")
end

local function finished(inst)
        inst:Remove()		
end

local function fn(Sim)
	local inst = CreateEntity()
	local trans = inst.entity:AddTransform()
	local anim = inst.entity:AddAnimState()
    local sound = inst.entity:AddSoundEmitter()
    MakeInventoryPhysics(inst)

    anim:SetBank("venus_flowerglass")
    anim:SetBuild("venus_flowerglass")
    anim:PlayAnimation("anim")
    
	inst:AddTag("hat")
	inst:AddTag("hide")
    inst:AddTag("trinket")
	inst:AddComponent("inspectable")
	

    inst:AddComponent("tradable")
	inst.components.tradable.goldvalue =  59
    if SaveGameIndex:IsModeShipwrecked() then
	inst.components.tradable.dubloonvalue =  59
    end
    inst:AddComponent("inspectable")
		
    inst:AddComponent("inventoryitem")
	inst.components.inventoryitem.imagename = "venus_flowerglass"
    inst.components.inventoryitem.atlasname = "images/inventoryimages/venus_flowerglass.xml"
  
	inst:AddComponent("equippable")
	inst.components.equippable.equipslot = EQUIPSLOTS.HEAD
	inst.components.equippable:SetOnEquip( onequiphat )
    inst.components.equippable:SetOnUnequip( onunequiphat )
    inst.components.equippable:SetOnEquip(opentop_onequip)
	inst.components.equippable.dapperness = TUNING.DAPPERNESS_LARGE
    return inst
end 
    
return Prefab( "common/inventory/venus_frogglass", fn, assets) 