-------------------
-- epsilonScript --
-------------------

epsilonScript = {};

include( "shared.lua" );

-- Create some fonts.
surface.CreateFont( "akbar", 24, 700, true, false, "MenuFont" );
surface.CreateFont( "coolvetica", 24, 700, true, false, "MenuFont2" );
surface.CreateFont( "coolvetica", 36, 700, true, false, "TargetFont" );
surface.CreateFont( "akbar", 48, 700, true, false, "IntroFont" );

-- Realistic death view through the eyes of the ragdoll.
function GM:CalcView( ply, origin, angles, fov )
	local View = {};
	
	if ( !ply:Alive() ) then
		local Ragdoll = ply:GetRagdollEntity();
		if ( !Ragdoll or !Ragdoll:IsValid() ) then return end;
		
		local EyePos = Ragdoll:GetAttachment( Ragdoll:LookupAttachment( "eyes" ) );
		View = { origin = EyePos.Pos, angles = EyePos.Ang, fov = 90 };
		
		return View;
	end;
	
	local Wep = ply:GetActiveWeapon();
	View = { origin = origin, angles = angles, fov = fov };
	
	if ( ValidEntity( Wep ) ) then
 		local func = Wep.GetViewModelPosition;
 		if ( func ) then 
 			View.vm_origin,  View.vm_angles = func( Wep, origin*1, angles*1 );
 		end;
		
 		local func = Wep.CalcView;
 		if ( func ) then 
 			View.origin, View.angles, View.fov = func( Wep, ply, origin*1, angles*1, fov );
 		end;
 	end;
	
	return View;
end;