// Path: core/src/main/java/org/mini2Dx/miniscript/core/ScriptInvocationListener.java
// public interface ScriptInvocationListener {
// 	/**
// 	 * Called just before a script begins execution. Note: If callOnGameThread() is true,
// 	 * the script will not begin until this callback is processed on the game thread
// 	 * @param scriptId The script id
// 	 */
// 	public default void onScriptBegin(int scriptId) {
// 
// 	}
// 
// 	/**
// 	 * Called when a script is cancelled while in the invoke queue.
// 	 *
// 	 * @param scriptId The script id
// 	 */
// 	public default void onScriptCancelled(int scriptId) {
// 	}
// 
// 	/**
// 	 * Called when a script successfully completes
// 	 * 
// 	 * @param scriptId
// 	 *            The script id
// 	 * @param executionResult
// 	 *            The variable bindings after execution
// 	 */
// 	public void onScriptSuccess(int scriptId, ScriptExecutionResult executionResult);
// 
// 	/**
// 	 * Called when a script is skipped during execution
// 	 * 
// 	 * @param scriptId
// 	 *            The script id
// 	 */
// 	public void onScriptSkipped(int scriptId);
// 
// 	/**
// 	 * Called when an exception occurs during script execution
// 	 * 
// 	 * @param scriptId
// 	 *            The script id
// 	 * @param e
// 	 *            The exception that occurred
// 	 */
// 	public void onScriptException(int scriptId, Exception e);
// 
// 	/**
// 	 * Returns if this {@link ScriptInvocationListener} should be notified on
// 	 * the game thread
// 	 * 
// 	 * @return False if this should be notified on the
// 	 *         {@link GameScriptingEngine} thread pool
// 	 */
// 	public boolean callOnGameThread();
// }


import org.mini2Dx.miniscript.core.ScriptInvocationListener;
import java.util.concurrent.atomic.AtomicBoolean;
/**
 * The MIT License (MIT)
 * 
 * Copyright (c) 2016 Thomas Cashman
 * 
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 * 
 * The above copyright notice and this permission notice shall be included in all
 * copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 * SOFTWARE.
 */
package org.mini2Dx.miniscript.core.notification;



/**
 *
 */
public class ScriptExceptionNotification implements ScriptNotification {
	private final ScriptInvocationListener invocationListener;
	private final int scriptId;
	private final Exception exception;
	private final AtomicBoolean notified = new AtomicBoolean(false);

	public ScriptExceptionNotification(ScriptInvocationListener invocationListener, int scriptId, Exception exception) {
		this.invocationListener = invocationListener;
// Path: core/src/main/java/org/mini2Dx/miniscript/core/ScriptInvocationListener.java
// public interface ScriptInvocationListener {
// 	/**
// 	 * Called just before a script begins execution. Note: If callOnGameThread() is true,
// 	 * the script will not begin until this callback is processed on the game thread
// 	 * @param scriptId The script id
// 	 */
// 	public default void onScriptBegin(int scriptId) {
// 
// 	}
// 
// 	/**
// 	 * Called when a script is cancelled while in the invoke queue.
// 	 *
// 	 * @param scriptId The script id
// 	 */
// 	public default void onScriptCancelled(int scriptId) {
// 	}
// 
// 	/**
// 	 * Called when a script successfully completes
// 	 * 
// 	 * @param scriptId
// 	 *            The script id
// 	 * @param executionResult
// 	 *            The variable bindings after execution
// 	 */
// 	public void onScriptSuccess(int scriptId, ScriptExecutionResult executionResult);
// 
// 	/**
// 	 * Called when a script is skipped during execution
// 	 * 
// 	 * @param scriptId
// 	 *            The script id
// 	 */
// 	public void onScriptSkipped(int scriptId);
// 
// 	/**
// 	 * Called when an exception occurs during script execution
// 	 * 
// 	 * @param scriptId
// 	 *            The script id
// 	 * @param e
// 	 *            The exception that occurred
// 	 */
// 	public void onScriptException(int scriptId, Exception e);
// 
// 	/**
// 	 * Returns if this {@link ScriptInvocationListener} should be notified on
// 	 * the game thread
// 	 * 
// 	 * @return False if this should be notified on the
// 	 *         {@link GameScriptingEngine} thread pool
// 	 */
// 	public boolean callOnGameThread();
// }


// Path: core/src/main/java/org/mini2Dx/miniscript/core/notification/ScriptExceptionNotification.java
import org.mini2Dx.miniscript.core.ScriptInvocationListener;
import java.util.concurrent.atomic.AtomicBoolean;

/**
 * The MIT License (MIT)
 * 
 * Copyright (c) 2016 Thomas Cashman
 * 
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 * 
 * The above copyright notice and this permission notice shall be included in all
 * copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 * SOFTWARE.
 */
package org.mini2Dx.miniscript.core.notification;



/**
 *
 */
public class ScriptExceptionNotification implements ScriptNotification {
	private final ScriptInvocationListener invocationListener;
	private final int scriptId;
	private final Exception exception;
	private final AtomicBoolean notified = new AtomicBoolean(false);

	public ScriptExceptionNotification(ScriptInvocationListener invocationListener, int scriptId, Exception exception) {
		this.invocationListener = invocationListener;
		this.scriptId = scriptId;