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

---------------------------
local function levelexp(inst,data)

	local max_exp = 4100
	local exp = math.min(inst.level, max_exp)

if inst.level <= 4000 then
inst.components.talker:Say("-[兔子侦查帽]\n[成长点数]".. (inst.level))
inst:RemoveTag("levelup")
end
if inst.level >=0 and inst.level <10 then
inst.components.talker:Say("-[兔子侦查帽] \n下一级:[10]\n[成长点数]".. (inst.level))
inst:AddTag("level1")
elseif inst.level >=10 and inst.level <30 then
inst.components.talker:Say("-[兔子侦查帽] \n下一级:[30]\n[成长点数]".. (inst.level))
inst:AddTag("level2")
inst:RemoveTag("level1")
elseif inst.level >=30 and inst.level <60 then
inst.components.talker:Say("-[兔子侦查帽] \n下一级:[60]\n[成长点数]".. (inst.level))
inst:AddTag("level3")
inst:RemoveTag("level1")
inst:RemoveTag("level2")
elseif inst.level >=60 and inst.level <100 then
inst.components.talker:Say("-[兔子侦查帽] \n下一级:[100]\n[成长点数]".. (inst.level))
inst:AddTag("level4")
inst:RemoveTag("level1")
inst:RemoveTag("level2")
inst:RemoveTag("level3")
elseif inst.level >=100 and inst.level <150 then
inst.components.talker:Say("-[兔子侦查帽] \n下一级:[150]\n[成长点数]".. (inst.level))
inst:AddTag("level5")
inst:RemoveTag("level1")
inst:RemoveTag("level2")
inst:RemoveTag("level3")
inst:RemoveTag("level4")
elseif inst.level >=150 and inst.level <200 then
inst.components.talker:Say("-[兔子侦查帽] \n下一级:[200]\n[成长点数]".. (inst.level))
inst:AddTag("level6")
inst:RemoveTag("level1")
inst:RemoveTag("level2")
inst:RemoveTag("level3")
inst:RemoveTag("level4")
inst:RemoveTag("level5")
elseif inst.level >=200 and inst.level <250 then
inst.components.talker:Say("-[兔子侦查帽] \n下一级:[250]\n[成长点数]".. (inst.level))
inst:AddTag("level7")
inst:RemoveTag("level1")
inst:RemoveTag("level2")
inst:RemoveTag("level3")
inst:RemoveTag("level4")
inst:RemoveTag("level5")
inst:RemoveTag("level6")
elseif inst.level >=250 and inst.level <300 then
inst.components.talker:Say("-[兔子侦查帽] \n下一级:[300]\n[成长点数]".. (inst.level))
inst:AddTag("level8")
inst:RemoveTag("level1")
inst:RemoveTag("level2")
inst:RemoveTag("level3")
inst:RemoveTag("level4")
inst:RemoveTag("level5")
inst:RemoveTag("level6")
inst:RemoveTag("level7")
elseif inst.level >=300 and inst.level <350 then
inst.components.talker:Say("-[兔子侦查帽] \n下一级:[350]\n[成长点数]".. (inst.level))
inst:AddTag("level9")
inst:RemoveTag("level1")
inst:RemoveTag("level2")
inst:RemoveTag("level3")
inst:RemoveTag("level4")
inst:RemoveTag("level5")
inst:RemoveTag("level6")
inst:RemoveTag("level7")
inst:RemoveTag("level8")
elseif inst.level >=350 and inst.level <450 then
inst.components.talker:Say("-[兔子侦查帽] \n下一级:[450]\n[成长点数]".. (inst.level))
inst:AddTag("level10")
inst:RemoveTag("level1")
inst:RemoveTag("level2")
inst:RemoveTag("level3")
inst:RemoveTag("level4")
inst:RemoveTag("level5")
inst:RemoveTag("level6")
inst:RemoveTag("level7")
inst:RemoveTag("level8")
inst:RemoveTag("level9")
elseif inst.level >=450 and inst.level <600 then
inst.components.talker:Say("-[兔子侦查帽] \n下一级:[600]\n[成长点数]".. (inst.level))
inst:AddTag("level11")
inst:RemoveTag("level1")
inst:RemoveTag("level2")
inst:RemoveTag("level3")
inst:RemoveTag("level4")
inst:RemoveTag("level5")
inst:RemoveTag("level6")
inst:RemoveTag("level7")
inst:RemoveTag("level8")
inst:RemoveTag("level9")
inst:RemoveTag("level10")
elseif inst.level >=600 and inst.level <700 then
inst.components.talker:Say("-[兔子侦查帽] \n下一级:[700]\n[成长点数]".. (inst.level))
inst:AddTag("level12")
inst:RemoveTag("level1")
inst:RemoveTag("level2")
inst:RemoveTag("level3")
inst:RemoveTag("level4")
inst:RemoveTag("level5")
inst:RemoveTag("level6")
inst:RemoveTag("level7")
inst:RemoveTag("level8")
inst:RemoveTag("level9")
inst:RemoveTag("level10")
inst:RemoveTag("level11")
elseif inst.level >=700 and inst.level <800 then
inst.components.talker:Say("-[兔子侦查帽] \n下一级:[800]\n[成长点数]".. (inst.level))
inst:AddTag("level13")
inst:RemoveTag("level1")
inst:RemoveTag("level2")
inst:RemoveTag("level3")
inst:RemoveTag("level4")
inst:RemoveTag("level5")
inst:RemoveTag("level6")
inst:RemoveTag("level7")
inst:RemoveTag("level8")
inst:RemoveTag("level9")
inst:RemoveTag("level10")
inst:RemoveTag("level11")
inst:RemoveTag("level12")
elseif inst.level >=800 and inst.level <900 then
inst.components.talker:Say("-[兔子侦查帽] \n下一级:[900]\n[成长点数]".. (inst.level))
inst:AddTag("level14")
inst:RemoveTag("level1")
inst:RemoveTag("level2")
inst:RemoveTag("level3")
inst:RemoveTag("level4")
inst:RemoveTag("level5")
inst:RemoveTag("level6")
inst:RemoveTag("level7")
inst:RemoveTag("level8")
inst:RemoveTag("level9")
inst:RemoveTag("level10")
inst:RemoveTag("level11")
inst:RemoveTag("level12")
inst:RemoveTag("level13")
elseif inst.level >=900 and inst.level <1000 then
inst.components.talker:Say("-[兔子侦查帽] \n下一级:[1000]\n[成长点数]".. (inst.level))
inst:AddTag("level15")
inst:RemoveTag("level1")
inst:RemoveTag("level2")
inst:RemoveTag("level3")
inst:RemoveTag("level4")
inst:RemoveTag("level5")
inst:RemoveTag("level6")
inst:RemoveTag("level7")
inst:RemoveTag("level8")
inst:RemoveTag("level9")
inst:RemoveTag("level10")
inst:RemoveTag("level11")
inst:RemoveTag("level12")
inst:RemoveTag("level13")
inst:RemoveTag("level14")
elseif inst.level >=1000 and inst.level <1100 then
inst.components.talker:Say("-[兔子侦查帽] \n下一级:[1100]\n[成长点数]".. (inst.level))
inst:AddTag("level16")
inst:RemoveTag("level1")
inst:RemoveTag("level2")
inst:RemoveTag("level3")
inst:RemoveTag("level4")
inst:RemoveTag("level5")
inst:RemoveTag("level6")
inst:RemoveTag("level7")
inst:RemoveTag("level8")
inst:RemoveTag("level9")
inst:RemoveTag("level10")
inst:RemoveTag("level11")
inst:RemoveTag("level12")
inst:RemoveTag("level13")
inst:RemoveTag("level14")
inst:RemoveTag("level15")
elseif inst.level >=1100 and inst.level <1200 then
inst.components.talker:Say("-[兔子侦查帽] \n下一级:[1200]\n[成长点数]".. (inst.level))
inst:AddTag("level17")
inst:RemoveTag("level1")
inst:RemoveTag("level2")
inst:RemoveTag("level3")
inst:RemoveTag("level4")
inst:RemoveTag("level5")
inst:RemoveTag("level6")
inst:RemoveTag("level7")
inst:RemoveTag("level8")
inst:RemoveTag("level9")
inst:RemoveTag("level10")
inst:RemoveTag("level11")
inst:RemoveTag("level12")
inst:RemoveTag("level13")
inst:RemoveTag("level14")
inst:RemoveTag("level15")
inst:RemoveTag("level16")
elseif inst.level >=1200 and inst.level <1300 then
inst.components.talker:Say("-[兔子侦查帽] \n下一级:[1300]\n[成长点数]".. (inst.level))
inst:AddTag("level18")
inst:RemoveTag("level1")
inst:RemoveTag("level2")
inst:RemoveTag("level3")
inst:RemoveTag("level4")
inst:RemoveTag("level5")
inst:RemoveTag("level6")
inst:RemoveTag("level7")
inst:RemoveTag("level8")
inst:RemoveTag("level9")
inst:RemoveTag("level10")
inst:RemoveTag("level11")
inst:RemoveTag("level12")
inst:RemoveTag("level13")
inst:RemoveTag("level14")
inst:RemoveTag("level15")
inst:RemoveTag("level16")
inst:RemoveTag("level17")
elseif inst.level >=1300 and inst.level <1400 then
inst.components.talker:Say("-[兔子侦查帽] \n下一级:[1400]\n[成长点数]".. (inst.level))
inst:AddTag("level19")
inst:RemoveTag("level1")
inst:RemoveTag("level2")
inst:RemoveTag("level3")
inst:RemoveTag("level4")
inst:RemoveTag("level5")
inst:RemoveTag("level6")
inst:RemoveTag("level7")
inst:RemoveTag("level8")
inst:RemoveTag("level9")
inst:RemoveTag("level10")
inst:RemoveTag("level11")
inst:RemoveTag("level12")
inst:RemoveTag("level13")
inst:RemoveTag("level14")
inst:RemoveTag("level15")
inst:RemoveTag("level16")
inst:RemoveTag("level17")
inst:RemoveTag("level18")
elseif inst.level >=1400 and inst.level <1500 then
inst.components.talker:Say("-[兔子侦查帽] \n下一级:[1500]\n[成长点数]".. (inst.level))
inst:AddTag("level20")
inst:RemoveTag("level1")
inst:RemoveTag("level2")
inst:RemoveTag("level3")
inst:RemoveTag("level4")
inst:RemoveTag("level5")
inst:RemoveTag("level6")
inst:RemoveTag("level7")
inst:RemoveTag("level8")
inst:RemoveTag("level9")
inst:RemoveTag("level10")
inst:RemoveTag("level11")
inst:RemoveTag("level12")
inst:RemoveTag("level13")
inst:RemoveTag("level14")
inst:RemoveTag("level15")
inst:RemoveTag("level16")
inst:RemoveTag("level17")
inst:RemoveTag("level18")
inst:RemoveTag("level19")
elseif inst.level >=1500 and inst.level <1600 then
inst.components.talker:Say("-[兔子侦查帽] \n下一级:[1600]\n[成长点数]".. (inst.level))
inst:AddTag("level21")
inst:RemoveTag("level1")
inst:RemoveTag("level2")
inst:RemoveTag("level3")
inst:RemoveTag("level4")
inst:RemoveTag("level5")
inst:RemoveTag("level6")
inst:RemoveTag("level7")
inst:RemoveTag("level8")
inst:RemoveTag("level9")
inst:RemoveTag("level10")
inst:RemoveTag("level11")
inst:RemoveTag("level12")
inst:RemoveTag("level13")
inst:RemoveTag("level14")
inst:RemoveTag("level15")
inst:RemoveTag("level16")
inst:RemoveTag("level17")
inst:RemoveTag("level18")
inst:RemoveTag("level19")
inst:RemoveTag("level20")
elseif inst.level >=1600 and inst.level <1800 then
inst.components.talker:Say("-[兔子侦查帽] \n下一级:[1800]\n[成长点数]".. (inst.level))
inst:AddTag("level22")
inst:RemoveTag("level1")
inst:RemoveTag("level2")
inst:RemoveTag("level3")
inst:RemoveTag("level4")
inst:RemoveTag("level5")
inst:RemoveTag("level6")
inst:RemoveTag("level7")
inst:RemoveTag("level8")
inst:RemoveTag("level9")
inst:RemoveTag("level10")
inst:RemoveTag("level11")
inst:RemoveTag("level12")
inst:RemoveTag("level13")
inst:RemoveTag("level14")
inst:RemoveTag("level15")
inst:RemoveTag("level16")
inst:RemoveTag("level17")
inst:RemoveTag("level18")
inst:RemoveTag("level19")
inst:RemoveTag("level20")
inst:RemoveTag("level21")
elseif inst.level >=1800 and inst.level <2000 then
inst.components.talker:Say("-[兔子侦查帽] \n下一级:[2000]\n[成长点数]".. (inst.level))
inst:AddTag("level23")
inst:RemoveTag("level1")
inst:RemoveTag("level2")
inst:RemoveTag("level3")
inst:RemoveTag("level4")
inst:RemoveTag("level5")
inst:RemoveTag("level6")
inst:RemoveTag("level7")
inst:RemoveTag("level8")
inst:RemoveTag("level9")
inst:RemoveTag("level10")
inst:RemoveTag("level11")
inst:RemoveTag("level12")
inst:RemoveTag("level13")
inst:RemoveTag("level14")
inst:RemoveTag("level15")
inst:RemoveTag("level16")
inst:RemoveTag("level17")
inst:RemoveTag("level18")
inst:RemoveTag("level19")
inst:RemoveTag("level20")
inst:RemoveTag("level21")
inst:RemoveTag("level22")
elseif inst.level >=2000 and inst.level <2200 then
inst.components.talker:Say("-[兔子侦查帽] \n下一级:[2200]\n[成长点数]".. (inst.level))
inst:AddTag("level24")
inst:RemoveTag("level1")
inst:RemoveTag("level2")
inst:RemoveTag("level3")
inst:RemoveTag("level4")
inst:RemoveTag("level5")
inst:RemoveTag("level6")
inst:RemoveTag("level7")
inst:RemoveTag("level8")
inst:RemoveTag("level9")
inst:RemoveTag("level10")
inst:RemoveTag("level11")
inst:RemoveTag("level12")
inst:RemoveTag("level13")
inst:RemoveTag("level14")
inst:RemoveTag("level15")
inst:RemoveTag("level16")
inst:RemoveTag("level17")
inst:RemoveTag("level18")
inst:RemoveTag("level19")
inst:RemoveTag("level20")
inst:RemoveTag("level21")
inst:RemoveTag("level22")
inst:RemoveTag("level23")
elseif inst.level >=2200 and inst.level <2400 then
inst.components.talker:Say("-[兔子侦查帽] \n下一级:[2400]\n[成长点数]".. (inst.level))
inst:AddTag("level25")
inst:RemoveTag("level1")
inst:RemoveTag("level2")
inst:RemoveTag("level3")
inst:RemoveTag("level4")
inst:RemoveTag("level5")
inst:RemoveTag("level6")
inst:RemoveTag("level7")
inst:RemoveTag("level8")
inst:RemoveTag("level9")
inst:RemoveTag("level10")
inst:RemoveTag("level11")
inst:RemoveTag("level12")
inst:RemoveTag("level13")
inst:RemoveTag("level14")
inst:RemoveTag("level15")
inst:RemoveTag("level16")
inst:RemoveTag("level17")
inst:RemoveTag("level18")
inst:RemoveTag("level19")
inst:RemoveTag("level20")
inst:RemoveTag("level21")
inst:RemoveTag("level22")
inst:RemoveTag("level23")
inst:RemoveTag("level24")
elseif inst.level >=2400 and inst.level <2600 then
inst.components.talker:Say("-[兔子侦查帽] \n下一级:[2600]\n[成长点数]".. (inst.level))
inst:AddTag("level26")
inst:RemoveTag("level1")
inst:RemoveTag("level2")
inst:RemoveTag("level3")
inst:RemoveTag("level4")
inst:RemoveTag("level5")
inst:RemoveTag("level6")
inst:RemoveTag("level7")
inst:RemoveTag("level8")
inst:RemoveTag("level9")
inst:RemoveTag("level10")
inst:RemoveTag("level11")
inst:RemoveTag("level12")
inst:RemoveTag("level13")
inst:RemoveTag("level14")
inst:RemoveTag("level15")
inst:RemoveTag("level16")
inst:RemoveTag("level17")
inst:RemoveTag("level18")
inst:RemoveTag("level19")
inst:RemoveTag("level20")
inst:RemoveTag("level21")
inst:RemoveTag("level22")
inst:RemoveTag("level23")
inst:RemoveTag("level24")
inst:RemoveTag("level25")
elseif inst.level >=2600 and inst.level <2800 then
inst.components.talker:Say("-[兔子侦查帽] \n下一级:[2800]\n[成长点数]".. (inst.level))
inst:AddTag("level27")
inst:RemoveTag("level1")
inst:RemoveTag("level2")
inst:RemoveTag("level3")
inst:RemoveTag("level4")
inst:RemoveTag("level5")
inst:RemoveTag("level6")
inst:RemoveTag("level7")
inst:RemoveTag("level8")
inst:RemoveTag("level9")
inst:RemoveTag("level10")
inst:RemoveTag("level11")
inst:RemoveTag("level12")
inst:RemoveTag("level13")
inst:RemoveTag("level14")
inst:RemoveTag("level15")
inst:RemoveTag("level16")
inst:RemoveTag("level17")
inst:RemoveTag("level18")
inst:RemoveTag("level19")
inst:RemoveTag("level20")
inst:RemoveTag("level21")
inst:RemoveTag("level22")
inst:RemoveTag("level23")
inst:RemoveTag("level24")
inst:RemoveTag("level25")
inst:RemoveTag("level26")
elseif inst.level >=2800 and inst.level <3000 then
inst.components.talker:Say("-[兔子侦查帽] \n下一级:[3000]\n[成长点数]".. (inst.level))
inst:AddTag("level28")
inst:RemoveTag("level1")
inst:RemoveTag("level2")
inst:RemoveTag("level3")
inst:RemoveTag("level4")
inst:RemoveTag("level5")
inst:RemoveTag("level6")
inst:RemoveTag("level7")
inst:RemoveTag("level8")
inst:RemoveTag("level9")
inst:RemoveTag("level10")
inst:RemoveTag("level11")
inst:RemoveTag("level12")
inst:RemoveTag("level13")
inst:RemoveTag("level14")
inst:RemoveTag("level15")
inst:RemoveTag("level16")
inst:RemoveTag("level17")
inst:RemoveTag("level18")
inst:RemoveTag("level19")
inst:RemoveTag("level20")
inst:RemoveTag("level21")
inst:RemoveTag("level22")
inst:RemoveTag("level23")
inst:RemoveTag("level24")
inst:RemoveTag("level25")
inst:RemoveTag("level26")
inst:RemoveTag("level27")
elseif inst.level >=3000 and inst.level <4000 then
inst.components.talker:Say("-[兔子侦查帽] \n下一级:[4000]\n[成长点数]".. (inst.level))
inst:AddTag("level29")
inst:RemoveTag("level1")
inst:RemoveTag("level2")
inst:RemoveTag("level3")
inst:RemoveTag("level4")
inst:RemoveTag("level5")
inst:RemoveTag("level6")
inst:RemoveTag("level7")
inst:RemoveTag("level8")
inst:RemoveTag("level9")
inst:RemoveTag("level10")
inst:RemoveTag("level11")
inst:RemoveTag("level12")
inst:RemoveTag("level13")
inst:RemoveTag("level14")
inst:RemoveTag("level15")
inst:RemoveTag("level16")
inst:RemoveTag("level17")
inst:RemoveTag("level18")
inst:RemoveTag("level19")
inst:RemoveTag("level20")
inst:RemoveTag("level21")
inst:RemoveTag("level22")
inst:RemoveTag("level23")
inst:RemoveTag("level24")
inst:RemoveTag("level25")
inst:RemoveTag("level26")
inst:RemoveTag("level27")
inst:RemoveTag("level28")
elseif inst.level >=4000 then
inst.components.talker:Say("-[兔子侦查帽] \n[满级]")
inst:AddTag("level30")
inst:RemoveTag("level1")
inst:RemoveTag("level2")
inst:RemoveTag("level3")
inst:RemoveTag("level4")
inst:RemoveTag("level5")
inst:RemoveTag("level6")
inst:RemoveTag("level7")
inst:RemoveTag("level8")
inst:RemoveTag("level9")
inst:RemoveTag("level10")
inst:RemoveTag("level11")
inst:RemoveTag("level12")
inst:RemoveTag("level13")
inst:RemoveTag("level14")
inst:RemoveTag("level15")
inst:RemoveTag("level16")
inst:RemoveTag("level17")
inst:RemoveTag("level18")
inst:RemoveTag("level19")
inst:RemoveTag("level20")
inst:RemoveTag("level21")
inst:RemoveTag("level22")
inst:RemoveTag("level23")
inst:RemoveTag("level24")
inst:RemoveTag("level25")
inst:RemoveTag("level26")
inst:RemoveTag("level27")
inst:RemoveTag("level28")
inst:RemoveTag("level29")
end
end


