epsilonScript.Classes = {};
epsilonScript.Classes.Stored = {};

-- Function to register a class.
function epsilonScript.Classes.RegisterClass( class )
	epsilonScript.Classes.Stored[ class.TeamID ] = class;
	epsilonScript.Classes.Stored[ class.TeamID ].Name = class.Name or "";
	epsilonScript.Classes.Stored[ class.TeamID ].Description = class.Description or "";
	epsilonScript.Classes.Stored[ class.TeamID ].Model = class.Model or nil; -- Nil is the choosen model ;).
	epsilonScript.Classes.Stored[ class.TeamID ].Icon = class.Icon or "models/player/corpse1.mdl";
	epsilonScript.Classes.Stored[ class.TeamID ].Flag = class.Flag or "";
	epsilonScript.Classes.Stored[ class.TeamID ].Public = class.Public;
	epsilonScript.Classes.Stored[ class.TeamID ].TeamID = class.TeamID or 0;
	epsilonScript.Classes.Stored[ class.TeamID ].TeamColour = class.TeamColour or Color( 255, 255, 255, 255 );
	
	if ( SERVER ) then
		epsilonScript.Classes.Stored[ class.TeamID ].Weapons = class.Weapons or {}
		epsilonScript.Classes.Stored[ class.TeamID ].PlayerSpawnHook = class.PlayerSpawnHook or function( ply )end;
	end;
	
	-- Setup the team.
	team.SetUp( class.TeamID, class.Name, class.TeamColour );
end;

function epsilonScript.Classes.GetClass( classID )
	if ( epsilonScript.Classes.Stored[ classID ] != nil ) then
		return epsilonScript.Classes.Stored[ classID ];
	else
		Error( "ClassID: " .. classID .. " does not exist!" );
	end;
end;

-- Include classes.
for k, v in pairs( file.FindInLua( "epsilonScript/gamemode/core/schemes/" .. epsilonScript.Config:Get( "ActiveScheme" ) .. "/classes/*.lua" ) ) do
	if ( v != "." and v != ".." ) then
		if ( SERVER ) then
			if ( file.Exists( "../gamemodes/epsilonScript/gamemode/core/schemes/" .. epsilonScript.Config:Get( "ActiveScheme" ) .. "/classes/" .. v ) ) then
				include( "epsilonScript/gamemode/core/schemes/" .. epsilonScript.Config:Get( "ActiveScheme" ) .. "/classes/" .. v );
				AddCSLuaFile( "epsilonScript/gamemode/core/schemes/" .. epsilonScript.Config:Get( "ActiveScheme" ) .. "/classes/" .. v );
			end;
		else
			if ( file.Exists( "../lua_temp/epsilonScript/gamemode/core/schemes/" .. epsilonScript.Config:Get( "ActiveScheme" ) .. "/classes/" .. v ) or file.Exists( "../gamemodes/epsilonScript/gamemode/core/schemes/" .. epsilonScript.Config:Get( "ActiveScheme" ) .. "/classes/" .. v ) ) then
				include( "epsilonScript/gamemode/core/schemes/" .. epsilonScript.Config:Get( "ActiveScheme" ) .. "/classes/" .. v );
			end;
		end;
	end;
end;