Definition
-- @/lua/vehicle/beamstate.lua:1270
-- only being called if the beam has deform triggers
local function onBeamDeformed(id, ratio)
--log('D', "beamstate.beamDeformed","beam "..id.." deformed with ratio "..ratio)
beamDamageTracker[id] = ratio
beamDamageTrackerDirty = true
local bodyPart = beamBodyPartLookup[id]
if bodyPart then
bodyPartDamageTracker[bodyPart] = bodyPartDamageTracker[bodyPart] + ratio
local damage = bodyPartDamageTracker[bodyPart] * invBodyPartBeamCount[bodyPart]
if damage > 0.001 then
damageTracker.setDamage("body", bodyPart, damage)
end
end
local b = v.data.beams[id]
if b then
if b.partPath and partDamageData[b.partPath] then
partDamageData[b.partPath].beamsDeformed = partDamageData[b.partPath].beamsDeformed + 1
end
if b.deformSwitches then
material.switchBrokenMaterial(b)
end
local deformGroup = b.deformGroup
if deformGroup then
if type(deformGroup) == "table" then
for _, g in ipairs(deformGroup) do
M.deformGroupsTriggerBeam[g] = M.deformGroupsTriggerBeam[g] or b.cid
local group = M.deformGroupDamage[g]
group.eventCount = group.eventCount + 1
group.damage = group.eventCount * group.invMaxEvents
end
else
M.deformGroupsTriggerBeam[deformGroup] = M.deformGroupsTriggerBeam[deformGroup] or b.cid
local group = M.deformGroupDamage[deformGroup]
group.eventCount = group.eventCount + 1
group.damage = group.eventCount * group.invMaxEvents
end
end
end
end
Callers
@/lua/vehicle/main.lua
-- only being called if the beam has deform triggers
function onBeamDeformed(id, ratio)
beamstate.onBeamDeformed(id, ratio)
function onBeamDeformed(id, ratio)
beamstate.onBeamDeformed(id, ratio)
controller.beamDeformed(id, ratio)
@/lua/objectpool/main.lua
function onBeamDeformed(id, ratio)
end
@/lua/vehicle/beamstate.lua
--print('deformed: ' .. tostring(cid) .. ' = ' .. tostring(beam[3]))
onBeamDeformed(cid, beam[3])
end