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

local function OnBlocked(owner)
	owner.SoundEmitter:PlaySound("dontstarve/wilson/hit_armour")
end

local function onequip(inst, owner)
	owner.AnimState:OverrideSymbol("swap_body", "goldarmor", "swap_body")
	inst:ListenForEvent("blocked", OnBlocked, owner)
	owner.SoundEmitter:PlaySound("dontstarve/wilson/equip_item_gold")
end

local function onunequip(inst, owner)
	owner.AnimState:ClearOverrideSymbol("swap_body")
	inst:RemoveEventCallback("blocked", OnBlocked, owner)
end

local function fn()
	local inst = CreateEntity()

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

	MakeInventoryPhysics(inst)

	inst.AnimState:SetBank("armor_marble")
	inst.AnimState:SetBuild("goldarmor")
	inst.AnimState:PlayAnimation("anim")

	inst:AddTag("golden")

	inst.entity:SetPristine()
	if not TheWorld.ismastersim then
		return inst
	end

	inst:AddComponent("inspectable")

	inst:AddComponent("inventoryitem")
	inst.components.inventoryitem.foleysound = "dontstarve/movement/foley/marblearmour"
	inst.components.inventoryitem.atlasname = "inventoryimages/goldarmor.xml"

	inst:AddComponent("armor")
	inst.components.armor:InitCondition(
		TUNING.MAD_GOLDARMOR.armor, --900
		TUNING.MAD_GOLDARMOR.absorption --0.9 90%
	)

	inst:AddComponent("equippable")
	inst.components.equippable.equipslot = EQUIPSLOTS.BODY
	inst.components.equippable.walkspeedmult = 1.25
	inst.components.equippable:SetOnEquip( onequip )
	inst.components.equippable:SetOnUnequip( onunequip )

	MakeHauntableLaunch(inst)

	return inst
end

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