local assets=
{
    Asset("ANIM", "anim/goldenhammer.zip"),
    Asset("ANIM", "anim/swap_goldenhammer.zip"),

    Asset("ATLAS", "inventoryimages/goldenhammer.xml"),
    Asset("IMAGE", "inventoryimages/goldenhammer.tex"),
}

prefabs = {
}

local function onfinished(inst)
    inst:Remove()
end

    local function OnEquip(inst, owner)
	    owner.SoundEmitter:PlaySound("dontstarve/wilson/equip_item_gold")
        owner.AnimState:OverrideSymbol("swap_object", "swap_goldenhammer", "swap_hammer")
        owner.AnimState:Show("ARM_carry")
        owner.AnimState:Hide("ARM_normal")
    end


    local function OnUnequip(inst, owner)
        owner.AnimState:Hide("ARM_carry")
        owner.AnimState:Show("ARM_normal")
    end


local function fn(sim)
	local inst = CreateEntity()
	local trans = inst.entity:AddTransform()
	local anim = inst.entity:AddAnimState()
	inst.entity:AddSoundEmitter()
    MakeInventoryPhysics(inst)
	inst.entity:AddNetwork()

    anim:SetBank("hammer")
    anim:SetBuild("goldenhammer")
    anim:PlayAnimation("idle")




      if not TheWorld.ismastersim then
        return inst
    end

	inst.entity:SetPristine()

    -----
    inst:AddComponent("tool")
    inst.components.tool:SetAction(ACTIONS.HAMMER)
    -------
    inst:AddComponent("finiteuses")
    inst.components.finiteuses:SetMaxUses(TUNING.HAMMER_USES * 4)
    inst.components.finiteuses:SetUses(TUNING.HAMMER_USES * 4)
    inst.components.finiteuses:SetOnFinished(inst.Remove)
    inst.components.finiteuses:SetConsumption(ACTIONS.HAMMER, 1)
    -------

    inst:AddComponent("weapon")
    inst.components.weapon:SetDamage(17)
	inst.components.weapon.attackwear = 1
    -------
	inst:AddComponent("inspectable")

	inst:AddComponent("inventoryitem")
    inst.components.inventoryitem.imagename = "goldenhammer"
    inst.components.inventoryitem.atlasname = "inventoryimages/goldenhammer.xml"

    inst:AddComponent("equippable")
    inst.components.equippable:SetOnEquip(OnEquip)
    inst.components.equippable:SetOnUnequip(OnUnequip)
    inst:AddInherentAction(ACTIONS.HAMMER)

     ------
            MakeHauntableLaunch(inst)

    return inst
end

return  Prefab("common/inventory/goldenhammer", fn, assets, prefabs)
