function assignCustomExFiles()
--------------------------------------------------------------------------------------------------------------
--PLACE CUSTOM ASSIGNMENTS BELOW HERE
--------------------------------------------------------------------------------------------------------------

addExternalFile("generalns.lua")




--------------------------------------------------------------------------------------------------------------
--PLACE CUSTOM ASSIGNMENTS ABOVE HERE
--------------------------------------------------------------------------------------------------------------
end

-----------------------------------------------------------------------------
-- Asset module
-----------------------------------------------------------------------------
gMaterialRemapTable = gSportsRNA:GetTable("MaterialRemap")
function AttribMaterial(name)
	return gSportsRNA:GetString(gMaterialRemapTable, name)
end

gLoadAsyncTable = {}

function LoadAsync(fname)
	local handle = gSportsRNA:LoadScriptAsync(fname)
    gLoadAsyncTable[fname] = handle
end

function LoadAsyncWait()
    for fname,handle in pairs(gLoadAsyncTable) do
		gSportsRNA:LoadScriptAsyncComplete(handle)
	end
	gLoadAsyncTable = {}
end

function addExternalFile(fname)
	LoadAsync("data/fifarna/lua/assignments/"..fname)
end

-----------------------------------------------------------------------------
-- Fire off all load requests simultaneously to get more efficient throughput
LoadAsync("data/fifarna/lua/assetsns/stadium.lua")
LoadAsync("data/fifarna/lua/assetsns/ball.lua")

local wvstate = gSportsRNA:GetTable("wvState")
LoadAsync("data/fifarna/lua/assetsns/player.lua")
LoadAsync("data/fifarna/lua/assetsns/goalnet.lua")
LoadAsync("data/fifarna/lua/assets/refereeflag.lua")
LoadAsync("data/fifarna/lua/assetsns/accessory.lua")
LoadAsync("data/fifarna/lua/assets/particleseffect.lua")
LoadAsync("data/fifarna/lua/assets/grass.lua")
LoadAsync("data/fifarna/lua/assetsns/sle.lua")
LoadAsync("data/fifarna/lua/assetsns/crowd.lua")
LoadAsync("data/fifarna/lua/assets/indicator.lua")
LoadAsync("data/fifarna/lua/assets/poleflag.lua")
LoadAsync("data/fifarna/lua/assets/trophy.lua")
LoadAsync("data/fifarna/lua/assets/batchsle.lua")
LoadAsync("data/fifarna/lua/assets/smallobjects.lua")
LoadAsync("data/fifarna/lua/assetsns/wipe3d.lua")
LoadAsync("data/fifarna/lua/assets/volumetricfx.lua")
LoadAsync("data/fifarna/lua/assets/gameplayprop.lua")
LoadAsync("data/fifarna/lua/assets/digitalboard.lua")
LoadAsync("data/fifarna/lua/assetsns/rm_common.lua")
-- assignCustomExFiles()

