Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent entity gates from being used on players #2908

Merged
merged 2 commits into from
Nov 27, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 6 additions & 8 deletions lua/wire/gates/entity.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ GateActions("Entity")
local clamp = WireLib.clampForce

local function isAllowed( gate, ent )
if not IsValid( ent ) then return false end
if ent:IsPlayer() then return false end
if not IsValid(gate:GetPlayer()) then return false end
return hook.Run( "PhysgunPickup", gate:GetPlayer(), ent ) ~= false
end
Expand All @@ -17,10 +19,9 @@ GateActions["entity_applyf"] = {
inputtypes = { "ENTITY" , "VECTOR" },
timed = true,
output = function(gate, ent, vec )
if not IsValid( ent ) then return end
if not isAllowed( gate, ent ) then return end
local phys = ent:GetPhysicsObject()
if not IsValid( phys ) then return end
if not isAllowed( gate, ent ) then return end
if not isvector(vec) then vec = Vector (0, 0, 0) end
vec = clamp(vec)
if vec.x == 0 and vec.y == 0 and vec.z == 0 then return end
Expand All @@ -38,10 +39,9 @@ GateActions["entity_applyof"] = {
inputtypes = { "ENTITY" , "VECTOR" , "VECTOR" },
timed = true,
output = function(gate, ent, vec, offset )
if not IsValid( ent ) then return end
if not isAllowed( gate, ent ) then return end
local phys = ent:GetPhysicsObject()
if not IsValid( phys ) then return end
if not isAllowed( gate, ent ) then return end
if not isvector(vec) then vec = Vector (0, 0, 0) end
if not isvector(offset) then offset = Vector (0, 0, 0) end
vec = clamp(vec)
Expand All @@ -63,10 +63,9 @@ GateActions["entity_applyaf"] = {
inputtypes = { "ENTITY" , "ANGLE" },
timed = true,
output = function(gate, ent, angForce )
if not IsValid( ent ) then return end
if not isAllowed( gate, ent ) then return end
local phys = ent:GetPhysicsObject()
if not IsValid( phys ) then return end
if not isAllowed( gate, ent ) then return end
local clampedForce = clamp(angForce)
if clampedForce.x == 0 and clampedForce.y == 0 and clampedForce.z == 0 then return end

Expand Down Expand Up @@ -110,10 +109,9 @@ GateActions["entity_applytorq"] = {
inputtypes = { "ENTITY" , "VECTOR" },
timed = true,
output = function(gate, ent, vec )
if not IsValid( ent ) then return end
if not isAllowed( gate, ent ) then return end
local phys = ent:GetPhysicsObject()
if not IsValid( phys ) then return end
if not isAllowed( gate, ent ) then return end
if not isvector(vec) then vec = Vector (0, 0, 0) end
if not isvector(offset) then offset = Vector (0, 0, 0) end
vec = clamp(vec)
Expand Down
Loading