local assets =
{
    Asset("ANIM", "anim/downvest_blue77.zip"),  --对应在anim里面的文件 加载动画文件
	Asset("ATLAS", "inventoryimages/downvest_blue77.xml"), --加载物品栏贴图
    Asset("IMAGE", "inventoryimages/downvest_blue77.tex"),
}

local function OnBlocked(owner, data)
    owner.SoundEmitter:PlaySound("dontstarve/wilson/hit_armour")
end

local function freezefn(attacked,data)
	if data and data.attacker and data.attacker.components.freezable then
        data.attacker.components.freezable:AddColdness(1.5)
        data.attacker.components.freezable:SpawnShatterFX()
    end
end

local function onequip(inst, owner) --装备
	owner.AnimState:OverrideSymbol("swap_body", "downvest_blue77", "swap_body")
  inst:ListenForEvent("attacked", freezefn, owner)
  inst:ListenForEvent("blocked", OnBlocked, owner)
end

local function onunequip(inst, owner)  --脱下
    owner.AnimState:ClearOverrideSymbol("swap_body")
    inst:RemoveEventCallback("blocked", OnBlocked, owner)
    inst:RemoveEventCallback("attacked", freezefn, owner)
end

local function fn()
    local inst = CreateEntity()

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

    MakeInventoryPhysics(inst)

    inst.AnimState:SetBank("downvest_blue77") --动画
    inst.AnimState:SetBuild("downvest_blue77")
    inst.AnimState:PlayAnimation("anim")	--丢地上的动画

    inst:AddComponent("heater")
    inst.components.heater.iscooler = true
  	inst.components.heater.carriedheat=TUNING.BLUEGEM_COOLER
    inst.components.heater.equippedheat = TUNING.BLUEGEM_COOLER*2

    inst:AddTag("wood")

    inst.foleysound = "dontstarve/movement/foley/logarmour"

    inst.entity:SetPristine()

    if not TheWorld.ismastersim then
        return inst
    end

    inst:AddComponent("inspectable") --可悲检查组件

    inst:AddComponent("inventoryitem")
	inst.components.inventoryitem.atlasname = "inventoryimages/downvest_blue77.xml"  --加载物品栏贴图 mod物品必须有

	inst:AddComponent("waterproofer")  --防雨组件  （括号里面可以直接填数字）
    inst.components.waterproofer:SetEffectiveness(TUNING.WATERPROOFNESS_ABSOLUTE)

	inst:AddComponent("insulator") --温度隔绝组件（括号里可以直接天数字就是保温多少秒）
    inst.components.insulator:SetInsulation(240)

	inst:AddComponent("fuel")--燃料 组件
    inst.components.fuel.fuelvalue = TUNING.LARGE_FUEL

    MakeSmallBurnable(inst, TUNING.SMALL_BURNTIME) --燃烧有关
    MakeSmallPropagator(inst)

    inst:AddComponent("armor")--护甲组件
    inst.components.armor:InitCondition(1500,0.9) --耐久度和减伤（90%）
    inst.components.armor:AddWeakness("beaver", TUNING.BEAVER_WOOD_DAMAGE)

    inst:AddComponent("equippable") --装备组件
    inst.components.equippable.equipslot = EQUIPSLOTS.BODY --装备的部位是身体
    inst.components.equippable.walkspeedmult = 1.25--這是裝備後可以加速

    inst.components.equippable:SetOnEquip(onequip)
    inst.components.equippable:SetOnUnequip(onunequip)

    MakeHauntableLaunch(inst)

    return inst
end

return Prefab("downvest_blue77", fn, assets) --生成这个预设物  代码为 downvest_gray77