local function onpreload(inst, data)
	if data then
		if data.level then
		inst.level = data.level
			levelexp(inst)
end
	end
		end
local function onsave(inst, data)
	data.level = inst.level
	data.charge_time = inst.charge_time
end

local function OnDurability(inst, data)
inst:AddTag("broken")
inst.components.fueled:StopConsuming()        
    inst.components.armor:InitCondition(9999999999999999999999999999999999999999999999999999999999999, 0.01)
inst.components.talker:Say("-[残破的 兔子帽]\n护甲值 (1)\n耐久度 (1)\n速度上升(0)")
end

local function UpgradeArmor(inst)
if inst:HasTag("broken") then
    inst.components.equippable.walkspeedmult = 1
	inst.components.talker:Say("-[残破的 兔子帽]\n耐久度 (0)\n速度上升 (0)")
            inst.components.fueled:StopConsuming()        
   end

if not inst:HasTag("broken") then
        if inst:HasTag("level1") then
	inst.components.talker:Say("-[兔子侦查帽(1级)]\n护甲值(10)\n速度上升\n保暖(小)")
    inst.components.armor:InitCondition(9999999999999999999999999999999999999999999999999999999999999, 0.1)
    inst.components.insulator.insulation = TUNING.INSULATION_SMALL

        elseif inst:HasTag("level2") then
	inst.components.talker:Say("-[兔子侦查帽(2级)]\n护甲值(11)\n速度上升\n保暖(小)")
    inst.components.armor:InitCondition(9999999999999999999999999999999999999999999999999999999999999, 0.11)
    inst.components.insulator.insulation = TUNING.INSULATION_SMALL

        elseif inst:HasTag("level3") then
	inst.components.talker:Say("-[兔子侦查帽(3级)]\n护甲值(12)\n速度上升\n保暖(小)")
    inst.components.armor:InitCondition(9999999999999999999999999999999999999999999999999999999999999, 0.12)
    inst.components.insulator.insulation = TUNING.INSULATION_SMALL

        elseif inst:HasTag("level4") then
	inst.components.talker:Say("-[兔子侦查帽(4级)]\n护甲值(13)\n速度上升\n保暖(小)")
    inst.components.armor:InitCondition(9999999999999999999999999999999999999999999999999999999999999, 0.13)
    inst.components.insulator.insulation = TUNING.INSULATION_SMALL

        elseif inst:HasTag("level5") then
	inst.components.talker:Say("-[兔子侦查帽(5级)]\n护甲值(14)\n速度上升\n保暖(小)")
    inst.components.armor:InitCondition(9999999999999999999999999999999999999999999999999999999999999, 0.14)
    inst.components.insulator.insulation = TUNING.INSULATION_SMALL

        elseif inst:HasTag("level6") then
	inst.components.talker:Say("-[兔子侦查帽(6级)]\n护甲值(15)\n速度上升\n保暖(小)")
    inst.components.armor:InitCondition(9999999999999999999999999999999999999999999999999999999999999, 0.15)
    inst.components.insulator.insulation = TUNING.INSULATION_SMALL

        elseif inst:HasTag("level7") then
	inst.components.talker:Say("-[兔子侦查帽(7级)]\n护甲值(16)\n速度上升\n保暖(小)")
    inst.components.armor:InitCondition(9999999999999999999999999999999999999999999999999999999999999, 0.16)
    inst.components.insulator.insulation = TUNING.INSULATION_SMALL

        elseif inst:HasTag("level8") then
	inst.components.talker:Say("-[兔子侦查帽(8级)]\n护甲值(17)\n速度上升\n保暖(小)")
    inst.components.armor:InitCondition(9999999999999999999999999999999999999999999999999999999999999, 0.17)
    inst.components.insulator.insulation = TUNING.INSULATION_SMALL

        elseif inst:HasTag("level9") then
	inst.components.talker:Say("-[兔子侦查帽(9级)]\n护甲值(18)\n速度上升\n保暖(小)")
    inst.components.armor:InitCondition(9999999999999999999999999999999999999999999999999999999999999, 0.18)
    inst.components.insulator.insulation = TUNING.INSULATION_SMALL

        elseif inst:HasTag("level10") then
	inst.components.talker:Say("-[兔子侦查帽(10级)]\n护甲值(19)\n速度上升\n保暖(中)")
    inst.components.armor:InitCondition(9999999999999999999999999999999999999999999999999999999999999, 0.19)
    inst.components.insulator.insulation = TUNING.INSULATION_MED

        elseif inst:HasTag("level11") then
   inst.components.equippable.walkspeedmult = 1.19
	inst.components.talker:Say("-[兔子侦查帽(11级)]\n护甲值(20)\n速度上升\n保暖(中)")
    inst.components.armor:InitCondition(9999999999999999999999999999999999999999999999999999999999999, 0.2)
    inst.components.insulator.insulation = TUNING.INSULATION_SMALL

        elseif inst:HasTag("level12") then
   inst.components.equippable.walkspeedmult = 1.20
	inst.components.talker:Say("-[兔子侦查帽(12级)]\n护甲值(21)\n速度上升\n保暖(中)")
    inst.components.armor:InitCondition(9999999999999999999999999999999999999999999999999999999999999, 0.21)
    inst.components.insulator.insulation = TUNING.INSULATION_SMALL

        elseif inst:HasTag("level13") then
   inst.components.equippable.walkspeedmult = 1.21
	inst.components.talker:Say("-[兔子侦查帽(13级)]\n护甲值(22)\n速度上升\n保暖(中)")
    inst.components.armor:InitCondition(9999999999999999999999999999999999999999999999999999999999999, 0.22)
    inst.components.insulator.insulation = TUNING.INSULATION_SMALL

        elseif inst:HasTag("level14") then
   inst.components.equippable.walkspeedmult = 1.22
	inst.components.talker:Say("-[兔子侦查帽(14级)]\n护甲值(23)\n速度上升\n保暖(中)")
    inst.components.armor:InitCondition(9999999999999999999999999999999999999999999999999999999999999, 0.23)
    inst.components.insulator.insulation = TUNING.INSULATION_SMALL

        elseif inst:HasTag("level15") then
   inst.components.equippable.walkspeedmult = 1.23
	inst.components.talker:Say("-[兔子侦查帽(15级)]\n护甲值(24)\n速度上升\n保暖(中)")
    inst.components.armor:InitCondition(9999999999999999999999999999999999999999999999999999999999999, 0.24)
    inst.components.insulator.insulation = TUNING.INSULATION_SMALL

        elseif inst:HasTag("level16") then
   inst.components.equippable.walkspeedmult = 1.24
	inst.components.talker:Say("-[兔子侦查帽(16级)]\n护甲值(25)\n速度上升\n保暖(中)")
    inst.components.armor:InitCondition(9999999999999999999999999999999999999999999999999999999999999, 0.25)
    inst.components.insulator.insulation = TUNING.INSULATION_SMALL

        elseif inst:HasTag("level17") then
   inst.components.equippable.walkspeedmult = 1.25
	inst.components.talker:Say("-[兔子侦查帽(17级)]\n护甲值(26)\n速度上升\n保暖(中)")
    inst.components.armor:InitCondition(9999999999999999999999999999999999999999999999999999999999999, 0.26)
    inst.components.insulator.insulation = TUNING.INSULATION_SMALL

        elseif inst:HasTag("level18") then
   inst.components.equippable.walkspeedmult = 1.26
	inst.components.talker:Say("-[兔子侦查帽(18级)]\n护甲值(27)\n速度上升\n保暖(中)")
    inst.components.armor:InitCondition(9999999999999999999999999999999999999999999999999999999999999, 0.27)
    inst.components.insulator.insulation = TUNING.INSULATION_SMALL

        elseif inst:HasTag("level19") then
   inst.components.equippable.walkspeedmult = 1.27
	inst.components.talker:Say("-[兔子侦查帽(19级)]\n护甲值(28)\n速度上升\n保暖(中)")
    inst.components.armor:InitCondition(9999999999999999999999999999999999999999999999999999999999999, 0.28)
    inst.components.insulator.insulation = TUNING.INSULATION_SMALL

        elseif inst:HasTag("level20") then
   inst.components.equippable.walkspeedmult = 1.28
	inst.components.talker:Say("-[兔子侦查帽(20级)]\n护甲值(29)\n速度上升\n保暖(大)")
    inst.components.armor:InitCondition(9999999999999999999999999999999999999999999999999999999999999, 0.29)
    inst.components.insulator.insulation = TUNING.INSULATION_LARGE

        elseif inst:HasTag("level21") then
   inst.components.equippable.walkspeedmult = 1.29
	inst.components.talker:Say("-[兔子侦查帽(21级)]\n护甲值(30)\n速度上升\n保暖(大)")
    inst.components.armor:InitCondition(9999999999999999999999999999999999999999999999999999999999999, 0.3)
    inst.components.insulator.insulation = TUNING.INSULATION_LARGE

        elseif inst:HasTag("level22") then
   inst.components.equippable.walkspeedmult = 1.3
	inst.components.talker:Say("-[兔子侦查帽(22级)]\n护甲值(31)\n速度上升\n保暖(大)")
    inst.components.armor:InitCondition(9999999999999999999999999999999999999999999999999999999999999, 0.31)
    inst.components.insulator.insulation = TUNING.INSULATION_LARGE

        elseif inst:HasTag("level23") then
   inst.components.equippable.walkspeedmult = 1.31
	inst.components.talker:Say("-[兔子侦查帽(23级)]\n护甲值(32)\n速度上升\n保暖(大)")
    inst.components.armor:InitCondition(9999999999999999999999999999999999999999999999999999999999999, 0.32)
    inst.components.insulator.insulation = TUNING.INSULATION_LARGE

        elseif inst:HasTag("level24") then
   inst.components.equippable.walkspeedmult = 1.32
	inst.components.talker:Say("-[兔子侦查帽(24级)]\n护甲值(33)\n速度上升\n保暖(大)")
    inst.components.armor:InitCondition(9999999999999999999999999999999999999999999999999999999999999, 0.33)
    inst.components.insulator.insulation = TUNING.INSULATION_LARGE

        elseif inst:HasTag("level25") then
   inst.components.equippable.walkspeedmult = 1.33
	inst.components.talker:Say("-[兔子侦查帽(25级)]\n护甲值(34)\n速度上升\n保暖(大)")
    inst.components.armor:InitCondition(9999999999999999999999999999999999999999999999999999999999999, 0.34)
    inst.components.insulator.insulation = TUNING.INSULATION_LARGE

        elseif inst:HasTag("level26") then
   inst.components.equippable.walkspeedmult = 1.34
	inst.components.talker:Say("-[兔子侦查帽(26级)]\n护甲值(35)\n速度上升\n保暖(大)")
    inst.components.armor:InitCondition(9999999999999999999999999999999999999999999999999999999999999, 0.35)
    inst.components.insulator.insulation = TUNING.INSULATION_LARGE

        elseif inst:HasTag("level27") then
   inst.components.equippable.walkspeedmult = 1.35
	inst.components.talker:Say("-[兔子侦查帽(27级)]\n护甲值(36)\n速度上升\n保暖(大)")
    inst.components.armor:InitCondition(9999999999999999999999999999999999999999999999999999999999999, 0.36)
    inst.components.insulator.insulation = TUNING.INSULATION_LARGE

        elseif inst:HasTag("level28") then
   inst.components.equippable.walkspeedmult = 1.36
	inst.components.talker:Say("-[兔子侦查帽(28级)]\n护甲值(37)\n速度上升\n保暖(大)")
    inst.components.armor:InitCondition(9999999999999999999999999999999999999999999999999999999999999, 0.37)
    inst.components.insulator.insulation = TUNING.INSULATION_LARGE

        elseif inst:HasTag("level29") then
   inst.components.equippable.walkspeedmult = 1.37
	inst.components.talker:Say("-[兔子侦查帽(29级)]\n护甲值(38)\n速度上升\n保暖(大)")
    inst.components.armor:InitCondition(9999999999999999999999999999999999999999999999999999999999999, 0.38)
    inst.components.insulator.insulation = TUNING.INSULATION_LARGE

        elseif inst:HasTag("level30") then
   inst.components.equippable.walkspeedmult = 1.4
	inst.components.talker:Say("-[兔子侦查帽(满级30级)]\n护甲值(40)\n速度上升\n保暖(大)")
    inst.components.armor:InitCondition(9999999999999999999999999999999999999999999999999999999999999, 0.4)
    inst.components.insulator.insulation = TUNING.INSULATION_LARGE

