Skip to content

Commit

Permalink
Finger poser updates correctly on entity loss
Browse files Browse the repository at this point in the history
  • Loading branch information
robotboy655 committed Jul 9, 2024
1 parent e4be9bf commit f8929bd
Showing 1 changed file with 4 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -528,6 +528,7 @@ end

local OldHand = nil
local OldEntity = nil
local OldEntityValid = false

--[[
Updates the selected entity with the values from the convars
Expand All @@ -541,12 +542,13 @@ function TOOL:Think()

if ( self.NextUpdate && self.NextUpdate > CurTime() ) then return end

if ( CLIENT && ( OldHand != hand || OldEntity != selected ) ) then
if ( CLIENT && ( OldHand != hand || OldEntity != selected || IsValid( selected ) != OldEntityValid ) ) then

OldHand = hand
OldEntity = selected
OldEntityValid = IsValid( selected )

self:RebuildControlPanel( hand )
self:RebuildControlPanel( self:HandEntity(), self:HandNum() )

end

Expand All @@ -565,18 +567,6 @@ for i = 0, VarsOnHand do
TOOL.ClientConVar[ "" .. i ] = "0 0"
end

-- Rebuilds the context menu based on the current selected entity/hand
function TOOL:RebuildControlPanel( hand )

-- We've selected a new entity - rebuild the controls list
local CPanel = controlpanel.Get( "finger" )
if ( !CPanel ) then return end

CPanel:ClearControls()
self.BuildCPanel( CPanel, self:HandEntity(), self:HandNum() )

end

local ConVarsDefault = TOOL:BuildConVarList()

function TOOL.BuildCPanel( CPanel, ent, hand )
Expand Down

0 comments on commit f8929bd

Please sign in to comment.