

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

/*---------------------------------------------------------
   Initializes the effect. The data is a table of data 
   which was passed from the server.
---------------------------------------------------------*/
function EFFECT:Init( data )
	
	for i=0, 5 do
	
		local effectdata = EffectData()
			effectdata:SetOrigin( data:GetOrigin() )
			effectdata:SetNormal( data:GetNormal() )
			effectdata:SetEntity( data:GetEntity() )
			effectdata:SetAttachment( data:GetAttachment() )
		util.Effect( "selection_ring", effectdata )
		
	end
	
	local Pos = data:GetOrigin() + data:GetNormal()
	
	local size = 8
	self.Entity:SetCollisionBounds( Vector( -size,-size,-size ), Vector( size,size,size ) )
	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 ) )
	
	if (data:GetEntity():IsValid()) then
		self.Entity:SetParentPhysNum( data:GetAttachment() )
		self.Entity:SetParent( data:GetEntity() )
	end
	
	self.Size = 4
	self.Alpha = 255
	
	self.Speed = 500 * data:GetScale()
	
end


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

	//self.Size = self.Size - 0.5 * FrameTime()
	self.Alpha = self.Alpha - 50.0 * FrameTime()
	
	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( 255, 255, 255, self.Alpha ) )
end
