local assets =
{
	-- Animation files used for the item.
	Asset("ANIM", "anim/woodenmace.zip"),
	Asset("ANIM", "anim/swap_woodenmace.zip"),

	-- Inventory image and atlas file used for the item.
    Asset("ATLAS", "images/inventoryimages/woodenmace.xml"),
    Asset("IMAGE", "images/inventoryimages/woodenmace.tex"),
}

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

local function onequip(inst, owner)
    owner.AnimState:OverrideSymbol("swap_object", -- Symbol to override.
    	"swap_woodenmace", -- Animation bank we will use to overwrite the symbol.
    	"swap_woodenmace") -- Symbol to overwrite it with.
    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 init()
	local inst = CreateEntity()

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

    MakeInventoryPhysics(inst)

    inst.AnimState:SetBank("woodenmace")
    inst.AnimState:SetBuild("woodenmace")
    inst.AnimState:PlayAnimation("woodenmace")

	if TheSim:GetGameID()=="DST" then
		inst.entity:AddNetwork()

		if not TheWorld.ismastersim then
			return inst
		end

		inst.entity:SetPristine()

	    MakeHauntableLaunch(inst)
	end

    inst:AddComponent("weapon")
    inst.components.weapon:SetDamage(TUNING.SPEAR_DAMAGE)

    inst:AddComponent("inspectable")

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

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

	inst:AddComponent("finiteuses")
    inst.components.finiteuses:SetMaxUses(50)
    inst.components.finiteuses:SetUses(50)

	inst.components.finiteuses:SetOnFinished( onfinished )

	inst:AddComponent("fuel")
    inst.components.fuel.fuelvalue = TUNING.MED_LARGE_FUEL
	MakeSmallBurnable(inst)
	MakeSmallPropagator(inst)

    return inst
end

return Prefab("common/inventory/woodenmace", init, assets)
