local assets=
{ 
    Asset("ANIM", "anim/hat_four_bw.zip"),
    Asset("ANIM", "anim/hat_four_bw_swap.zip"), 

    Asset("ATLAS", "images/inventoryimages/hat_four_bw.xml"),
    Asset("IMAGE", "images/inventoryimages/hat_four_bw.tex"),
}

local prefabs = 
{
}
        --prefabs = {"forcefieldfx"}
 
    --local function hat_four_bw_proc(inst, owner)
        --inst:AddTag("forcefield")
        --inst.components.armor:SetAbsorption(TUNING.FULL_ABSORPTION)
        --local fx = SpawnPrefab("forcefieldfx")
        --fx.entity:SetParent(owner.entity)
        --fx.Transform:SetPosition(0, 0.2, 0)
        --local fx_hitanim = function()
            --fx.AnimState:PlayAnimation("hit")
            --fx.AnimState:PushAnimation("idle_loop")
        --end
        --fx:ListenForEvent("blocked", fx_hitanim, owner)

        --inst.components.armor.ontakedamage = function(inst, damage_amount)
            --if owner then
                --local sanity = owner.components.sanity
                --if sanity then
                    --local unsaneness = damage_amount * TUNING.ARMOR_HAT_FOUR_BW_DMG_AS_SANITY
                    --sanity:DoDelta(-unsaneness, false)
                --end
            --end
        --end

        --inst.active = true

        --owner:DoTaskInTime(--[[Duration]] TUNING.ARMOR_HAT_FOUR_BW_DURATION, function()
            --fx:RemoveEventCallback("blocked", fx_hitanim, owner)
            --fx.kill_fx(fx)
            --if inst:IsValid() then
                --inst:RemoveTag("forcefield")
                --inst.components.armor.ontakedamage = nil
                --inst.components.armor:SetAbsorption(TUNING.ARMOR_HAT_FOUR_BW_ABSORPTION)
                --owner:DoTaskInTime(--[[Cooldown]] TUNING.ARMOR_HAT_FOUR_BW_COOLDOWN, function() inst.active = false end)
            --end
        --end)
    --end

    --local function tryproc(inst, owner)
        --if not inst.active and math.random() < --[[ Chance to proc ]] TUNING.ARMOR_HAT_FOUR_BW_PROC_CHANCE then
          --hat_four_bw_proc(inst, owner)
        --end
    --end 

local function fn()

    local function OnEquip(inst, owner) 
        owner.AnimState:OverrideSymbol("swap_hat", "hat_four_bw_swap", "swap_hat")
        owner.AnimState:Show("HAT")
        owner.AnimState:Show("HAT_HAIR")
        owner.AnimState:Hide("HAIR_NOHAT")
        owner.AnimState:Hide("HAIR")
        print('A')
        if owner:HasTag("player") then
            print('B')
            owner.AnimState:Hide("HEAD")
            owner.AnimState:Show("HEAD_HAIR")
        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")

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

    local inst = CreateEntity()
    local trans = inst.entity:AddTransform()
    local anim = inst.entity:AddAnimState()
    MakeInventoryPhysics(inst)
    
    anim:SetBank("hat_four")
    anim:SetBuild("hat_four_bw")
    anim:PlayAnimation("idle")

    inst:AddComponent("inventoryitem")
    inst.components.inventoryitem.imagename = "hat_four_bw"
    inst.components.inventoryitem.atlasname = "images/inventoryimages/hat_four_bw.xml"
    
    inst:AddComponent("equippable")
    inst.components.equippable.equipslot = EQUIPSLOTS.HEAD
    --inst.components.armor:InitCondition(TUNING.ARMOR_HAT_FOUR_BW, TUNING.ARMOR_HAT_FOUR_BW_ABSORPTION)
    inst.components.equippable:SetOnEquip(OnEquip)
    inst.components.equippable:SetOnUnequip(OnUnequip)

    inst:AddComponent("dapperness")
    inst.components.dapperness.dapperness = TUNING.DAPPERNESS_TINY

    inst:AddComponent("insulator")
    inst.components.insulator.insulation = TUNING.INSULATION_MED 

    return inst
end

return  Prefab("common/inventory/hat_four_bw", fn, assets, prefabs)