Added an option to lock/unlock physical position and rotation at once

This commit is contained in:
penolakushari 2024-11-03 07:02:32 +03:00
parent 82ecfe24fc
commit bb67e6e6b8
4 changed files with 36 additions and 6 deletions

View File

@ -1244,6 +1244,7 @@ local FeaturesPhys = {
{ 8, (language.GetPhrase("tool.ragdollmover.resetmenu") .. " " .. language.GetPhrase("tool.ragdollmover.resetscalechildren")), 1 }, -- 8
{ 9, (language.GetPhrase("tool.ragdollmover.scalezero") .. " " .. language.GetPhrase("tool.ragdollmover.bone")), 2 }, -- 9
{ 10, (language.GetPhrase("tool.ragdollmover.scalezero") .. " " .. language.GetPhrase("tool.ragdollmover.bonechildren")), 2 }, -- 10
{ 19, { "#tool.ragdollmover.unlockall", "#tool.ragdollmover.lockall" }, 3 }, -- 19
{ 12, { "#tool.ragdollmover.unlockpos", "#tool.ragdollmover.lockpos" }, 3 }, -- 12
{ 13, { "#tool.ragdollmover.unlockang", "#tool.ragdollmover.lockang" }, 3}, -- 13
{ 15, { "#tool.ragdollmover.unlockscale", "#tool.ragdollmover.lockscale" }, 3 }, --15
@ -1365,6 +1366,8 @@ function AdvBoneSelectRadialRender(ent, bones, bonenodes, isresetmode)
name = bonenodes[ent][bone].anglock and name[1] or name[2]
elseif id == 15 then
name = bonenodes[ent][bone].scllock and name[1] or name[2]
elseif id == 19 then
name = ( bonenodes[ent][bone].poslock and bonenodes[ent][bone].anglock ) and name[1] or name[2]
end
end

View File

@ -763,24 +763,32 @@ local NETFUNC = {
end
local plTable = RAGDOLLMOVER[pl]
if mode == 1 then
if mode == 0 then
if not plTable.rgmPosLocks[ent][boneid] then
plTable.rgmPosLocks[ent][boneid] = ent:GetPhysicsObjectNum(physbone)
else
plTable.rgmPosLocks[ent][boneid] = nil
end
elseif mode == 2 then
elseif mode == 1 then
if not plTable.rgmAngLocks[ent][boneid] then
plTable.rgmAngLocks[ent][boneid] = ent:GetPhysicsObjectNum(physbone)
else
plTable.rgmAngLocks[ent][boneid] = nil
end
elseif mode == 3 then
elseif mode == 2 then
if not plTable.rgmScaleLocks[ent][bone] then
plTable.rgmScaleLocks[ent][bone] = true
else
plTable.rgmScaleLocks[ent][bone] = false
end
elseif mode == 3 then
if not plTable.rgmPosLocks[ent][boneid] or not plTable.rgmAngLocks[ent][boneid] then
plTable.rgmPosLocks[ent][boneid] = ent:GetPhysicsObjectNum(physbone)
plTable.rgmAngLocks[ent][boneid] = ent:GetPhysicsObjectNum(physbone)
else
plTable.rgmPosLocks[ent][boneid] = nil
plTable.rgmAngLocks[ent][boneid] = nil
end
end
local poslock, anglock, scllock = IsValid(plTable.rgmPosLocks[ent][boneid]), IsValid(plTable.rgmAngLocks[ent][boneid]), plTable.rgmScaleLocks[ent][bone]
@ -3332,7 +3340,7 @@ local NodeFunctions = {
net.Start("RAGDOLLMOVER")
net.WriteUInt(5, 5)
net.WriteEntity(ent)
net.WriteUInt(1, 2)
net.WriteUInt(0, 2)
net.WriteUInt(id, 10)
net.SendToServer()
end,
@ -3341,7 +3349,7 @@ local NodeFunctions = {
net.Start("RAGDOLLMOVER")
net.WriteUInt(5, 5)
net.WriteEntity(ent)
net.WriteUInt(2, 2)
net.WriteUInt(1, 2)
net.WriteUInt(id, 10)
net.SendToServer()
end,
@ -3384,7 +3392,7 @@ local NodeFunctions = {
net.Start("RAGDOLLMOVER")
net.WriteUInt(5, 5)
net.WriteEntity(ent)
net.WriteUInt(3, 2)
net.WriteUInt(2, 2)
net.WriteUInt(id, 10)
net.SendToServer()
end,
@ -3412,6 +3420,15 @@ local NodeFunctions = {
function() -- 18 nodeResetGizmo
RGMResetGizmo()
end,
function(ent, id) -- 19 nodeAllPhysLock
net.Start("RAGDOLLMOVER")
net.WriteUInt(5, 5)
net.WriteEntity(ent)
net.WriteUInt(3, 2)
net.WriteUInt(id, 10)
net.SendToServer()
end
}
@ -3581,6 +3598,12 @@ local function SetBoneNodes(bonepanel, sortedbones)
bonemenu:AddSpacer()
elseif nodes[ent][v.id].Type == BONE_PHYSICAL and IsValid(ent) and ( ent:GetClass() == "prop_ragdoll" or IsPropRagdoll ) then
option = bonemenu:AddOption(( nodes[ent][v.id].poslock and nodes[ent][v.id].anglock ) and "#tool.ragdollmover.unlockall" or "#tool.ragdollmover.lockall", function()
if not IsValid(ent) then return end
NodeFunctions[19](ent, v.id)
end)
option:SetIcon(( nodes[ent][v.id].poslock and nodes[ent][v.id].anglock ) and "icon16/lock.png" or "icon16/brick.png")
option = bonemenu:AddOption(nodes[ent][v.id].poslock and "#tool.ragdollmover.unlockpos" or "#tool.ragdollmover.lockpos", function()
if not IsValid(ent) then return end
NodeFunctions[12](ent, v.id)

View File

@ -90,6 +90,8 @@ tool.ragdollmover.scalezero=Scale to Zero
tool.ragdollmover.bone=Bone
tool.ragdollmover.bonechildren=Bone + Children
tool.ragdollmover.lockall=Lock Pos/Rot
tool.ragdollmover.unlockall=Unlock Pos/Rot
tool.ragdollmover.lockpos=Lock Position
tool.ragdollmover.unlockpos=Unlock Position
tool.ragdollmover.lockang=Lock Rotation

View File

@ -90,6 +90,8 @@ tool.ragdollmover.scalezero=Установить нулевой размер
tool.ragdollmover.bone=Кости
tool.ragdollmover.bonechildren=Кости + Потомков
tool.ragdollmover.lockall=Заблокировать позицию и поворот
tool.ragdollmover.unlockall=Разблокировать позицию и поворот
tool.ragdollmover.lockpos=Заблокировать позицию
tool.ragdollmover.unlockpos=Разблокировать позицию
tool.ragdollmover.lockang=Заблокировать поворот