Skip to content

Commit

Permalink
Tweak comments
Browse files Browse the repository at this point in the history
  • Loading branch information
StyledStrike committed Dec 30, 2024
1 parent c811296 commit 9fa6a01
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 14 deletions.
2 changes: 1 addition & 1 deletion lua/entities/base_glide_aircraft/shared.lua
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ if CLIENT then
ENT.ExhaustPositions = {}

-- Offsets and timings for strobe lights.
-- This should countain a table of tables, where each looks like this:
-- This should contain a table of tables, where each looks like this:
--
-- { offset = Vector( 0, 0, 0 ), blinkTime = 0 }, -- Blinks at the start of the cycle
-- { offset = Vector( 0, 0, 0 ), blinkTime = 0.5, blinkDuration = 0.5 }, -- Blinks in the middle of the cycle, for half of the cycle
Expand Down
29 changes: 16 additions & 13 deletions lua/glide/server/weaponry.lua
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
local IsValid = IsValid

local EntityMeta = FindMetaTable( "Entity" )
local getClass = EntityMeta.GetClass
local isVehicle = EntityMeta.IsVehicle
local getParent = EntityMeta.GetParent

function Glide.CreateTurret( vehicle, offset, angles )
local turret = ents.Create( "glide_vehicle_turret" )

Expand Down Expand Up @@ -254,19 +249,25 @@ do
end
end

local EntityMeta = FindMetaTable( "Entity" )
local getClass = EntityMeta.GetClass
local isVehicle = EntityMeta.IsVehicle
local getParent = EntityMeta.GetParent

local AllEnts = ents.Iterator
local CanLockOnEntity = Glide.CanLockOnEntity

local WHITELIST = Glide.LOCKON_WHITELIST

--- Finds all entities that we can lock on with `Glide.CanLockOnEntity`,
--- then returns which one has the largest dot product between `normal` and the direction towards them.
local function isLockableEntity( ent, skipParentCheck )
local function IsLockableEntity( ent, skipParentCheck )
local class = getClass( ent )
if class == "prop_vehicle_prisoner_pod" and not skipParentCheck then -- Checks for parent vehicles like for example glide

-- Checks for parent vehicles, like for example glide
if class == "prop_vehicle_prisoner_pod" and not skipParentCheck then
local parent = getParent( ent )
if parent ~= NULL then -- Check directly against NULL as getParent returns a clean NULL object and it's faster than IsValid
if isLockableEntity( parent, true ) then

-- Check directly against NULL as getParent returns a clean NULL object and it's faster than IsValid
if parent ~= NULL then
if IsLockableEntity( parent, true ) then
return false
end
return true
Expand All @@ -288,6 +289,8 @@ local function isLockableEntity( ent, skipParentCheck )
return false
end

--- Finds all entities that we can lock on with `Glide.CanLockOnEntity`,
--- then returns which one has the largest dot product between `normal` and the direction towards them.
function Glide.FindLockOnTarget( origin, normal, threshold, maxDistance, attacker, traceData, filter )
local largestDot = 0
local canLock, dot, target
Expand All @@ -302,7 +305,7 @@ function Glide.FindLockOnTarget( origin, normal, threshold, maxDistance, attacke
end

for _, e in AllEnts() do
if e ~= attacker and not ignore[e] and isLockableEntity( e ) then
if e ~= attacker and not ignore[e] and IsLockableEntity( e ) then
canLock, dot = CanLockOnEntity( e, origin, normal, threshold, maxDistance, attacker, includeEmpty, traceData )

if canLock and dot > largestDot then
Expand Down

0 comments on commit 9fa6a01

Please sign in to comment.