fix FallApartOnDeath messing with other players

This commit is contained in:
Yagira 2022-04-30 12:48:22 +02:00
parent be5a1c7625
commit 3849b6b9e8
2 changed files with 13 additions and 1 deletions

View File

@ -34,7 +34,7 @@ do
if not IsEntity(ply) or not ply:IsValid() then return end
if ply.pac_death_physics_parts and ply:Alive() and ply.pac_physics_died then
pac.CallRecursiveOnAllParts("OnBecomePhysics")
pac.CallRecursiveOnOwnedParts(ply, "OnBecomePhysics")
ply.pac_physics_died = false
end

View File

@ -592,6 +592,18 @@ function pac.CallRecursiveOnAllParts(func_name, ...)
end
end
function pac.CallRecursiveOnOwnedParts(ent, func_name, ...)
local owned_parts = parts_from_ent(ent)
for _, part in pairs(owned_parts) do
if part[func_name] then
local ret = part[func_name](part, ...)
if ret ~= nil then
return ret
end
end
end
end
function pac.EnablePartsByClass(classname, enable)
for _, part in pairs(all_parts) do
if part.ClassName == classname then