package net.mostlyoriginal.api.screen.core;

import com.artemis.World;
import com.badlogic.gdx.Screen;
import com.badlogic.gdx.math.MathUtils;

/**
 * @author Daan van Yperen
 */
public abstract class WorldScreen implements Screen {

	public static final float MIN_DELTA = 1 / 15f;
	protected final World world;

	public WorldScreen() {
		world = createWorld();
	}

	protected abstract World createWorld();

	@Override
	public void show() {
	}

	@Override
	public void render(float delta) {
		if ( world == null ) {
			throw new RuntimeException("World not initialized.");
		}
		// Prevent spikes in delta from causing insane world updates.
		world.setDelta(MathUtils.clamp(delta, 0, MIN_DELTA));
		world.process();
	}

	@Override
	public void resize(int width, int height) {

	}

	@Override
	public void pause() {

	}

	@Override
	public void resume() {

	}

	@Override
	public void hide() {

	}

	@Override
	public void dispose() {

	}

}

@@ -286,22 +286,16 @@
 otected 
-final 
 World wo
@@ -299,16 +299,16 @@
  world;%0A
+
 %0A%09public
@@ -328,33 +328,8 @@
 ) %7B%0A
-%09%09world = createWorld();%0A
 %09%7D%0A%0A
@@ -373,32 +373,32 @@
 ();%0A%0A%09@Override%0A
-
 %09public void sho
@@ -399,24 +399,81 @@
 id show() %7B%0A
+%09%09if ( world == null )%0A%09%09%7B%0A%09%09%09world = createWorld();%0A%09%09%7D%0A
 %09%7D%0A%0A%09@Overri

Move world initialization to WorldScreen#show.