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

local function onequip(inst, owner)
    owner.AnimState:OverrideSymbol("swap_object", "swap_miaoji_sword", "swap_miaoji_sword")
    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()

    inst.entity:AddTransform()
    inst.entity:AddAnimState()
	if TheSim:GetGameID() == "DST" then
    inst.entity:AddNetwork()
	end	
    MakeInventoryPhysics(inst)

    inst.AnimState:SetBank("miaoji_sword")
    inst.AnimState:SetBuild("miaoji_sword")
    inst.AnimState:PlayAnimation("idle")

    inst:AddTag("sharp")
    inst:AddTag("pointy")
	if TheSim:GetGameID() == "DST" then
    inst.entity:SetPristine()

    if not TheWorld.ismastersim then
        return inst
    end
	end

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

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

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

    inst:AddComponent("inspectable")

    inst:AddComponent("inventoryitem")
	inst.components.inventoryitem.atlasname = "images/inventoryimages/miaoji_sword.xml"
    inst:AddComponent("equippable")
    inst.components.equippable:SetOnEquip(onequip)
    inst.components.equippable:SetOnUnequip(onunequip)
	if TheSim:GetGameID() == "DST" then
    MakeHauntableLaunch(inst)
	end

    return inst
end

return Prefab("miaoji_sword", fn, assets)