-- @author  Geri-G & Sven777b

loadBGA = {};
g_BaseDir = g_currentModDirectory;

function loadBGA:loadMap(name)
	if string.find(name,"Herlefeld_basic_v11/Herlefeld.i3d",1) then
		self.searchOnCreateObjects = loadBGA.searchOnCreateObjects;
		g_currentMission.isLoadingMap = true;
		local BGA = g_currentMission:loadMap(Utils.getFilename("Autobahn.i3d", g_BaseDir));
		self:searchOnCreateObjects(BGA);
		g_currentMission.isLoadingMap = false;
	end;
		
end;

function loadBGA:deleteMap()
end;

function loadBGA:mouseEvent(posX, posY, isDown, isUp, button)
end;

function loadBGA:keyEvent(unicode, sym, modifier, isDown)
end;

function loadBGA:update(dt)
end;

function loadBGA:draw(dt)
end;

function loadBGA:searchOnCreateObjects(node)
    for i=1,getNumOfChildren(node) do
        local c = getChildAt(node, i-1);
        if getUserAttribute(c,"onCreate")~= nil  then
			local stringname = string.sub(getUserAttribute(c,"onCreate"),13);
			if g_onCreateUtil.onCreateFunctions[stringname] ~= nil then
				g_onCreateUtil.onCreateFunctions[stringname](c);			
			end;
			if getNumOfChildren(c) >0 then
				self:searchOnCreateObjects(c);
			end;
        else
            self:searchOnCreateObjects(c);
        end;
    end;
end;

addModEventListener(loadBGA);
