Update lua files
This commit is contained in:
@@ -79,11 +79,10 @@ end
|
||||
|
||||
function ENT:InFOV(pos, fov)
|
||||
local owner = self:GetOwner()
|
||||
|
||||
if not IsValid(owner) then return false end
|
||||
|
||||
if IsEntity(pos) then
|
||||
-- we must check eyepos and worldspacecenter
|
||||
-- maybe in the future add more points
|
||||
|
||||
if PointWithinViewAngle(owner:EyePos(), pos:WorldSpaceCenter(), owner:GetAimVector(), fov) then
|
||||
return true
|
||||
end
|
||||
@@ -95,22 +94,19 @@ function ENT:InFOV(pos, fov)
|
||||
end
|
||||
|
||||
function ENT:CanSee(ply, fov)
|
||||
local owner = self:GetOwner()
|
||||
if not IsValid(owner) then return false end
|
||||
|
||||
if ply:GetPos():DistToSqr(self:GetPos()) > self:GetMaxVisionRange() * self:GetMaxVisionRange() then
|
||||
return false
|
||||
end
|
||||
|
||||
-- TODO: check fog farz and compare with distance
|
||||
|
||||
-- half fov or something
|
||||
-- probably should move this to a variable
|
||||
fov = fov or true
|
||||
|
||||
if fov and !self:InFOV(ply, math.cos(0.5 * (self:GetFOV() or 90) * math.pi / 180)) then
|
||||
return false
|
||||
end
|
||||
|
||||
-- TODO: we really should check worldspacecenter too
|
||||
local owner = self:GetOwner()
|
||||
return util.QuickTrace(owner:EyePos(), ply:EyePos() - owner:EyePos(), {owner, self}).Entity == ply
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user