------
end
end
end

-------- --------
local function TakeItem(inst, item, data)
local expchance0 = 1
local expchance1 = 0.3
local expchance2 = 0.2
local expchance3 = 0.12
	inst.components.fueled:DoDelta(5000000)
	SpawnPrefab("splash").Transform:SetPosition(inst:GetPosition():Get())
inst:RemoveTag ("broken")     
UpgradeArmor(inst)
   if math.random() < expchance1 and inst.level <= 4005 then
	inst.level = inst.level + 2
	levelexp(inst)
	inst.components.talker:Say("幸运点数 ! +(2)\n[成长点数]".. (inst.level))
    elseif  math.random() < expchance2 and inst.level <= 4005 then
	inst.level = inst.level + 5
	levelexp(inst)
	inst.components.talker:Say("幸运点数 ! +(5)\n[成长点数]".. (inst.level))
	elseif  math.random() < expchance3 and inst.level <= 4005 then
	inst.level = inst.level + 8
	levelexp(inst)
	inst.components.talker:Say("幸运点数 ! +(8)\n[成长点数]".. (inst.level))
	elseif  math.random() < expchance0 and inst.level <= 4005 then
	inst.level = inst.level + 1
	levelexp(inst)
    end
end

local function OnLoad(inst, data)
    UpgradeArmor(inst)
