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

}


local prefabs =
{
     "firesplash_fx",
   
}

local function onequip(inst, owner) 
    owner.AnimState:OverrideSymbol("swap_object", "swap_lm", "swap_galientsword")
    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 onattack(inst, attacker, target)

   if math.random() < .33 then
      target.components.health:DoDelta(-20)
 if target then
  SpawnPrefab("firesplash_fx").Transform:SetPosition(inst:GetPosition():Get())
end
        end
end

local function fn(Sim)
	local inst = CreateEntity()
	local trans = inst.entity:AddTransform()
	local anim = inst.entity:AddAnimState()
    MakeInventoryPhysics(inst)
if SaveGameIndex:IsModeShipwrecked() then
  
	MakeInventoryFloatable(inst, "idle", "idle")
end
    anim:SetBank("lm")
    anim:SetBuild("lm")
 anim:PlayAnimation("idle")   
    
    inst:AddTag("sharp")

    inst:AddComponent("weapon")
    inst.components.weapon:SetDamage(50)
    inst.components.weapon:SetOnAttack(onattack)

    -------
inst:AddComponent("finiteuses")
    inst.components.finiteuses:SetMaxUses(300)
    inst.components.finiteuses:SetUses(300)

    inst.components.finiteuses:SetOnFinished(inst.Remove)


  
    inst:AddComponent("inspectable")
    
    inst:AddComponent("inventoryitem")
     inst:AddComponent("inventoryitem")
	inst.components.inventoryitem.atlasname = "images/inventoryimages/lm.xml"
    inst:AddComponent("equippable")
    inst.components.equippable:SetOnEquip( onequip )
    inst.components.equippable:SetOnUnequip( onunequip )

 
    
    return inst
end

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