package net.mgsx.game.core;

import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.InputMultiplexer;
import com.badlogic.gdx.utils.Array;

import net.mgsx.game.core.meta.KitMeta;
import net.mgsx.game.core.meta.ReflectionCache;

public class Kit {

	public static final InputMultiplexer inputs = new InputMultiplexer();
	
	public static final KitMeta meta = new ReflectionCache();
	
	/**
	 * Game listeners allow hook in game workflow.
	 */
	public static final Array<KitGameListener> gameListeners = new Array<KitGameListener>();
	
	private static boolean exited = false;
	
	/**
	 * Exit application, all gameListeners will be called.
	 * @param e optional error causing the exit.
	 */
	public synchronized static void exit(Throwable e){
		if(!exited){
			exited = true;
			if(e != null){
				Gdx.app.error("KIT", "exiting because of unhandled error", e);
			}
			for(KitGameListener listener : gameListeners){
				try {
					listener.exit(e);
				} catch (Throwable e2) {
					Gdx.app.error("KIT", "error in exit hooks", e2);
				}
			}
			if(e != null){
				// don't re throw because GLThread only will end and app won't exit ..
				// throw new RuntimeException(e);
				Gdx.app.exit();
			}
		}
	}
}

@@ -22,16 +22,69 @@
 .core;%0A%0A
+import com.badlogic.gdx.Application.ApplicationType;%0A
 import c
@@ -187,48 +187,114 @@
 ay;%0A
-%0A
 import 
-net.mgsx.game.core.meta.KitMeta;
+com.badlogic.gdx.utils.GdxRuntimeException;%0Aimport com.badlogic.gdx.utils.reflect.ClassReflection;%0A
 %0Aimp
@@ -321,31 +321,23 @@
 re.meta.
-ReflectionCache
+KitMeta
 ;%0A%0Apubli
@@ -439,22 +439,16 @@
  static 
-final 
 KitMeta 
@@ -455,32 +455,8 @@
 meta
- = new ReflectionCache()
 ;%0A%09%0A
@@ -643,24 +643,313 @@
  = false;%0A%09%0A
+%09static%7B%0A%09%09if(Gdx.app.getType() == ApplicationType.WebGL)%7B%0A%09%09%09meta = null;%0A%09%09%7Delse%7B%0A%09%09%09try %7B%0A%09%09%09%09meta = (KitMeta)ClassReflection.newInstance(ClassReflection.forName(%22net.mgsx.game.core.meta.ReflectionCache%22));%0A%09%09%09%7D catch (Exception e) %7B%0A%09%09%09%09throw new GdxRuntimeException(e);%0A%09%09%09%7D%0A%09%09%7D%0A%09%7D%0A%09%0A
 %09/**%0A%09 * Exi

make Kit class gwt compatible