晨星相关代码如下:
inst:AddComponent("fueled")
inst.components.fueled:SetSectionCallback(
function(section)
if section == 0 then
--when we burn out
if inst.components.burnable then
inst.components.burnable:Extinguish()
end
if inst.components.inventoryitem and inst.components.inventoryitem:IsHeld() then
local owner = inst.components.inventoryitem.owner
inst:Remove()
if owner then
owner:PushEvent("nightstickranout", {nightstick = inst})
end
end
end
end)
inst.components.fueled:InitializeFuelLevel(TUNING.NIGHTSTICK_FUEL)
inst.components.fueled:SetDepletedFn(function(inst) inst:Remove() end)