public class StoredUnit : Unit {
	private ModuleData store;
	private bool beingLoaded;

	public StoredUnit(Class unitClass) : base(unitClass) {
		beingLoaded = false;
		GameController.addStoredUnit(this);
	}

	public StoredUnit(DeployedUnit deployed) : base(deployed) {
		beingLoaded = false;
		GameController.addStoredUnit(this);
	}

	public void changeStore(ModuleData store) {
		if (this.store == store) {
			return;
		}

		removeFromStore();

		this.store = store;

		if (store is LauncherModuleData) {
			((LauncherModuleData)store).addReadyToLaunch(this);
		}
		else if (store is StorageModuleData) {
			((StorageModuleData)store).addToStored(this);
		}
	}

	public void removeFromStore() {
		if (store == null) {
			return;
		}

		if (store is LauncherModuleData) {
			((LauncherModuleData)store).removeFromReady(this);
		}
		else if (store is StorageModuleData) {
			((StorageModuleData)store).removeFromStored(this);
		}

		store = null;
	}

	public ModuleData getStore() {
		return store;
	}

	public bool isBeingLoaded() {
		return beingLoaded;
	}

	public void setBeingLoaded(bool val) {
		beingLoaded = val;
	}

	//Adds the corresponding DeployedUnit to the game
	public DeployedUnit deploy() {
		Vertex position = GameController.fromID(store.getParent()).getPosition();

		DeployedUnit deployed = new DeployedUnit(this, position);
		GameController.addDeployedUnit(deployed);
		GameController.removedStoredUnit(this);

		return deployed;
	}
}
