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

local function onequip(inst, owner)
    --owner.AnimState:OverrideSymbol("swap_body", "swap_backpack", "backpack")
    owner.AnimState:OverrideSymbol("swap_body", "swap_bunnyback", "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 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()
	local inst = CreateEntity()

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

  MakeInventoryPhysics(inst)

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

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

		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/bunnyback.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("container")

		inst.components.container:WidgetSetup("bunnyback")

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

STRINGS.NAMES.BUNNYBACK 								= "Bunnyback"
STRINGS.RECIPE_DESC.BUNNYBACK 							= "A bag of fuzzyness."

STRINGS.CHARACTERS.GENERIC.DESCRIBE.BUNNYBACK 			= "Feels like I'm resting on a bed, while standing!"
STRINGS.CHARACTERS.WILLOW.DESCRIBE.BUNNYBACK 			= "A massive, wearable bunny tail."
STRINGS.CHARACTERS.WOLFGANG.DESCRIBE.BUNNYBACK 			= "Back feels puffy!"
STRINGS.CHARACTERS.WENDY.DESCRIBE.BUNNYBACK 			= "It is a bag full of fuzzy wuzzy essence."
STRINGS.CHARACTERS.WX78.DESCRIBE.BUNNYBACK 				= "INCREASES FUZZINESS TO MODERATE LEVELS"
STRINGS.CHARACTERS.WICKERBOTTOM.DESCRIBE.BUNNYBACK 		= "The comfort reduces the weight of carrying."
STRINGS.CHARACTERS.WOODIE.DESCRIBE.BUNNYBACK 			= "Looks like a pile of snow."
STRINGS.CHARACTERS.WAXWELL.DESCRIBE.BUNNYBACK 			= "Comfort, without sitting or lying down."
STRINGS.CHARACTERS.WATHGRITHR.DESCRIBE.BUNNYBACK 	= "Even warriörs seek comfört."
STRINGS.CHARACTERS.WEBBER.DESCRIBE.BUNNYBACK		= "Luck is behind my back."

--[[if IsDLCEnabled(CAPY_DLC) then
	STRINGS.CHARACTERS.WOODLEGS.DESCRIBE.BUNNYBACK		= "I ain't liking this, but it does th' job."
	STRINGS.CHARACTERS.WALANI.DESCRIBE.BUNNYBACK		= "Cute, in a way."
	STRINGS.CHARACTERS.WARLY.DESCRIBE.BUNNYBACK			= "Fuzzy on the back."
end]]

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