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

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"]);

		icon = Resources.Load("Sprites/Modules/Icons/FuelTanks/" + getUniqueName(), typeof(Sprite)) as Sprite;
		silhouette = Resources.Load("Sprites/Modules/Silhouettes/FuelTanks/" + getUniqueName(), typeof(Sprite)) as Sprite;
	}

	public float getFuelQuantity() {
		return fuelQuantity;
	}

	public FuelType getFuelType() {
		return fuelType;
	}

	public static FuelTankModule[] loadModules(string[] filenames) {
		Array.Sort(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, float angleOffset, Vector position) {
		return new FuelTankModuleData(parent, this, position);
	}
}

public class FuelTankModuleData : ModuleData{
	private float fuelLeft;

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

	public float getFuelLeft() {
		return fuelLeft;
	}

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