package de.rico.adventure.actions.custom;

import javax.media.opengl.GL;

import de.rico.adventure.actions.AbstractAction;
import de.rico.adventure.actions.ActionScheduler;
import de.rico.adventure.script.ScriptInterpreter;

/**
 * This action can be used to run script code in a queuee manner.
 * @author Frank Bruns
 *
 */
public class RunCode extends AbstractAction
{
	private String code = null;
	private ScriptInterpreter interpreter = null;

	/**
	 * Creates a new RunCode game action with the specified parameters.
	 * @param code code that ought to be executed
	 * @param inter script interpreter to use for running the code
	 */
	public RunCode(String code, ScriptInterpreter inter)
	{
		this.code = code;
		this.interpreter = inter;
	}

	/* (non-Javadoc)
	 * @see de.rico.adventure.actions.AbstractAction#update(long)
	 */
	@Override
	public void update(long elapsedTime)
	{
		this.interpreter.runCode(this.code);

		ActionScheduler.getInstance().removeFirst();
	}

	/* (non-Javadoc)
	 * @see de.rico.adventure.actions.AbstractAction#draw(javax.media.opengl.GL)
	 */
	@Override
	public void draw(GL gl)
	{
		// TODO Auto-generated method stub

	}

	/* (non-Javadoc)
	 * @see de.rico.adventure.actions.AbstractAction#finishUp()
	 */
	@Override
	public void finishUp()
	{
		// TODO Auto-generated method stub

	}
}
