using System.Collections.Generic;

public abstract class Unit {
	protected int id;
	protected Class unitClass;
	protected UnitModules modules;

	public Unit(Class unitClass) {
		this.unitClass = unitClass;
		id = Util.freshId();

		modules = new UnitModules(this.getID(), unitClass);
	}

	public Unit(Unit oldUnit) {
		this.unitClass = oldUnit.getClass();
		id = oldUnit.getID();

		modules = oldUnit.modules;
	}

	public Unit(int id, string className) {
		this.unitClass = GameController.classFromUniqueName(className);
		this.id = id;

		modules = new UnitModules(this.getID(), unitClass, false);
	}

	public int getID() {
		return id;
	}

	public Class getClass() {
		return unitClass;
	}

	public Country getOwner() {
		return unitClass.getCountry();
	}

	public List<Tuple<Module, ModuleData>> getModules() {
		return modules.getModules();
	}

	public void addReadyToLaunch(StoredUnit stored) {
		modules.addReadyToLaunch(stored);
	}

	public void addToStorage(StoredUnit stored) {
		modules.addToStorage(stored);
	}

	public void store(StoredUnit stored) {
		modules.store(stored);
	}

	public void updateModulesTime(float delta) {
		modules.updateModulesTime(delta);
	}

	public void updateModulesState() {
		modules.updateModulesState();
	}

	public void setNewStore(int storedUnitID, int newStoreID) {
		modules.setNewStore(storedUnitID, newStoreID);
	}

	public bool hasFuelLeft(FuelType type) {
		return modules.getFuelAmount(type) > 0.0f;
	}

	public bool hasRadarOn() {
		return modules.hasRadarOn();
	}

	public float getMinSpeed() {
		return modules.getMinSpeed();
	}

	public float getMaxSpeed() {
		return modules.getMaxSpeed();
	}

	public float getMinAltitude() {
		return modules.getMinAltitude();
	}

	public float getMaxAltitude() {
		return modules.getMaxAltitude();
	}

	//SHOULD ONLY BE CALLED BY NETWORK MANAGER, WHEN RECEIVING A CREATE MODULE DATA COMMAND
	public void addModuleData(ModuleData data) {
		modules.addModuleData(data);
	}
}
