Permalink
Browse files

Properties improvements

All prop physics can now be ignited
More props can now be selected by properties ( Like prop_physics with
custom collision groups )
  • Loading branch information...
robotboy655 committed Nov 25, 2016
1 parent 8c1202b commit 6e4bcecf3fe3adb7b8c8005d913c630398bbb0c1
Showing with 40 additions and 29 deletions.
  1. +3 −1 garrysmod/lua/autorun/properties/ignite.lua
  2. +37 −28 garrysmod/lua/includes/modules/properties.lua
@@ -3,7 +3,9 @@ AddCSLuaFile()
local function CanEntityBeSetOnFire( ent )
if ( ent:GetClass() == "prop_physics" ) then return true end
-- func_pushable, func_breakable & func_physbox cannot be ignited
if ( ent:GetClass() == "item_item_crate" ) then return true end
if ( ent:GetClass():match( "prop_physics*") ) then return true end
if ( ent:IsNPC() ) then return true end
return false
@@ -3,16 +3,16 @@ module( "properties", package.seeall )
local meta = {
MsgStart = function( self )
net.Start( "properties" )
net.WriteString( self.InternalName )
end,
MsgEnd = function( self )
net.SendToServer()
end
}
@@ -28,7 +28,7 @@ List = {}
function Add( name, tab )
name = name:lower()
tab.InternalName = name
tab.InternalName = name
setmetatable( tab, meta )
List[ name ] = tab
@@ -53,7 +53,7 @@ local function AddOption( data, menu, ent, ply, tr )
if ( data.Type == "toggle" ) then return AddToggleOption( data, menu, ent, ply, tr ) end
if ( data.PrependSpacer ) then
if ( data.PrependSpacer ) then
menu:AddSpacer()
end
@@ -74,18 +74,18 @@ end
function OpenEntityMenu( ent, tr )
local menu = DermaMenu()
for k, v in SortedPairsByMemberValue( List, "Order" ) do
if ( !v.Filter ) then continue end
if ( !v:Filter( ent, LocalPlayer() ) ) then continue end
local option = AddOption( v, menu, ent, LocalPlayer(), tr )
if ( v.OnCreate ) then v:OnCreate( menu, option ) end
end
menu:Open()
end
@@ -100,10 +100,19 @@ function GetHovered( eyepos, eyevec )
endpos = eyepos + eyevec * 1024,
filter = filter
} )
if ( !trace.Hit ) then return end
if ( !IsValid( trace.Entity ) ) then return end
// Hit COLLISION_GROUP_DEBRIS and stuff
if ( !trace.Hit || !IsValid( trace.Entity ) ) then
local trace = util.TraceLine( {
start = eyepos,
endpos = eyepos + eyevec * 1024,
filter = filter,
mask = MASK_ALL
} )
end
if ( !trace.Hit || !IsValid( trace.Entity ) ) then return end
return trace.Entity, trace
end
@@ -112,7 +121,7 @@ function OnScreenClick( eyepos, eyevec )
local ent, tr = GetHovered( eyepos, eyevec )
if ( !IsValid( ent ) ) then return end
OpenEntityMenu( ent, tr )
end
@@ -124,18 +133,18 @@ if ( SERVER ) then
util.AddNetworkString( "properties" )
net.Receive( "properties", function( len, client )
local name = net.ReadString()
if ( !name ) then return end
if ( !IsValid( client ) ) then return end
local prop = List[ name ]
if ( !prop ) then return end
if ( !prop.Receive ) then return end
prop:Receive( len, client )
end )
end
@@ -148,24 +157,24 @@ if ( CLIENT ) then
local ent = GetHovered( EyePos(), LocalPlayer():GetAimVector() )
if ( !IsValid( ent ) ) then return end
local c = Color( 255, 255, 255, 255 )
c.r = 200 + math.sin( RealTime() * 50 ) * 55
c.g = 200 + math.sin( RealTime() * 20 ) * 55
c.b = 200 + math.cos( RealTime() * 60 ) * 55
local t = { ent }
if ( ent.GetActiveWeapon && IsValid( ent:GetActiveWeapon() ) ) then table.insert( t, ent:GetActiveWeapon() ) end
halo.Add( t, c, 2, 2, 2, true, false )
end )
--
-- Hook the GUIMousePressed call, which is called when the client clicks on the
-- gui.
--
hook.Add( "GUIMousePressed", "PropertiesClick", function( code, vector )
if ( !IsValid( vgui.GetHoveredPanel() ) || vgui.GetHoveredPanel() != g_ContextMenu ) then return end
if ( code == MOUSE_RIGHT && !input.IsButtonDown( MOUSE_LEFT ) ) then
@@ -178,14 +187,14 @@ if ( CLIENT ) then
-- Hook the GUIMousePressed call, which is called when the client clicks on the
-- gui.
--
local wasPressed = false
hook.Add( "PreventScreenClicks", "PropertiesPreventClicks", function()
if ( !input.IsButtonDown( MOUSE_RIGHT ) ) then wasPressed = false end
if ( wasPressed && input.IsButtonDown( MOUSE_RIGHT ) && !input.IsButtonDown( MOUSE_LEFT ) ) then return true end
if ( !IsValid( vgui.GetHoveredPanel() ) || vgui.GetHoveredPanel() != g_ContextMenu ) then return end
local ply = LocalPlayer()

0 comments on commit 6e4bcec

Please sign in to comment.