-----------------------------------------------------------------------------
function InitializeDB()
	db = { 
		accessory = {},
		ball = {}, 
		gameplayprop = {},
		digitalboard = {},
		trophy = {},
		wipeTrophy = {},
		player = {}, 
		stadium = {}, 
		pitch = {},
		grass = {},
		goalnet = {},
		crowd = {},
		poleflag = {},
		batchsle = {},
		sle = {},
		particleseffect = {},
		smallobject = {},
		refereeflag = {},
		volumetricFX = {},
		wipe3d = {},
		nballs = 2, ntrophies = 1, nplayers = 33, 
		nstadiums = 2, npitches = 2,
		nrefereeflags = 2, ngoalnets = 4, ngrass = 2, 
		naccessoriesperplayer = 10, nsles = 110, nbatchsles = 1, 
		nparticleseffects = 20, nsmallobjects=1, nvolumetricFX = 1,
		nwipe3d = 5, nwipe3dclips = 2,
		ngameplayprops = 44,
		ndigitalboards = 1,
	}

	local as = gAttribSys
	local idx
	for idx=0,db.nstadiums-1 do 
		db.stadium[idx] = {}
	end
	
	for idx=0,db.npitches-1 do 
		db.pitch[idx] = {}
	end
	
	for idx=0,db.nballs-1 do 
		db.ball[idx] = {}
	end
	
	for idx=0,db.ntrophies-1 do 
		db.trophy[idx] = {}
	end
	
	for idx=0,db.nsmallobjects-1 do
		db.smallobject[idx] = {}
	end
	
	for idx=0,db.nplayers-1 do 
		db.player[idx] = {}
		
		for accidx=0,db.naccessoriesperplayer-1 do 
			db.accessory[idx * db.naccessoriesperplayer + accidx] = {}
		end
	end
	
	for idx=0,db.ngrass-1 do 
		db.grass[idx] = {}
	end
	
	for idx=0,db.ngoalnets-1 do 
		db.goalnet[idx] = {}
	end
	
	for idx=0,db.nbatchsles-1 do 
		db.batchsle[idx] = {}
	end
	for idx=0,db.nsles-1 do 
		db.sle[idx] = {}
	end
	
	for idx=0,db.nparticleseffects-1 do 
		db.particleseffect[idx] = {}
	end

	for idx=0, db.nrefereeflags-1 do
		db.refereeflag[idx] = {}
	end
    
	for idx=0,db.nvolumetricFX-1 do 
		db.volumetricFX[idx] = {}
	end
	
	for idx=0,db.nwipe3d-1 do 
		db.wipe3d[idx] = {}
	end
	
	for idx=0,db.ngameplayprops-1 do
		db.gameplayprop[idx] = {}
	end

	for idx=0,db.ndigitalboards-1 do
		db.digitalboard[idx] = {}
	end
	
end

-----------------------------------------------------------------------------
function InitializeRenderables()
	gRenderObj = { 
		batchSle = nil,
		sles = {},
		ball = {}, 
		trophy = {},
		wipeTrophy = {},
		players = {},
		stadium = {},
		pitch = {},
		refereeflag = {},
		goalnet = {},
		particlesEffect = {},
		frameGrab = {},
		batchPlayer = nil,
		flatShadow = nil,
		lightmapgen=nil,
		depthBufferPrePass = nil,
		crowd = nil,
		mipmapsgen = nil,
		batchparticle = nil,
		poleflag = nil,
		gameplayprop = {},
		digitalboard = {},
		grass = {},
		postfx = nil,
		indicator = nil,
		pitchlines = nil,
		selfshadow = nil,
		ferenderable = nil,
		onscreenimage = nil,
		smallobjects = {},
		flatrender = nil,
		volumetricFX = {},
		wipe3d = {},
		wipe3dclip = {},
	} 

	local gr = gRenderables

	gRenderObj.lightmapgen = gr:Create("lightmapgen", 0)

	local idx
	for idx=0,db.nstadiums-1 do 
		gRenderObj.stadium[idx] = gr:Create("stadium", idx)
	end
	
	for idx=0,db.npitches-1 do 
		gRenderObj.pitch[idx] = gr:Create("pitch", idx)
	end
	
	for idx=0,db.nballs-1 do
		gRenderObj.ball[idx] = gr:Create("ball", idx)
	end
	
	for idx=0,db.ntrophies-1 do
		gRenderObj.trophy[idx] = gr:Create("trophy", idx)
	end

	gRenderObj.wipeTrophy = gr:Create("trophy", db.ntrophies);

	for idx=0,db.ngoalnets-1 do
		gRenderObj.goalnet[idx] = gr:Create("goalnet", idx)
	end
	
	for idx=0,db.nrefereeflags-1 do
		gRenderObj.refereeflag[idx] = gr:Create("refereeflag", idx)
	end
	
	for idx=0,db.ngrass-1 do
		gRenderObj.grass[idx] = gr:Create("grass", idx)
	end

	gRenderObj.batchSle = gr:Create("batchsle", 0)
	gRenderObj.batchPlayer = gr:Create("batchplayer", 0)
	gRenderObj.flatShadow = gr:Create("flatshadow", 0)
	if (EA_PLATFORM_WINDOWS == true or EA_PLATFORM_MAC == true) then
		gRenderObj.depthBufferPrePass = gr:Create("depthbufferprepass", 0)
	end

	-- create crowd object and add stadium 1 as subobject for updates
	gRenderObj.crowd = gr:Create("crowd", 0)
	gr:AddSubObject(gRenderObj.crowd, gRenderObj.stadium[1])

	gRenderObj.mipmapsgen = gr:Create("mipmapsgen", 0)

	gRenderObj.frameGrab[0] = gr:Create("framegrab", 0)
	gRenderObj.frameGrab[1] = gr:Create("framegrab", 1)
	
	gRenderObj.msaa = gr:Create("msaa", 1)
	gRenderObj.postfx = gr:Create("postfx", 0)
	gRenderObj.batchparticle = gr:Create("batchparticle", 0)
	gRenderObj.poleflag = gr:Create("poleflag", 0)
	gRenderObj.indicator = gr:Create("indicator", 0)
	gRenderObj.pitchlines = gr:Create("pitchlines", 0)
