
AddCSLuaFile( "cl_init.lua" )
AddCSLuaFile( "shared.lua" )


function ENT:Initialize()

	self.Entity:PhysicsInit( SOLID_VPHYSICS )
	self.Entity:SetMoveType( MOVETYPE_VPHYSICS )
	self.Entity:SetSolid( SOLID_VPHYSICS )
	self.Entity:SetUseType( 0 )
	
	local phys = self.Entity:GetPhysicsObject()
	self.Entity:SetNetworkedInt(0,0)
	
	if (phys:IsValid()) then
		phys:Wake()
	end
	
end

function ENT:Use( activator, caller )

	self.On = true

	if self.Entity:GetNetworkedInt(0) == 1 then return end

	self:Toggle( true )
	self.Entity:NextThink( CurTime() )
	
end

function ENT:Think()

	if !self.On then
		self:Toggle( false )
		return
	end

	self.Entity:NextThink( CurTime() )
	self.On = nil


end

function ENT:SetKey( k )

	self.key = k

end

function ENT:Toggle( bool )

	if bool then
		numpad.Activate( self.Entity:GetTable().pl, _, {self.Entity:GetTable().key} )
		self.Entity:SetNetworkedInt(0,1)
	else
		numpad.Deactivate( self.Entity:GetTable().pl, _, {self.Entity:GetTable().key} )
		self.Entity:SetNetworkedInt(0,0)
	end
end

include('shared.lua')