using Newtonsoft.Json.Linq;
using System.Collections.Generic;
using UnityEngine;

public enum FuelType {None = -1, ShipFuel = 0};

public class FuelTankModule : Module {
	private FuelType fuelType;
	private float fuelQuantity;

	public FuelTankModule(JObject json) : base(json) {
		fuelType = (FuelType)((int)json["fuelType"] - 1);
		fuelQuantity = (float)(json["fuelQuantity"]);

		sprite = Resources.Load("Sprites/Modules/FuelTanks/" + getUniqueName(), typeof(Sprite)) as Sprite;
	}

	public float getFuelQuantity() {
		return fuelQuantity;
	}

	public FuelType getFuelType() {
		return fuelType;
	}

	public static FuelTankModule[] loadModules(string[] filenames) {
		FuelTankModule[] array = new FuelTankModule[filenames.Length];

		for (int i = 0; i < filenames.Length; i++) {
			array[i] = new FuelTankModule(jsonFromFile(filenames[i]));
		}

		return array;
	}

	override public bool canBeDisabled() {
		return false;
	}

	override public void updateClasses() {
	}

	override public ModuleData getData(int parent) {
		return new FuelTankModuleData(parent, this);
	}
}

public class FuelTankModuleData : ModuleData{
	private float fuelLeft;

	public FuelTankModuleData(int parent, Module template) : base(parent, template) {
		fuelLeft = ((FuelTankModule)template).getFuelQuantity();
	}

	public float getFuelLeft() {
		return fuelLeft;
	}

	public void setFuelLeft(float amount) {
		fuelLeft = amount;
	}

	override public void deployUnit(int storedUnitID) {
		Debug.LogError("This module cannot deploy units");
	}
}