package me.benjozork.onyx.internal;

import com.badlogic.gdx.Screen;
import com.badlogic.gdx.graphics.OrthographicCamera;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.graphics.glutils.ShapeRenderer;

import me.benjozork.onyx.entity.EntityPlayer;
import me.benjozork.onyx.screen.GameScreen;

/**
 * Created by Benjozork on 2017-03-19.
 */
public class GameManager {

    /**
     * The camera instance that is used when rendering world objects
     */
    private static OrthographicCamera worldCamera;

    /**
     * The camera instance that is used when rendering gui objects
     */
    private static OrthographicCamera guiCamera;

    private static Screen currentScreen;

    private static ShapeRenderer renderer;

    private static SpriteBatch batch;

    private static EntityPlayer player;

    /**
     * The camera instance that is used when rendering world objects
     *
     * @return the world camera
     */
    public static OrthographicCamera getWorldCamera() {
        return worldCamera;
    }

    /**
     * Set the camera instance to be used when rendering world objects
     *
     * @param worldCamera the camera instance to be used
     */
    public static void setWorldCamera(OrthographicCamera worldCamera) {
        GameManager.worldCamera = worldCamera;
    }

    /**
     * The camera instance that is used when rendering gui objects
     *
     * @return the gui camera
     */
    public static OrthographicCamera getGuiCamera() {
        return guiCamera;
    }

    /**
     * Set the camera instance to be used when rendering gui objects
     *
     * @param guiCamera the camera instance to be used
     */
    public static void setGuiCamera(OrthographicCamera guiCamera) {
        GameManager.guiCamera = guiCamera;
    }

    public static Screen getCurrentScreen() {
        return currentScreen;
    }

    public static void setCurrentScreen(Screen currentScreen) {
        Logger.log("Changed screen to " + currentScreen.getClass().getName().replace("me.benjozork.onyx.screen.", ""));
        GameManager.currentScreen = currentScreen;
    }

    /**
     * The ShapeRenderer
     *
     * @return the ShapeRenderer
     */
    public static ShapeRenderer getShapeRenderer() {
        return renderer;
    }

    /**
     * Set the ShapeRenderer
     *
     * @param renderer the ShapeRenderer to be used
     */
    public static void setRenderer(ShapeRenderer renderer) {
        GameManager.renderer = renderer;
    }

    /**
     * The SpriteBatch
     *
     * @return the SpriteBatch
     */
    public static SpriteBatch getBatch() {
        return batch;
    }

    /**
     * Set the SpriteBatch
     *
     * @param batch the SpriteBatch to be used
     */
    public static void setBatch(SpriteBatch batch) {
        GameManager.batch = batch;
    }

    public static void setIsRendering(boolean v) {
        if (v) if (! batch.isDrawing()) batch.begin();
        if (! v) if (batch.isDrawing()) batch.end();
    }

    /**
     * The player entity used for GameScreen logic
     * @throws IllegalStateException
     * @return the player
     */
    public static EntityPlayer getPlayer() {
        if (currentScreen instanceof GameScreen) return player;
        else throw new IllegalStateException("player does not exist in this screen");
    }

    /**
     * Sets the player instance
     * @param player the player instance to be used
     */
    public static void setPlayer(EntityPlayer player) {
        GameManager.player = player;
    }
}

@@ -324,43 +324,114 @@
 %0A * 
-Created by Benjozork on 2017-03-19.
+Manages %7B@link SpriteBatch%7Des, %7B@link OrthographicCamera%7Ds and %7B@link ShapeRenderer%7Ds%0A * @author Benjozork
 %0A */
@@ -733,50 +733,8 @@
 a;%0A%0A
-    private static Screen currentScreen;%0A%0A
     
@@ -1821,333 +1821,8 @@
  %7D%0A%0A
-    public static Screen getCurrentScreen() %7B%0A        return currentScreen;%0A    %7D%0A%0A    public static void setCurrentScreen(Screen currentScreen) %7B%0A        Logger.log(%22Changed screen to %22 + currentScreen.getClass().getName().replace(%22me.benjozork.onyx.screen.%22, %22%22));%0A        GameManager.currentScreen = currentScreen;%0A    %7D%0A%0A
     
@@ -2890,17 +2890,34 @@
     if (
-c
+ScreenManager.getC
 urrentSc
@@ -2920,16 +2920,18 @@
 ntScreen
+()
  instanc

change file template, move screen methods to ScreenManager