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

--local params = {}
--local containers = require "containers"
--local prev_widgetsetup=containers.widgetsetup

--[[local function mywidgetsetup(container, prefab, data)
    local t = data or params[prefab or container.inst.prefab]
    if t ~= nil then
        for k, v in pairs(t) do
            container[k] = v
        end
        container:SetNumSlots(container.widget.slotpos ~= nil and #container.widget.slotpos or 0)
    end
end]]

--------------------------------------------------------------------------
--[[ equip_pack ]]
--------------------------------------------------------------------------

--[[params.equip_pack =
{
    widget =
    {
        slotpos = {},
        animbank = "ui_piggyback_2x6",
        animbuild = "ui_piggyback_2x6",
        pos = Vector3(-5, -50, 0),
    },
    issidewidget = true,
    type = "pack",
}

for y = 0, 5 do
    table.insert(params.equip_pack.widget.slotpos, Vector3(-162, -75 * y + 170, 0))
    table.insert(params.equip_pack.widget.slotpos, Vector3(-162 + 75, -75 * y + 170, 0))
end]]

--------------------------------------------------------------------------

--------------------------------------------------------------------------

local function onequip(inst, owner)
    owner.AnimState:OverrideSymbol("swap_body", "swap_equip_pack", "backpack")
		owner.AnimState:OverrideSymbol("swap_body", "swap_equip_pack", "swap_body")
    inst.components.container:Open(owner)
end

local function onunequip(inst, owner)
    owner.AnimState:ClearOverrideSymbol("swap_body")
    owner.AnimState:ClearOverrideSymbol("backpack")
    inst.components.container:Close(owner)
end

local function itemtest(container, item, slot)
--	return item.components.equippable
    if item.components.equippable then
        return true
    end
end

local function fn()
	local inst = CreateEntity()

	inst.entity:AddTransform()
	inst.entity:AddAnimState()
	inst.entity:AddSoundEmitter()
    inst.entity:AddMiniMapEntity()
    inst.entity:AddNetwork()

    MakeInventoryPhysics(inst)

    inst.AnimState:SetBank("equip_pack")
    inst.AnimState:SetBuild("swap_equip_pack")
    inst.AnimState:PlayAnimation("anim")

	inst.MiniMapEntity:SetIcon("minimap_equip_pack.tex")

	inst:AddTag("backpack")
    inst:AddTag("fridge")
    inst:AddTag("nocool")
    inst:AddTag("waterproofer")

	inst.foleysound = "dontstarve/movement/foley/backpack"

	inst.entity:SetPristine()

    if not TheWorld.ismastersim then
        return inst
    end

    inst:AddComponent("inspectable")

    inst:AddComponent("inventoryitem")
	inst.components.inventoryitem.atlasname = "images/inventoryimages/equip_pack.xml"
    inst.components.inventoryitem.cangoincontainer = false

	inst:AddComponent("equippable")
	if EQUIPSLOTS["BACK"] then
		inst.components.equippable.equipslot = EQUIPSLOTS.BACK
	elseif EQUIPSLOTS["PACK"] then
		inst.components.equippable.equipslot = EQUIPSLOTS.PACK
	else
		inst.components.equippable.equipslot = EQUIPSLOTS.BODY
	end

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

    inst:AddComponent("waterproofer")
    inst.components.waterproofer:SetEffectiveness(0)

	inst:AddComponent("container")
	inst.components.container.itemtestfn = itemtest
	--containers.widgetsetup = mywidgetsetup
	inst.components.container:WidgetSetup("equip_pack")
	--containers.widgetsetup = prev_widgetsetup

    MakeHauntableLaunchAndDropFirstItem(inst)

    return inst
end

STRINGS.NAMES.EQUIP_PACK 								= "Equipment Pack"
STRINGS.RECIPE_DESC.EQUIP_PACK 							= "Holds equipment and equipment alone."

STRINGS.CHARACTERS.GENERIC.DESCRIBE.EQUIP_PACK  		= "It doesn't seem to accept anything else aside from equipment."
STRINGS.CHARACTERS.WILLOW.DESCRIBE.EQUIP_PACK  			= "It makes me feel like a girl scout again."
STRINGS.CHARACTERS.WOLFGANG.DESCRIBE.EQUIP_PACK 		= "Weight does not affect me!"
STRINGS.CHARACTERS.WENDY.DESCRIBE.EQUIP_PACK 			= "A box for trinkets."
STRINGS.CHARACTERS.WX78.DESCRIBE.EQUIP_PACK 			= "TOOL COMPARTMENT"
STRINGS.CHARACTERS.WICKERBOTTOM.DESCRIBE.EQUIP_PACK 	= "This box is built specifically for equipment."
STRINGS.CHARACTERS.WOODIE.DESCRIBE.EQUIP_PACK 			= "I feel like hiking."
STRINGS.CHARACTERS.WAXWELL.DESCRIBE.EQUIP_PACK 			= "A toolbox for my tools."
STRINGS.CHARACTERS.WATHGRITHR.DESCRIBE.EQUIP_PACK 		= "Keeps my weapons and armour ready for battle."
STRINGS.CHARACTERS.WEBBER.DESCRIBE.EQUIP_PACK			= "It's like a toy box!"

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