mirror of
https://github.com/CapsAdmin/pac3.git
synced 2025-03-04 03:03:01 -05:00
display is_touching as well + permanently display
unless a different part was selected
This commit is contained in:
parent
04c0e4346d
commit
b1bf11ba79
@ -496,7 +496,7 @@ PART.OldEvents = {
|
||||
else
|
||||
local classname = parent:GetNiceName()
|
||||
local name = parent:GetName()
|
||||
self:SetWarning(("ranger doesn't work on [%s] %s"):format(classnname, classname ~= name and "(" .. name .. ")" or ""))
|
||||
self:SetWarning(("ranger doesn't work on [%s] %s"):format(classname, classname ~= name and "(" .. name .. ")" or ""))
|
||||
end
|
||||
end,
|
||||
},
|
||||
@ -532,6 +532,7 @@ PART.OldEvents = {
|
||||
|
||||
is_touching = {
|
||||
arguments = {{extra_radius = "number"}},
|
||||
userdata = {{editor_panel = "is_touching", is_touching_property = "extra_radius"}},
|
||||
callback = function(self, ent, extra_radius)
|
||||
extra_radius = extra_radius or 0
|
||||
|
||||
@ -556,20 +557,6 @@ PART.OldEvents = {
|
||||
mins = mins,
|
||||
filter = ent
|
||||
} )
|
||||
|
||||
--[[
|
||||
|
||||
|
||||
if tr.Hit then
|
||||
debugoverlay.Text(tr.HitPos, "hit!", 1, false)
|
||||
end
|
||||
|
||||
cam.IgnoreZ(true)
|
||||
render.DrawWireframeBox( startpos, Angle( 0, 0, 0 ), mins, maxs, tr.Hit and Color(255,0,0) or Color(255,255,255), true )
|
||||
cam.IgnoreZ(false)
|
||||
|
||||
]]
|
||||
|
||||
return tr.Hit
|
||||
end,
|
||||
},
|
||||
|
@ -663,11 +663,12 @@ do -- event ranger
|
||||
hook.Remove("PostDrawOpaqueRenderables", "pace_draw_ranger")
|
||||
end
|
||||
|
||||
local time = os.clock() + 3
|
||||
local last_part = pace.current_part
|
||||
|
||||
hook.Add("PostDrawOpaqueRenderables", "pace_draw_ranger", function()
|
||||
local part = pace.current_part
|
||||
if not part:IsValid() then stop() return end
|
||||
if part ~= last_part then stop() return end
|
||||
if part.ClassName ~= "event" then stop() return end
|
||||
if part:GetEvent() ~= "ranger" then stop() return end
|
||||
|
||||
@ -688,13 +689,64 @@ do -- event ranger
|
||||
endpos = startpos + parent:GetWorldAngles():Forward() * compare
|
||||
color = Color(10,255,10)
|
||||
end
|
||||
|
||||
render.DrawLine( startpos, endpos, trigger and Color(255,0,0) or color)
|
||||
end
|
||||
|
||||
if time < os.clock() then
|
||||
stop()
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
||||
pace.RegisterPanel(PANEL)
|
||||
end
|
||||
|
||||
do -- event is_touching
|
||||
local PANEL = {}
|
||||
|
||||
PANEL.ClassName = "properties_is_touching"
|
||||
PANEL.Base = "pace_properties_number"
|
||||
|
||||
function PANEL:OnValueSet()
|
||||
local function stop()
|
||||
hook.Remove("PostDrawOpaqueRenderables", "pace_draw_is_touching")
|
||||
end
|
||||
local last_part = pace.current_part
|
||||
|
||||
hook.Add("PostDrawOpaqueRenderables", "pace_draw_is_touching", function()
|
||||
local part = pace.current_part
|
||||
if part ~= last_part then stop() return end
|
||||
if not part:IsValid() then stop() return end
|
||||
if part.ClassName ~= "event" then stop() return end
|
||||
if part:GetEvent() ~= "is_touching" then stop() return end
|
||||
|
||||
local extra_radius = part:GetProperty("extra_radius") or 0
|
||||
local ent
|
||||
if part.RootOwner then
|
||||
ent = part:GetRootPart():GetOwner()
|
||||
else
|
||||
ent = part:GetOwner()
|
||||
end
|
||||
|
||||
if not IsValid(ent) then stop() return end
|
||||
local radius = ent:BoundingRadius()
|
||||
|
||||
if radius == 0 and IsValid(ent.pac_projectile) then
|
||||
radius = ent.pac_projectile:GetRadius()
|
||||
end
|
||||
|
||||
radius = radius + extra_radius + 1
|
||||
|
||||
local mins = Vector(-1,-1,-1)
|
||||
local maxs = Vector(1,1,1)
|
||||
local startpos = ent:WorldSpaceCenter()
|
||||
mins = mins * radius
|
||||
maxs = maxs * radius
|
||||
|
||||
local tr = util.TraceHull( {
|
||||
start = startpos,
|
||||
endpos = startpos,
|
||||
maxs = maxs,
|
||||
mins = mins,
|
||||
filter = ent
|
||||
} )
|
||||
render.DrawWireframeBox( startpos, Angle( 0, 0, 0 ), mins, maxs, tr.Hit and Color(255,0,0) or Color(255,255,255), true )
|
||||
end)
|
||||
end
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user