

EFFECT.Mat = Material( "effects/select_ring" )

/*---------------------------------------------------------
   Initializes the effect. The data is a table of data 
   which was passed from the server.
---------------------------------------------------------*/
function EFFECT:Init( data )
	
	local size = 8
	self.Entity:SetCollisionBounds( Vector( -size,-size,-size ), Vector( size,size,size ) )
	
	local Pos = data:GetOrigin() + data:GetNormal() * 2
		
	self.Entity:SetPos( Pos )
	
	// This 0.01 is a hack.. to prevent the angle being weird and messing up when we change it back to a normal
	self.Entity:SetAngles( data:GetNormal():Angle() + Angle( 0.01, 0.01, 0.01 ) )
	
	self.Entity:SetParentPhysNum( data:GetAttachment() )
	
	if (data:GetEntity():IsValid()) then
		self.Entity:SetParent( data:GetEntity() )
	end
	
	self.Pos = data:GetOrigin()
	self.Normal = data:GetNormal()
	
	self.Speed = math.Rand( 30, 60 )
	self.Size = 4
	self.Alpha = 255
	
end


/*---------------------------------------------------------
   THINK
---------------------------------------------------------*/
function EFFECT:Think( )

	local speed = FrameTime()
	
	//if (self.Speed > 100) then self.Speed = self.Speed - 1000 * speed end
	
	self.Speed = self.Speed - ( 100 - self.Speed ) * speed
	
	if (self.Speed < 0) then self.Speed = 0 end
	
	self.Size = self.Size + 2.0 * speed * self.Speed
	self.Alpha = self.Alpha - 700.0 * speed
	
	if (self.Alpha < 0 ) then return false end
	if (self.Size < 0) then return false end
	return true
	
end

/*---------------------------------------------------------
   Draw the effect
---------------------------------------------------------*/
function EFFECT:Render( )

	if (self.Alpha < 1 ) then return end

	render.SetMaterial( self.Mat )
	
	render.DrawQuadEasy( self.Entity:GetPos(),
						 self.Entity:GetAngles():Forward(),
						 self.Size, self.Size,
						 Color( math.Rand( 10, 150), math.Rand( 170, 220), math.Rand( 240, 255), self.Alpha ) )
						 
						

end
