-------------------------------
-- SSTRP
-- Author: MNWRP
--
-- schema.lua
-- Loads and configures the schema
-------------------------------

Schemas = {  };

function LoadSchema( schema )

	local path = "schemas/" .. schema .. ".lua";
	
	SCHEMA = {  };
	
	include( path );
	
	DayLog( "script.txt", "Loading schema " .. SCHEMA.Name .. " by " .. SCHEMA.Author .. "" );
	
	table.insert( Schemas, SCHEMA );
	
	-- Load the plugins
	
	local list = file.FindInLua( "HL2PFRP/gamemode/schemas/" .. schema .. "/plugins/*.lua" );
	
	for k, v in pairs( list ) do
	
		LoadPlugin( schema, v );
		
	end
	
	-- Load the items
	local list = file.FindInLua( "HL2PFRP/gamemode/schemas/" .. schema .. "/items/*.lua" );
	
	for k, v in pairs( list ) do
	
		LoadItem( schema, v );
		
	end
	
	if( SCHEMA.Base != nil ) then
	
		LoadSchema( SCHEMA.Base )
		
	end
	
end

function InitSchemas( )

	for _, SCHEMA in pairs( Schemas ) do
		
		CallHook( "InitSchema", SCHEMA );
		SCHEMA.SetUp( );
		
	end
	
end

ValidModels = {};

function AddModels(mdls)

	if(type(mdls) == "table") then
	
		for k, v in pairs(mdls) do
		
			table.insert(ValidModels, v)
			
		end
		
	else
	
		table.insert(ValidModels, mdls)
		
	end
	
end
