Merge pull request #65 from penolakushari/master

Additional gizmo enhancements (#13)
This commit is contained in:
penolakushari 2025-01-22 23:42:38 +03:00 committed by GitHub
commit b4d912d59b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 30 additions and 3 deletions

View File

@ -16,6 +16,31 @@ local TYPE_BOOL = 5
RAGDOLLMOVER = {}
local shouldCallHook = false
hook.Add("EntityKeyValue", "RGMAllowTool", function(ent, key, val)
-- I couldn't find a clean, direct way to add ragdollmover to the m_tblToolsAllowed for both
-- loading into a map or loading a save on the same map.
if key == "gmod_allowtools" and not string.find(val, "ragdollmover") then
shouldCallHook = true
end
-- We can't call the hook at the same time the key is gmod_allowtools because ent.m_tblToolsAllowed
-- must exist (which relies on the gmod_allowtools key), but it doesn't yet
if shouldCallHook and key ~= "gmod_allowtools" then
hook.Run("RGMAllowTool", ent)
shouldCallHook = false
end
end)
-- Some brush entities only allow a select number of tools (see https://wiki.facepunch.com/gmod/Sandbox_Specific_Mapping)
-- Without this, the gizmos would not be "selectable"
hook.Add("RGMAllowTool", "RGMAllowTool", function(ent)
-- If the table is not filled, we don't want to insert it, as it would make other tools not work
if istable(ent.m_tblToolsAllowed) and #ent.m_tblToolsAllowed > 0 then
table.insert(ent.m_tblToolsAllowed, "ragdollmover")
end
end)
if SERVER then
util.AddNetworkString("RAGDOLLMOVER_META")
@ -43,6 +68,7 @@ hook.Add("PlayerDisconnected", "RGMCleanupGizmos", function(pl)
RAGDOLLMOVER[pl] = nil
end)
local NumpadBindRot, NumpadBindScale = {}, {}
local RotKey, ScaleKey = {}, {}
local rgmMode = {}

View File

@ -10,6 +10,7 @@ function ENT:Initialize()
self:DrawShadow(false)
self:SetCollisionBounds(-self.DefaultMinMax, self.DefaultMinMax)
self:SetMoveType(MOVETYPE_VPHYSICS)
self:SetSolid(SOLID_VPHYSICS)
self:SetNotSolid(true)

View File

@ -1851,7 +1851,7 @@ function TOOL:Deploy()
end
local function EntityFilter(ent, tool)
return (ent:GetClass() == "prop_ragdoll" or ent:GetClass() == "prop_physics" or ent:GetClass() == "prop_effect") or (tool:GetClientNumber("disablefilter") ~= 0 and not ent:IsWorld())
return ent:GetBrushPlaneCount() == 0 and ((ent:GetClass() == "prop_ragdoll" or ent:GetClass() == "prop_physics" or ent:GetClass() == "prop_effect") or (tool:GetClientNumber("disablefilter") ~= 0 and not ent:IsWorld()))
end
function TOOL:LeftClick()
@ -2225,7 +2225,7 @@ function TOOL:Reload()
end
function TOOL:Think()
function TOOL:Think()
if SERVER then
@ -2235,7 +2235,7 @@ if SERVER then
if CurTime() < self.LastThink + (RAGDOLLMOVER[pl].updaterate or 0.01) then return end
local plTable = RAGDOLLMOVER[pl]
local ent = plTable.Entity
local axis = plTable.Axis