end

    local function onequip(inst, owner, fname_override)
   inst:AddTag("talkf")
    UpgradeArmor(inst)
inst.components.fueled:StartConsuming()        

if inst:HasTag("gogleoff") then
        owner.AnimState:OverrideSymbol("swap_hat", "hat_mbunny", "swap_hat")
        owner.AnimState:Show("HAT")
        owner.AnimState:Hide("HAT_HAIR")
        owner.AnimState:Hide("HAIR_NOHAT")
        owner.AnimState:Hide("HAIR")
            owner.AnimState:Hide("HEAD")
            owner.AnimState:Show("HEAD_HAIR")
elseif not inst:HasTag("gogleoff") then
        owner.AnimState:OverrideSymbol("swap_hat", "hat_mbunny2", "swap_hat")
        owner.AnimState:Show("HAT")
        owner.AnimState:Hide("HAT_HAIR")
        owner.AnimState:Hide("HAIR_NOHAT")
        owner.AnimState:Hide("HAIR")
            owner.AnimState:Hide("HEAD")
            owner.AnimState:Show("HEAD_HAIR")
        end

    inst.expfn = function(attacked, data)
local expchance = 0.5
local damagedur1 = 0.2
local damagedur2 = 0.5
local damagedur3 = 0.7
local damagedur4 = 1


