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






local function onequip(inst, owner)
--头
    owner.AnimState:OverrideSymbol("swap_hat", "bcapeup", "swap_hat")

    owner.AnimState:Show("HAT")
    owner.AnimState:Show("HAT_HAIR")
    owner.AnimState:Hide("HAIR_NOHAT")
    owner.AnimState:Hide("HAIR")

--身体
    owner.AnimState:OverrideSymbol("swap_body", "swap_bcape", "backpack")
    owner.AnimState:OverrideSymbol("swap_body", "swap_bcape", "swap_body")
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.AnimState:ClearOverrideSymbol("swap_body")
    owner.AnimState:ClearOverrideSymbol("bcape")
end

local function fn()
    local inst = CreateEntity()

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

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

    --inst.foleysound = "dontstarve/movement/foley/backpack"
    inst:AddComponent("inspectable")

    inst:AddComponent("inventoryitem")
    --inst.components.inventoryitem.cangoincontainer = true
	inst.components.inventoryitem.imagename = "bcape"
    inst.components.inventoryitem.atlasname = "images/inventoryimages/bcape.xml"
	--inst.components.inventoryitem.keepondeath = true
	--夜视
	--inst:AddTag("nightvision")
	
	inst:AddComponent("insulator")
    inst.components.insulator.insulation = 480
	
	inst:AddComponent("waterproofer")
    inst.components.waterproofer:SetEffectiveness(TUNING.WATERPROOFNESS_SMALL)	
	
    inst:AddComponent("equippable")
    inst.components.equippable.equipslot = EQUIPSLOTS.BODY

    inst.components.equippable:SetOnEquip(onequip)
    inst.components.equippable:SetOnUnequip(onunequip)


    return inst
end

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