

CreateConVar( "cl_drawhoverballs", "1" )

ENT.Spawnable			= true
ENT.AdminSpawnable		= false

/*---------------------------------------------------------
   Name: Initialize
---------------------------------------------------------*/
function ENT:Initialize()

	self.Refraction = Material( "sprites/heatwave" )
	self.Glow		= Material( "sprites/light_glow02_add" )
	self.Altitude	= 32
	self.ShouldDraw = 1
	
	self.NextSmokeEffect = 0

end


/*---------------------------------------------------------
   Name: Draw
---------------------------------------------------------*/
function ENT:Draw()

	if ( self.ShouldDraw == 0 ) then return end

	local vVel = self.Entity:GetVelocity()
	
	local PowerBeingUsed = vVel.z
	
	PowerBeingUsed = mathx.Clamp( math.abs(PowerBeingUsed), 0.0, 30.0 )
	PowerBeingUsed = PowerBeingUsed / 30
	
	local vOffset = self.Entity:GetPos()
	local vPlayerEyes = LocalPlayer():EyePos()
	local vDiff = (vOffset - vPlayerEyes):GetNormalized()
	
	render.SetMaterial( self.Glow )	
	local color = Color( 70, 180, 255, 255 )
	
	render.DrawSprite( vOffset - vDiff * 2, 32, 32, color )
	render.DrawSprite( vOffset - vDiff * 4, 32, 32, color )
	render.DrawSprite( vOffset - vDiff * 6, 32, 32, color )
	
	// Fade the colour if we're close to our hover point
	local mul = math.abs(self.Fraction)
	local color = Color( 70*mul, 180*mul, 255*mul, 255 )
	
	// Stobe the size faster the further away from our hover point we are
	// To give it the appearance that it's really working to pull the object up
	self.CurTime = self.CurTime or 0
	self.CurTime = self.CurTime + mul * FrameTime() * 30
	local size = 36 + math.sin( self.CurTime ) * 4.0
	
	render.DrawSprite( vOffset - vDiff * 4, size, size, color )
	render.DrawSprite( vOffset - vDiff * 6, size, size, color )
	render.DrawSprite( vOffset - vDiff * 6, size, size, color )
	render.DrawSprite( vOffset - vDiff * 6, size, size, color )
	
	self.Entity:DrawModel()
	
		
end


/*---------------------------------------------------------
   Name: Think
   Desc: Client Think - called every frame
---------------------------------------------------------*/
function ENT:Think()

	self.Altitude = self.Entity:GetNetworkedInt( self.IDX_ALTITUDE )
	self.Fraction = self:GetFractionFromHover()
	
	self.ShouldDraw = GetConVarNumber( "cl_drawhoverballs" )
end

include('shared.lua')