if data and data.attacker and math.random() < damagedur1 then
inst.components.fueled:DoDelta(-150000)
elseif data and data.attacker and math.random() < damagedur2 then
inst.components.fueled:DoDelta(-100000)
elseif data and data.attacker and math.random() < damagedur3 then
inst.components.fueled:DoDelta(-50000)
elseif data and data.attacker and math.random() < damagedur4 then
inst.components.fueled:DoDelta(-50000)

end
if data and data.attacker and math.random() < expchance and inst.level < 4010 then

inst.components.fueled:DoDelta(-50000)
	inst.level = inst.level + 1
			levelexp(inst)

		end 
	    end

    inst:ListenForEvent("attacked", inst.expfn, owner)

end

    local function onunequip(inst, owner)
   inst:RemoveTag("talkf")
    UpgradeArmor(inst)
	inst:AddTag("gogleoff") 
inst.components.fueled:StopConsuming()        
    inst:RemoveEventCallback("attacked", inst.expfn, owner)
    if inst.task then inst.task:Cancel() inst.task = nil end

        owner.AnimState:Hide("HAT")
        owner.AnimState:Hide("HAT_HAIR")
        owner.AnimState:Show("HAIR_NOHAT")
        owner.AnimState:Show("HAIR")

        if owner:HasTag("player") then
            owner.AnimState:Show("HEAD")
            owner.AnimState:Hide("HEAD_HAIR")
        end
    end

