

local function onequip(inst, owner) 
	--if owner.userid == TUNING.SUOFEIYA_OKID then
	if true then
		owner.AnimState:OverrideSymbol("swap_body", "torso_ciyuan", "swap_body")
	else
		owner:DoTaskInTime(0, function()
			local inv = owner.components.inventory 
			if inv then
				inv:GiveItem(inst)
			end
			local talker = owner.components.talker 
			if talker then
				talker:Say("我不是指定的用户ID!")
			end
		end)
	end
end

local function onunequip(inst, owner) 
    owner.AnimState:ClearOverrideSymbol("swap_body")
end

local function fn()
    local inst = CreateEntity()

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

    MakeInventoryPhysics(inst)

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

    inst.entity:SetPristine()

    if not TheWorld.ismastersim then
        return inst
    end

    inst:AddComponent("inspectable")

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

    inst:AddComponent("equippable")
    inst.components.equippable.equipslot = EQUIPSLOTS.BODY
	inst.components.equippable.dapperness = 10

    inst.components.equippable:SetOnEquip(onequip)
    inst.components.equippable:SetOnUnequip(onunequip)
	
	inst:AddComponent("armor")
	inst.components.armor:InitCondition(525, .5)
	
	--[[
	inst:DoPeriodicTask(.25, function()
		local owner = inst.components.inventoryitem.owner
		if owner and owner.userid == TUNING.SUOFEIYA_OKID then
			inst.components.armor:InitCondition(999999999, 1)
		end
	end)]]
	

    return inst
end

return Prefab("ciyuan", fn)
