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




local function onAttackb(inst, attacker, target)

   if target.components.sleeper and target.components.sleeper:IsAsleep() then
        target.components.sleeper:WakeUp()
    end
    if target.components.burnable then
        if target.components.burnable:IsBurning() then
            target.components.burnable:Extinguish()
        elseif target.components.burnable:IsSmoldering() then
            target.components.burnable:SmotherSmolder()
        end
    end

    if target.components.combat then
        target.components.combat:SuggestTarget(attacker)
    end

    if target.sg and not target.sg:HasStateTag("frozen") then
        target:PushEvent("attacked", {attacker = attacker, damage = 0})
    end

    if target.components.freezable then
        target.components.freezable:AddColdness(0.7)
        target.components.freezable:SpawnShatterFX()
    end


end




local function onequip(inst, owner)

    owner.AnimState:OverrideSymbol("swap_object", "swap_sword_6", "swap_sword_6")
    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()
    local inst = CreateEntity()
    local trans = inst.entity:AddTransform()
    local anim = inst.entity:AddAnimState()
    --inst.entity:AddNetwork()

    MakeInventoryPhysics(inst)
	
    inst.AnimState:SetBank("sword_6")
    inst.AnimState:SetBuild("sword_6")
    inst.AnimState:PlayAnimation("idle")
	inst.entity:AddMiniMapEntity()
	inst.MiniMapEntity:SetIcon( "sword_6.tex" )   
	--inst:AddTag("shadow")
	--inst:AddTag("feng")
    inst:AddTag("sharp")
    inst:AddTag("weapon_sword")
    --inst:AddTag("extinguisher")
	


    inst:AddComponent("weapon")
    inst.components.weapon:SetDamage(27)

    -------
    inst.components.weapon:SetRange(1.2)
    inst.components.weapon:SetOnAttack(onAttackb)


	
    inst:AddComponent("inspectable")
	


    inst:AddComponent("inventoryitem")
	inst.components.inventoryitem.imagename = "sword_6"
    inst.components.inventoryitem.atlasname = "images/inventoryimages/sword_6.xml"
	--inst.components.inventoryitem.nobounce = true
	inst.components.inventoryitem.keepondeath = true


	inst:AddComponent("talker")
    inst.components.talker.fontsize = 36
    inst.components.talker.font = TALKINGFONT
    inst.components.talker.colour = Vector3(.9, .4, .4)
    inst.components.talker.offset = Vector3(0, 0, 0)
    inst.components.talker.symbol = "swap_object"
	inst.Transform:SetScale(1.5,1.5,1.5)
	
    inst:AddComponent("equippable")
    inst.components.equippable:SetOnEquip(onequip)
    inst.components.equippable:SetOnUnequip(onunequip)
    --inst.components.equippable.dapperness = 20/60
	
	inst:AddComponent("insulator")
    inst.components.insulator:SetInsulation(TUNING.INSULATION_LARGE)
    inst.components.insulator:SetSummer()
	
--inst:AddComponent("tool")
--inst.components.tool:SetAction(ACTIONS.HACK,2)
--inst.components.tool:SetAction(ACTIONS.CHOP, 5)
--inst.components.tool:SetAction(ACTIONS.MINE, 2)

 
	
    return inst
end

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