local function consume(inst, owner)
if not inst:HasTag("broken") then
inst.components.fueled:DoDelta(-50000)
end
end

  local function gogleon(inst, data, owner, fname_override)
local player = GetPlayer()
        local owner = inst.components.inventoryitem.owner
if owner and inst:HasTag("broken") then
	inst:AddTag("gogleoff") 
	player.components.talker:Say("兔子帽破了 !")
	inst.components.talker:Say("-[兔子侦查帽]\n耐久度 (0)\n速度上升 (0)")
    inst.components.equippable.walkspeedmult = 1
        owner.AnimState:OverrideSymbol("swap_hat", "hat_mbunny", "swap_hat")
        owner.AnimState:Show("HAT")
        owner.AnimState:Hide("HAT_HAIR")
        owner.AnimState:Hide("HAIR_NOHAT")
        owner.AnimState:Hide("HAIR")
            owner.AnimState:Hide("HEAD")
            owner.AnimState:Show("HEAD_HAIR")
        inst.components.useableitem:StopUsingItem()
end
if owner and inst:HasTag("gogleoff") and not inst:HasTag("broken") then
	player.components.talker:Say("戴上护目镜 !")
    inst.task = inst:DoPeriodicTask(1, function() consume(inst, owner) end)

        owner.AnimState:OverrideSymbol("swap_hat", "hat_mbunny2", "swap_hat")
        owner.AnimState:Show("HAT")
        owner.AnimState:Hide("HAT_HAIR")
        owner.AnimState:Hide("HAIR_NOHAT")
        owner.AnimState:Hide("HAIR")
            owner.AnimState:Hide("HEAD")
            owner.AnimState:Show("HEAD_HAIR")

        if inst:HasTag("level1")then
	inst.components.talker:Say("-[兔子侦查兵]\n速度上升(15)\n(1级)")
    inst.components.equippable.walkspeedmult = 1.15
	inst:RemoveTag("gogleoff") 

        elseif inst:HasTag("level2") then
	inst.components.talker:Say("-[兔子侦查兵]\n速度上升(16)\n(2级)")
    inst.components.equippable.walkspeedmult = 1.16
	inst:RemoveTag("gogleoff") 

        elseif inst:HasTag("level3") then
	inst.components.talker:Say("-[兔子侦查兵]\n速度上升(17)\n(3级)")
    inst.components.equippable.walkspeedmult = 1.17
	inst:RemoveTag("gogleoff") 

        elseif inst:HasTag("level4") then
	inst.components.talker:Say("-[兔子侦查兵]\n速度上升(18)\n(4级)")
    inst.components.equippable.walkspeedmult = 1.18
	inst:RemoveTag("gogleoff") 

        elseif inst:HasTag("level5") then
	inst.components.talker:Say("-[兔子侦查兵]\n速度上升(19)\n(5级)")
    inst.components.equippable.walkspeedmult = 1.19
	inst:RemoveTag("gogleoff") 

        elseif inst:HasTag("level6") then
	inst.components.talker:Say("-[兔子侦查兵]\n速度上升(20)\n(6级)")
   inst.components.equippable.walkspeedmult = 1.20
	inst:RemoveTag("gogleoff") 

        elseif inst:HasTag("level7") then
   inst.components.equippable.walkspeedmult = 1.21
	inst.components.talker:Say("-[兔子侦查兵]\n速度上升(21)\n(7级)")
	inst:RemoveTag("gogleoff") 

        elseif inst:HasTag("level8") then
   inst.components.equippable.walkspeedmult = 1.22
	inst.components.talker:Say("-[兔子侦查兵]\n速度上升(22)\n(8级)")
	inst:RemoveTag("gogleoff") 

        elseif inst:HasTag("level9") then
   inst.components.equippable.walkspeedmult = 1.23
	inst.components.talker:Say("-[兔子侦查兵]\n速度上升(23)\n(9级)")
	inst:RemoveTag("gogleoff") 

        elseif inst:HasTag("level10") then
   inst.components.equippable.walkspeedmult = 1.24
	inst.components.talker:Say("-[兔子侦查兵]\n速度上升(24)\n(10级)")
	inst:RemoveTag("gogleoff") 

        elseif inst:HasTag("level11") then
   inst.components.equippable.walkspeedmult = 1.25
	inst.components.talker:Say("-[兔子侦查兵]\n速度上升(25)\n(11级)")
	inst:RemoveTag("gogleoff") 

        elseif inst:HasTag("level12") then
   inst.components.equippable.walkspeedmult = 1.26
	inst.components.talker:Say("-[兔子侦查兵]\n速度上升(26)\n(12级)")
	inst:RemoveTag("gogleoff") 

        elseif inst:HasTag("level13") then
   inst.components.equippable.walkspeedmult = 1.27
	inst.components.talker:Say("-[兔子侦查兵]\n速度上升(27)\n(13级)")
	inst:RemoveTag("gogleoff") 

        elseif inst:HasTag("level14") then
   inst.components.equippable.walkspeedmult = 1.28
	inst.components.talker:Say("-[兔子侦查兵]\n速度上升(28)\n(14级)")
	inst:RemoveTag("gogleoff") 

        elseif inst:HasTag("level15") then
   inst.components.equippable.walkspeedmult = 1.29
	inst.components.talker:Say("-[兔子侦查兵]\n速度上升(29)\n(15级)")
	inst:RemoveTag("gogleoff") 

        elseif inst:HasTag("level16") then
   inst.components.equippable.walkspeedmult = 1.30
	inst.components.talker:Say("-[兔子侦查兵]\n速度上升(30)\n(16级)")
	inst:RemoveTag("gogleoff") 

        elseif inst:HasTag("level17") then
   inst.components.equippable.walkspeedmult = 1.31
	inst.components.talker:Say("-[兔子侦查兵]\n速度上升(31)\n(17级)")
	inst:RemoveTag("gogleoff") 

        elseif inst:HasTag("level18") then
   inst.components.equippable.walkspeedmult = 1.32
	inst.components.talker:Say("-[兔子侦查兵]\n速度上升(32)\n(18级)")
	inst:RemoveTag("gogleoff") 

        elseif inst:HasTag("level19") then
   inst.components.equippable.walkspeedmult = 1.33
	inst.components.talker:Say("-[兔子侦查兵]\n速度上升(33)\n(19级)")
	inst:RemoveTag("gogleoff") 

        elseif inst:HasTag("level20") then
   inst.components.equippable.walkspeedmult = 1.34
	inst.components.talker:Say("-[兔子侦查兵]\n速度上升(34)\n(20级)")
	inst:RemoveTag("gogleoff") 

        elseif inst:HasTag("level21") then
   inst.components.equippable.walkspeedmult = 1.35
	inst.components.talker:Say("-[兔子侦查兵]\n速度上升(35)\n(21级)")
	inst:RemoveTag("gogleoff") 

        elseif inst:HasTag("level22") then
   inst.components.equippable.walkspeedmult = 1.36
	inst.components.talker:Say("-[兔子侦查兵]\n速度上升(36)\n(22级)")
	inst:RemoveTag("gogleoff") 

        elseif inst:HasTag("level23") then
   inst.components.equippable.walkspeedmult = 1.37
	inst.components.talker:Say("-[兔子侦查兵]\n速度上升(37)\n(23级)")
	inst:RemoveTag("gogleoff") 

        elseif inst:HasTag("level24") then
   inst.components.equippable.walkspeedmult = 1.38
	inst.components.talker:Say("-[兔子侦查兵]\n速度上升(38)\n(24级)")
	inst:RemoveTag("gogleoff") 

        elseif inst:HasTag("level25") then
   inst.components.equippable.walkspeedmult = 1.39
	inst.components.talker:Say("-[兔子侦查兵]\n速度上升(39)\n(25级)")
	inst:RemoveTag("gogleoff") 

        elseif inst:HasTag("level26") then
   inst.components.equippable.walkspeedmult = 1.40
	inst.components.talker:Say("-[兔子侦查兵]\n速度上升(40)\n(26级)")
	inst:RemoveTag("gogleoff") 

        elseif inst:HasTag("level27") then
   inst.components.equippable.walkspeedmult = 1.41
	inst.components.talker:Say("-[兔子侦查兵]\n速度上升(41)\n(27级)")
	inst:RemoveTag("gogleoff") 

        elseif inst:HasTag("level28") then
   inst.components.equippable.walkspeedmult = 1.42
	inst.components.talker:Say("-[兔子侦查兵]\n速度上升(42)\n(28级)")
	inst:RemoveTag("gogleoff") 

        elseif inst:HasTag("level29") then
   inst.components.equippable.walkspeedmult = 1.43
	inst.components.talker:Say("-[兔子侦查兵]\n速度上升(43)\n(29级)")
	inst:RemoveTag("gogleoff") 

        elseif inst:HasTag("level30") then
   inst.components.equippable.walkspeedmult = 1.45
	inst.components.talker:Say("-[兔子侦查兵]\n速度上升(45)\n(30级)")
	inst:RemoveTag("gogleoff") 

