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

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

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

local function onopen(inst)
	inst.SoundEmitter:PlaySound("dontstarve/wilson/backpack_open", "open")
end

local function onclose(inst)
	inst.SoundEmitter:PlaySound("dontstarve/wilson/backpack_close", "open")
end

local function fn(Sim)
	local inst = CreateEntity()

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

    inst.AnimState:SetBank("wolfyback")
    inst.AnimState:SetBuild("wolfyback")
    inst.AnimState:PlayAnimation("anim")

		inst.MiniMapEntity:SetIcon("wolfyback.tex")
		inst.foleysound = "dontstarve/movement/foley/backpack"
		inst.entity:SetPristine()

	    if not TheWorld.ismastersim then
	        return inst
	    end

    inst:AddTag("backpack")
    inst:AddComponent("inspectable")

    inst:AddComponent("inventoryitem")
	inst.components.inventoryitem.atlasname = "images/inventoryimages/wolfyback.xml"
    inst.components.inventoryitem.cangoincontainer = false
    --inst.components.inventoryitem.foleysound = "dontstarve/movement/foley/backpack"

		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.walkspeedmult = 1.1

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

    inst:AddComponent("waterproofer")
    inst.components.waterproofer.effectiveness = 0

    inst:AddComponent("container")
		inst.components.container:WidgetSetup("wolfyback")
    --inst.components.container:SetNumSlots(#slotpos)
    --inst.components.container.widgetslotpos = slotpos
    --inst.components.container.widgetanimbank = "ui_piggyback_2x6"
    --inst.components.container.widgetanimbuild = "ui_piggyback_2x6"
    --inst.components.container.widgetpos = Vector3(-5,-90,0)
	--inst.components.container.side_widget = true
    --inst.components.container.type = "pack"

    inst.components.container.onopenfn = onopen
    inst.components.container.onclosefn = onclose
		MakeHauntableLaunchAndDropFirstItem(inst)
    return inst
end

STRINGS.NAMES.WOLFYBACK 								= "Houndback"
STRINGS.RECIPE_DESC.WOLFYBACK 							= "It's as if I am carrying nothing at all."

STRINGS.CHARACTERS.GENERIC.DESCRIBE.WOLFYBACK 			= "Looks itchy to carry."
STRINGS.CHARACTERS.WILLOW.DESCRIBE.WOLFYBACK 			= "Will the hounds think I am one of them now?"
STRINGS.CHARACTERS.WOLFGANG.DESCRIBE.WOLFYBACK 			= "Is smelly as hound."
STRINGS.CHARACTERS.WENDY.DESCRIBE.WOLFYBACK 			= "I feel one with the pack."
STRINGS.CHARACTERS.WX78.DESCRIBE.WOLFYBACK 				= "IT NOW SERVES ME"
STRINGS.CHARACTERS.WICKERBOTTOM.DESCRIBE.WOLFYBACK 		= "This backpack seems to increase my movement speed when worn."
STRINGS.CHARACTERS.WOODIE.DESCRIBE.WOLFYBACK 			= "Made from pure hound."
STRINGS.CHARACTERS.WAXWELL.DESCRIBE.WOLFYBACK 			= "Ironically, carrying it supports my movement."
STRINGS.CHARACTERS.WATHGRITHR.DESCRIBE.WOLFYBACK 	= "Fenrir can nöw guide me!"
STRINGS.CHARACTERS.WEBBER.DESCRIBE.WOLFYBACK 		= "Puppy now serves a better purpose."

--if IsDLCEnabled(CAPY_DLC) then
	--STRINGS.CHARACTERS.WOODLEGS.DESCRIBE.WOLFYBACK		= "Me treasure feels like it be guarded by hounds."
	--STRINGS.CHARACTERS.WALANI.DESCRIBE.WOLFYBACK		= "Kinda cute."
	--STRINGS.CHARACTERS.WARLY.DESCRIBE.WOLFYBACK			= "Feels like my food would be eaten if I placed them in there."
--end

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