-----------------------------
-- epsilonScript --
-- This file is a mess LOL --
-----------------------------
require( "gamedescription" );
require( "datastream" );

-- Derive gamemode from sandbox.
DeriveGamemode( "sandbox" );
--DeriveGamemode( "base" )

-- Config functions.
epsilonScript.Config = {};

function epsilonScript.Config:Set( side, name, value )
	if ( side == SHARED ) then
		epsilonScript.Config[ name ] = value;
	elseif ( side ) then
		epsilonScript.Config[ name ] = value;
	end;
end;

function epsilonScript.Config:Get( con )
	if ( epsilonScript.Config[ con ] ) then
		return epsilonScript.Config[ con ];
	end;
end;

-- I put this here cuz it keeps fucking up the shitty loading lol.
epsilonScript.Config:Set( SHARED, "ActiveScheme", "Hl2RP" );

-- Datastream fix.
function IsValid( Ent )  
    if ( Ent ) and ( Ent.IsValid ) then
        return Ent:IsValid();
    end;
	
    return false;
end;

include( "includes/modules/datastream.lua" );

-- Function to get the inflation amount.
function epsilonScript.AmountToInflation( amount )
	return amount + math.ceil( ( #player.GetAll() * epsilonScript.Economy ) / epsilonScript.Config:Get( "InflationRate" ) );
end;

-- Load the core files!
if ( SERVER ) then
	-- Send the client the menus.
	for k, v in pairs( file.FindInLua( "epsilonScript/gamemode/core/clientside/derma/*.lua" ) ) do
		AddCSLuaFile( "core/clientside/derma/" .. v );
	end;
	
	for k, v in pairs( file.FindInLua( "epsilonScript/gamemode/core/clientside/*.lua" ) ) do
		if ( v != "." and v != ".." ) then
			AddCSLuaFile( "core/clientside/" .. v );
		end;
	end;
	
	for k, v in pairs( file.FindInLua( "epsilonScript/gamemode/core/serverside/*.lua" ) ) do
		if ( v != "." and v != ".." ) then
			include( "core/serverside/" .. v );
		end;
	end;
	
	for k, v in pairs( file.FindInLua( "epsilonScript/gamemode/core/shared/*.lua" ) ) do
		if ( v != "." and v != ".." ) then
			AddCSLuaFile( "core/shared/" .. v );
			include( "core/shared/" .. v );
		end;
	end;
	
	-- Scheme settings file.
	AddCSLuaFile( "core/schemes/" .. epsilonScript.Config:Get( "ActiveScheme" ) .. "/" .. string.lower( epsilonScript.Config:Get( "ActiveScheme" ) ) .. ".lua" );
else
	-- Include the menus.
	for k, v in pairs( file.FindInLua( "epsilonScript/gamemode/core/clientside/derma/*.lua" ) ) do
		include( "core/clientside/derma/" .. v );
	end;
	
	for k, v in pairs( file.FindInLua( "epsilonScript/gamemode/core/clientside/*.lua" ) ) do
		if ( v != "." and v != ".." ) then
			include( "core/clientside/" .. v );
		end;
	end;
	
	for k, v in pairs( file.FindInLua( "epsilonScript/gamemode/core/shared/*.lua" ) ) do
		if ( v != "." and v != ".." ) then
			include( "core/shared/" .. v );
		end;
	end;
end;

-- Scheme settings file.
include( "core/schemes/" .. epsilonScript.Config:Get( "ActiveScheme" ) .. "/" .. string.lower( epsilonScript.Config:Get( "ActiveScheme" ) ) .. ".lua" );

-- Just setting some colours for easier use.
Colour_White = Color( 255, 255, 255, 255 );
Colour_Black = Color( 0, 0, 0, 255 );
Colour_Red = Color( 255, 0, 0, 255 );
Colour_Green = Color( 0, 255, 0, 255 );
Colour_Blue = Color( 0, 0, 255, 255 );

-- Info.
GM.Name = "epsilonScript[ BETA ] | " .. epsilonScript.Config:Get( "ActiveScheme" );
GM.Author = "Chewgum";