end
        inst.components.useableitem:StopUsingItem()

-----------
elseif owner and not inst:HasTag("gogleoff") and not inst:HasTag("broken") then
	inst:AddTag("gogleoff") 
	player.components.talker:Say("拿下护目镜 !")
	inst.components.talker:Say("-[兔子侦查兵]\n速度上升(10)\n(基础值)")
    if inst.task then inst.task:Cancel() inst.task = nil end
    inst.components.equippable.walkspeedmult = 1.1

        owner.AnimState:OverrideSymbol("swap_hat", "hat_mbunny", "swap_hat")
        owner.AnimState:Show("HAT")
        owner.AnimState:Hide("HAT_HAIR")
        owner.AnimState:Hide("HAIR_NOHAT")
        owner.AnimState:Hide("HAIR")
            owner.AnimState:Hide("HEAD")
            owner.AnimState:Show("HEAD_HAIR")
        inst.components.useableitem:StopUsingItem()
end
end

---------------hat fn sim
	
local function fn(Sim)
	local inst = CreateEntity()
	local trans = inst.entity:AddTransform()
	local anim = inst.entity:AddAnimState()

    MakeInventoryPhysics(inst)
    
    inst:AddTag("hat")

    anim:SetBank("beehat")
    anim:SetBuild("hat_mbunny")

    anim:PlayAnimation("anim")    
        
    inst:AddComponent("inspectable")
    	
    inst:AddComponent("inventoryitem")
    inst.components.inventoryitem.atlasname = "images/inventoryimages/hat_mbunny.xml"

   inst:AddComponent("armor")
    inst.components.armor:InitCondition(9999999999999999999999999999999999999999999999999999999999999, 0.15)

