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

local function onequip(inst, owner)
    owner.AnimState:OverrideSymbol("swap_hat", "hat_xiang", "swap_hat")

    owner.AnimState:Show("HAT")
    owner.AnimState:Show("HAT_HAIR")
    owner.AnimState:Hide("HAIR_NOHAT")
    owner.AnimState:Hide("HAIR")
            if GetClock():IsNight() then
				owner.Light:Enable(true)
				owner.Light:SetRadius(18)
    			owner.Light:SetFalloff(1)
    			owner.Light:SetIntensity(0.5)
    			owner.Light:SetColour(128/255,128/255,255/255)
    		end
	
	
end

local function onunequip(inst, owner)
    owner.AnimState:Hide("HAT")
    owner.AnimState:Hide("HAT_HAIR")
    owner.AnimState:Show("HAIR_NOHAT")
    owner.AnimState:Show("HAIR")
            owner.Light:Enable(false)
end













local function fn()
    local inst = CreateEntity()

    inst.entity:AddTransform()
    inst.entity:AddAnimState()
    MakeInventoryPhysics(inst)

    inst.AnimState:SetBank("baosuiya")
    inst.AnimState:SetBuild("baosuiya")
    inst.AnimState:PlayAnimation("idle")

    inst:AddComponent("inspectable")

    inst:AddComponent("inventoryitem")
	inst.components.inventoryitem.imagename = "hat_xiang"
    inst.components.inventoryitem.atlasname = "images/inventoryimages/hat_xiang.xml"
--[[	
inst:AddComponent("tool")
	inst.components.tool:SetAction(ACTIONS.CHOP, 3)
        inst.components.tool:SetAction(ACTIONS.MINE, 2)
]]		
    inst:AddComponent("equippable")
	inst.components.equippable.equipslot = EQUIPSLOTS.HEAD
    inst.components.equippable:SetOnEquip(onequip)
    inst.components.equippable:SetOnUnequip(onunequip)
	inst.components.equippable.dapperness = 20/60

    --夜视
    inst:AddTag("nightvision")

    return inst
end

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