--	gRenderObj.selfshadow = gr:Create("selfshadow", 0)
	gRenderObj.selfshadow = gr:Create("selfshadowpo", 0)
	gRenderObj.ferenderable = gr:Create("ferenderable", 0)
	gRenderObj.onscreenimage = gr:Create("onscreenimage", 0)
    gRenderObj.jumbotron = gr:Create("jumbotron", 0)

	gRenderObj.smallobjects[0] = gr:Create("smallobject", 0)
	
	-- Create the Gameplay props using the base renderable implementation
	for idx=0,db.ngameplayprops-1 do
		gRenderObj.gameplayprop[idx] = gr:Create("gameplayprop", idx)
	end

	-- Create digital board
	for idx=0,db.ndigitalboards-1 do
		gRenderObj.digitalboard[idx] = gr:Create("digitalboard", idx)
	end
    gRenderObj.flatrender = gr:Create("flatrender", 0)
    gr:AddSubObject(gRenderObj.flatrender, gRenderObj.batchPlayer)

	-- Create players, and add them to the batchplayer object
	for idx=0,db.nplayers-1 do 
		player = gr:Create("player", idx)
		gRenderObj.players[ idx ] = player
		
		
		for accidx=0,db.naccessoriesperplayer-1 do
			accessory = gr:Create("accessory", idx * db.naccessoriesperplayer + accidx)
			gr:AddSubObject(player, accessory);
		end
		
		gr:AddSubObject(gRenderObj.batchPlayer, player)
	end
	
	-- Create sles, and add them to the batchSle object
	for idx=0,db.nsles-1 do
		sle = gr:Create("sle", idx)
		gRenderObj.sles[idx] = sle 
	end

	-- Add sles to the batchSle and assign proper types
	AssignSleTypes( gr, gRenderObj.batchSle, gRenderObj.sles, db.nsles );
	
	-- Add all objects that are required to the depthbufferPrePassObject
	local dbpp = gRenderObj.depthBufferPrePass
	if (dbpp ~= nil) then
		for idx=0,db.nstadiums-1 do 
			gr:AddSubObject(dbpp, gRenderObj.stadium[idx])
		end
		for idx=0,db.nballs-1 do 
			gr:AddSubObject(dbpp, gRenderObj.ball[idx])
		end
		for idx=0,db.ntrophies-1 do
	--		gr:AddSubObject(dbpp, gRenderObj.trophy[idx])
		end
		for idx=0,db.nrefereeflags-1 do
	--		gr:AddSubObject(dbpp, gRenderObj.refereeflag[idx])
		end
		for idx=0,db.ngoalnets-1 do
			gr:AddSubObject(dbpp, gRenderObj.goalnet[idx])
		end
		gr:AddSubObject(dbpp, gRenderObj.crowd)
		gr:AddSubObject(dbpp, gRenderObj.batchPlayer)
		gr:AddSubObject(dbpp, gRenderObj.batchSle)
		
		for idx=0,db.ngameplayprops-1 do
			gr:AddSubObject(dbpp, gRenderObj.gameplayprop[idx], 3) -- Tell dbpp to use pass 3 (dbpp pass) instead of dbpp interface
		end

		for idx=0,db.ndigitalboards-1 do
			gr:AddSubObject(dbpp, gRenderObj.digitalboard[idx], 3) -- Tell dbpp to use pass 3 (dbpp pass) instead of dbpp interface
		end
	end

	-- Add ball, batchsle and batchplayer object to the flat shadow renderer
	for idx=0,db.nballs-1 do 
		gr:AddSubObject(gRenderObj.flatShadow, gRenderObj.ball[idx])
		gr:AddSubObject(gRenderObj.selfshadow, gRenderObj.ball[idx])
	end
	
	for idx=0,db.ntrophies-1 do
		gr:AddSubObject(gRenderObj.flatShadow, gRenderObj.trophy[idx])
		gr:AddSubObject(gRenderObj.selfshadow, gRenderObj.trophy[idx])
	end
	
	gr:AddSubObject(gRenderObj.flatShadow, gRenderObj.batchPlayer)
	gr:AddSubObject(gRenderObj.selfshadow, gRenderObj.batchPlayer)
	
	for idx=0,db.ngameplayprops-1 do
		gr:AddSubObject(gRenderObj.flatShadow, gRenderObj.gameplayprop[idx], 2) -- Tell flatshadow to use pass 2 (flatshadow pass) instead of flatshadow interface
		gr:AddSubObject(gRenderObj.selfshadow, gRenderObj.gameplayprop[idx], 4) -- Tell selfshadow to use pass 4 (selfshadow pass) instead of selfshadow interface
	end

	for idx=0,db.ndigitalboards-1 do
		gr:AddSubObject(gRenderObj.flatShadow, gRenderObj.digitalboard[idx], 2) -- Tell flatshadow to use pass 2 (flatshadow pass) instead of flatshadow interface
		gr:AddSubObject(gRenderObj.selfshadow, gRenderObj.digitalboard[idx], 4) -- Tell selfshadow to use pass 4 (selfshadow pass) instead of selfshadow interface
	end
	
	gr:AddSubObject(gRenderObj.flatShadow, gRenderObj.batchSle)
	
	for idx=0,db.nvolumetricFX-1 do
		gRenderObj.volumetricFX[idx] = gr:Create("volumetricfx", idx)
	end
	
	-- Create wipe elements before creating clips
	for idx=0,db.nwipe3d-1 do
		gRenderObj.wipe3d[idx] = gr:Create("wipe3d", idx)
	end
	-- create wipe movies
	for idx=0,db.nwipe3dclips-1 do
		gRenderObj.wipe3dclip[idx] = gr:Create("wipe3dclip", idx)
	end
	-- build replay wipe
	gr:AddSubObject(gRenderObj.wipe3dclip[0], gRenderObj.wipe3d[0])
	-- build intro wipe
	for idx=1,db.nwipe3d-1 do
		gr:AddSubObject(gRenderObj.wipe3dclip[1], gRenderObj.wipe3d[idx])
	end

	-- Create particles effect, and add them to the particles object
	for idx=0,db.nparticleseffects-1 do 
		particlesEffect = gr:Create("particleseffect", idx)
		gRenderObj.particlesEffect[ idx ] = particlesEffect
	end
	
	-----------------------------------------------------------------------------
	-- Init post fx passes with renderables
	CreatePostFXRenderables( gRenderObj, gr )
end

-----------------------------------------------------------------------------
InitializeDB()
LoadAsyncWait() -- ensure all files are loaded
InitializeRenderables()

assignCustomExFiles()
LoadAsyncWait()
collectgarbage('collect')

--Revolution Mod 14 1.1
--Edited by scouser09