Skip to content

Commit

Permalink
Add detour to initialize beingLookedAtByLocalPlayer (#3046)
Browse files Browse the repository at this point in the history
  • Loading branch information
Denneisk authored Apr 17, 2024
1 parent 42a2ab1 commit 92ecf2b
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions lua/entities/base_wire_entity.lua
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,14 @@ ENT.IsWire = true

if CLIENT then
local wire_drawoutline = CreateClientConVar("wire_drawoutline", 1, true, false)
local beingLookedAtByLocalPlayer
-- Funny reverse-detour because this function is sometimes nil and sometimes not, but is never nil when drawing for the first time.
local function beingLookedAtByLocalPlayer(self)
beingLookedAtByLocalPlayer = BaseClass.BeingLookedAtByLocalPlayer
return beingLookedAtByLocalPlayer(self)
end

function ENT:Initialize()
self.NextRBUpdate = CurTime() + 0.25
beingLookedAtByLocalPlayer = BaseClass.BeingLookedAtByLocalPlayer
end

function ENT:Draw()
Expand Down Expand Up @@ -416,12 +419,14 @@ net.Receive( "wire_overlay_request", function( len, ply )
end
end)

function ENT:Initialize()
BaseClass.Initialize(self)
self:PhysicsInit(SOLID_VPHYSICS)
self:SetMoveType(MOVETYPE_VPHYSICS)
self:SetSolid(SOLID_VPHYSICS)
self.WireDebugName = self.WireDebugName or (self.PrintName and self.PrintName:sub(6)) or self:GetClass():gsub("gmod_wire", "")
if SERVER then
function ENT:Initialize()
BaseClass.Initialize(self)
self:PhysicsInit(SOLID_VPHYSICS)
self:SetMoveType(MOVETYPE_VPHYSICS)
self:SetSolid(SOLID_VPHYSICS)
self.WireDebugName = self.WireDebugName or (self.PrintName and self.PrintName:sub(6)) or self:GetClass():gsub("gmod_wire", "")
end
end

function ENT:OnRemove()
Expand Down

0 comments on commit 92ecf2b

Please sign in to comment.