package ei.engine.state;

import ei.engine.input.InputHandler;
import ei.engine.util.MultiPrintStream;

public abstract class GameState {
	private String name;
	private InputHandler input;
	private boolean enabled = false;
	
	public GameState(String name){
		this.name = name;
		input = new InputHandler();
	}
	
	/**
	 * Returns the input handler of this state
	 * 
	 * @return The input handler
	 */
	public InputHandler getInput(){
		return input;
	}
	
	/**
	 * set if this State is enabled
	 * @param b
	 */
	public void setEnabled(boolean b){
		enabled = b;
		MultiPrintStream.out.println("Enabling("+b+") State: "+getName());
	}
	
	/**
	 * @return the status of the GameState
	 */
	public boolean isEnabled(){
		return enabled;
	}
	
	/**
	 * @return the name of the GameState
	 */
	public String getName(){
		return name;
	}
	
	/**
	 * Updates the State
	 *
	 */
	public void stateUpdate(){
		input.update();
		update();
	}
	
	/**
	 * Renders the state
	 *
	 */
	public void stateRender(){
		render();
		input.render();
	}
	
	public abstract void update();
	
	public abstract void render();
}
