import java.io.Serializable;

import java.net.InetAddress;
import java.net.UnknownHostException;

/**
 * Actors' primary behavior, with the standard available methods.
 * Extended by automatically-generated abstract users' base-level classes
 * defining become(). Can be directly implemented by users' base-level classes
 * (using becomeAny() only).
 *
 * @version 0.6.0
 */
public abstract class QuasiBehavior implements Serializable {

	/** Reference of the owner actor */
	private transient Agent refToMyEgo;
	private transient Controler myControler = null;

	/**
	 * Creates a new QuasiBehavior.
	 */
	public QuasiBehavior() {
	}

	/**
	 * Allows the reference to the owner Controler to be set in the behavior.
	 *
	 * @param c the owner Controler
	 */
	protected final void setMyControler(Controler c) {
		myControler = c;
		refToMyEgo = myControler.getMyAgent();
	}


	/**
	 * Get the reference of the owner actor
	 *
	 * @return the reference of the owner agent
	 */
	protected final Agent mySelf() {
		return refToMyEgo;
	}

	/**
	 * Get the place whereon the owner actor is located.  The port is included
	 * since v4.1
	 *
	 * @return the place (an URL as a String)
	 */
	protected final String myPlace() {
		String aux = null;
		String port;

		try {
			aux = InetAddress.getLocalHost().getHostName();
			port = System.getProperty("JAVACT_PORT");

			if (port != null)
				aux += port;
		} catch (UnknownHostException e) {
			System.out.println("Exception -> ");
			e.printStackTrace();
		}

		return aux;
	}

	//----------------------------------------- GENERATED CODE ------------------------------------------

	protected final float getHeading() { return myControler.getHeading(); }

	protected final java.lang.String getLatitude() { return myControler.getLatitude(); }

	protected final java.lang.String getLongitude() { return myControler.getLongitude(); }

	protected final float getSpeed() { return myControler.getSpeed(); }

	protected final boolean connect(java.lang.String _p0) { return myControler.connect(_p0); }

	protected final float getHeight() { return myControler.getHeight(); }

	protected final boolean isConnected() { return myControler.isConnected(); }

	protected final void disconnect() { myControler.disconnect(); }


	//%%METHODS%%

}