inst:AddTag("gogleoff") 
inst:AddTag("level1")

            inst:AddComponent("useableitem")
     inst.components.useableitem:SetOnUseFn(gogleon)
        inst:AddComponent("equippable")
        inst.components.equippable.equipslot = EQUIPSLOTS.HEAD
        inst.components.equippable:SetOnEquip( onequip )
        inst.components.equippable:SetOnUnequip( onunequip )
    inst.components.equippable.walkspeedmult = 1.1

        inst:AddComponent("insulator")
        inst.components.insulator.insulation = TUNING.INSULATION_MED

    inst:AddComponent("talker")
    inst.components.talker.fontsize = 19
    inst.components.talker.font = TALKINGFONT
    inst.components.talker.colour = Vector3(0.8, 1, 0.65, 1)
    inst.components.talker.offset = Vector3(-200,-220,0)
    inst.components.talker.symbol = "swap_object"

	inst.level = 0
inst:ListenForEvent("levelup", levelexp)
	inst.OnSave = onsave
	inst.OnPreLoad = onpreload

        inst:AddComponent("fueled")
       inst.components.fueled.fueltype = "CHEMICAL"
        inst.components.fueled:InitializeFuelLevel(20000000)
       inst.components.fueled:SetDepletedFn(OnDurability)
        inst.components.fueled.ontakefuelfn = TakeItem
        inst.components.fueled.accepting = true
inst.components.fueled:StartConsuming()        

    return inst
end
---------------------------------
return Prefab( "common/inventory/hat_mbunny", fn, assets ) 
