public void AddAbility()
    {
        if (string.IsNullOrEmpty(MassInput.text))
        {
            Debug.LogError("Must set mass before adding ability.");
            return;
        }
        List <float> inputs = new List <float>();

        foreach (InputField f in InputFields)
        {
            float  i = 0;
            string s = f.text;
            if (!String.IsNullOrEmpty(s))
            {
                i = float.Parse(s);
            }
            inputs.Add(i);
        }
        Comp.AddAbility(CurrentAbilityCat(), inputs[0], inputs[1], inputs[2]);
        ResetInputs();
    }
    public void LoadComponents()
    {
        string        path       = "Assets/Output/Components/Components.txt";
        string        file       = File.ReadAllText(path);
        List <string> components = new List <string>();

        components.AddRange(file.Split('#'));

        foreach (string s in components)
        {
            if (string.IsNullOrEmpty(s))
            {
                continue;
            }

            //	Debug.LogError(s); //ok

            ShipComponents c         = new ShipComponents();
            string         fields    = s.Split('$')[0];
            string         abilities = s.Split('$')[1];

            //	Debug.LogError(fields); //ok

            List <string> FieldsSplit = new List <string>();
            FieldsSplit.AddRange(fields.Split('\n'));

            //	Debug.LogError(FieldsSplit.Count);

            Debug.LogWarning(FieldsSplit[3]);


            for (int i = 1; i < FieldsSplit.Count; i++)
            {
                if (string.IsNullOrEmpty(FieldsSplit[i]))
                {
                    continue;
                }
                string cleaned = FieldsSplit[i].Split(':')[1].Trim();
                FieldsSplit[i] = cleaned;
            }

            FieldsSplit.RemoveAt(0);
            //	Debug.LogError(FieldsSplit[0]);

            try
            {
                c.Name = FieldsSplit[0].ToString();
            }
            catch
            {
                Debug.LogError(FieldsSplit[0].ToString());
            }
            try
            {
                c.Description = FieldsSplit[1].ToString();
            }
            catch
            {
                Debug.LogError(FieldsSplit[1].ToString());
            }
            try
            {
                //	c.Category = Enum.Parse(, fields[2].ToString());
            }
            catch
            {
                Debug.LogError(FieldsSplit[2].ToString());
            }
            try
            {
                c.Mass = int.Parse(FieldsSplit[3].ToString());
            }
            catch
            {
                Debug.LogError(FieldsSplit[3].ToString());
            }
            try
            {
                c.CrewRequired = int.Parse(FieldsSplit[4].ToString());
            }
            catch
            {
                Debug.LogError(FieldsSplit[4].ToString());
            }
            try
            {
                c.MaintReq = int.Parse(FieldsSplit[5].ToString());
            }
            catch
            {
                Debug.LogError(FieldsSplit[5].ToString());
            }

            List <string> AbilitiesSplit = new List <string>();
            AbilitiesSplit.AddRange(abilities.Trim().Split('\n'));
            //AbilitiesSplit.RemoveAt(0);
            Debug.LogError(c.Name + " has " + AbilitiesSplit.Count);
            foreach (string m in AbilitiesSplit)
            {
                if (string.IsNullOrEmpty(m))
                {
                    continue;
                }
                List <string> split = new List <string>();
                split.AddRange(m.Trim().Split('|'));
                Debug.LogError(split[0]);

                try
                {
                    c.AddAbility((AbilityCats)int.Parse(split[0]), float.Parse(split[2]), float.Parse(split[4]), float.Parse(split[6]));
                }
                catch
                {
                    c.AddAbility((AbilityCats)Enum.Parse(typeof(AbilityCats), (split[0].Trim())), float.Parse(split[2]), float.Parse(split[4]), float.Parse(split[6]));
                }
            }
            LoadedComponents.AddExclusive(c);
            ShipComponents.AllShipComponents.AddExclusive(c);
        }
        if (LoadedComponents.Count > 0)
        {
            //	LoadComponentToScreen(LoadedComponents[0]);
        }

        SetupButtons();
    }
    // Use this for initialization
    void Start()
    {
        //Design test component
        ShipComponents c = new ShipComponents();

        c.Name         = "Heavy Test";
        c.Mass         = 500;
        c.CrewRequired = 200;
        c.SetHTK(3);

        ShipComponents b = new ShipComponents();

        b.Name         = "Light Test";
        b.Mass         = 250;
        b.CrewRequired = 50;
        b.SetHTK(2);

        ShipComponents bridge = new ShipComponents();

        bridge.Name         = "Bridge";
        bridge.Mass         = 50;
        bridge.CrewRequired = 15;
        bridge.AddAbility(AbilityCats.CONTROL);
        bridge.Category    = CompCategory.REQUIRED;
        bridge.Description = "A command and control center for the ship's officers.";

        ShipComponents MilEngine = new ShipComponents();

        MilEngine.Category     = CompCategory.ENGINE;
        MilEngine.Name         = "MilEngine Mk1";
        MilEngine.CrewRequired = 50;
        MilEngine.Mass         = 200;
        MilEngine.AddAbility(AbilityCats.THRUST, (float)EngineTypes.MAGNETO, 2f, 1f);
        MilEngine.AddAbility(AbilityCats.USEFUEL, (float)EngineTypes.MAGNETO * MilEngine.Mass * 5f);
        MilEngine.Description = "An engine designed for maximum thrust with minimum weight.";

        ShipComponents CivEngine = new ShipComponents();

        CivEngine.Name         = "CivEngine Mk1";
        CivEngine.Category     = CompCategory.ENGINE;
        CivEngine.CrewRequired = 125;
        CivEngine.Mass         = 500;
        CivEngine.AddAbility(AbilityCats.THRUST, (float)EngineTypes.MAGNETO, .75f, 1f);
        CivEngine.AddAbility(AbilityCats.USEFUEL, (float)EngineTypes.MAGNETO * CivEngine.Mass);
        CivEngine.Description = "An engine designed for efficiency.";

        ShipComponents turnThruster = new ShipComponents();

        turnThruster.Name = "Manuevering Thruster";
        turnThruster.AddAbility(AbilityCats.TURN, 35f);
        turnThruster.Mass         = 25;
        turnThruster.CrewRequired = 10;
        turnThruster.Category     = CompCategory.DEFAULT;
        turnThruster.Description  = "Small thruster mounted on the exterior in order to improve turn rates.";

        ShipComponents berths = new ShipComponents();

        berths.Name = "Crew Quarters";
        berths.Mass = 100;
        berths.AddAbility(AbilityCats.CREW, 100);
        berths.Category    = CompCategory.REQUIRED;
        berths.Description = "Area for the crew to sleep, eat and pray.";

        ShipComponents smBerths = new ShipComponents();

        smBerths.Name = "Crew Quarters (S)";
        smBerths.Mass = 10;
        smBerths.AddAbility(AbilityCats.CREW, 10);
        smBerths.Category    = CompCategory.REQUIRED;
        smBerths.Description = "Small area for the crew to sleep, eat and pray.";

        ShipComponents Engineering = new ShipComponents();

        Engineering.Name         = "Engineering Section";
        Engineering.Mass         = 35;
        Engineering.CrewRequired = 15;
        Engineering.AddAbility(AbilityCats.MAINT, Engineering.Mass, 25f, 25f);
        Engineering.Category    = CompCategory.UTILITY;
        Engineering.Description = "Provides engineering personnel and equipment to keep the ship in functional condition.";

        ShipComponents SparePartsLocker = new ShipComponents();

        SparePartsLocker.Name         = "Maintenance Locker";
        SparePartsLocker.Mass         = 25;
        SparePartsLocker.CrewRequired = 15;
        SparePartsLocker.AddAbility(AbilityCats.MAINT, 0, 50f, 50f);
        SparePartsLocker.Category    = CompCategory.UTILITY;
        SparePartsLocker.Description = "Contains a reserve of maintenance supplies.";

        ShipComponents CargoHoldLarge = new ShipComponents();

        CargoHoldLarge.Name         = "Cargo Hold";
        CargoHoldLarge.Mass         = 250;
        CargoHoldLarge.CrewRequired = 0;
        CargoHoldLarge.AddAbility(AbilityCats.CARGO, 100f, 0f, 0f);
        CargoHoldLarge.Category    = CompCategory.UTILITY;
        CargoHoldLarge.Description = "Empty space and the infrastructure needed to service it.";


        ShipComponents CargoHoldSmall = new ShipComponents();

        CargoHoldSmall.Name         = "Cargo Hold (S)";
        CargoHoldSmall.Mass         = 25;
        CargoHoldSmall.CrewRequired = 0;
        CargoHoldSmall.AddAbility(AbilityCats.CARGO, 10f, 0f, 0f);
        CargoHoldSmall.Category    = CompCategory.UTILITY;
        CargoHoldSmall.Description = "Empty space and the infrastructure needed to service it.";

        ShipComponents FuelLarge = new ShipComponents();

        FuelLarge.Name         = "Fuel Cell";
        FuelLarge.Mass         = 150;
        FuelLarge.CrewRequired = 0;
        FuelLarge.AddAbility(AbilityCats.FUEL, 10000f, 0f, 0f);
        FuelLarge.Category    = CompCategory.UTILITY;
        FuelLarge.Description = "A refillable fuel cell used to power modern engines.";


        ShipComponents FuelSmall = new ShipComponents();

        FuelSmall.Name         = "Fuel Cell (S)";
        FuelSmall.Mass         = 15;
        FuelSmall.CrewRequired = 0;
        FuelSmall.AddAbility(AbilityCats.FUEL, 1000f, 0f, 0f);
        FuelSmall.Category    = CompCategory.UTILITY;
        FuelSmall.Description = "A small fuel cell for lighter craft.";

        ShipComponents.AddComponentToPublicDomain(FuelSmall);
        ShipComponents.AddComponentToPublicDomain(FuelLarge);
        ShipComponents.AddComponentToPublicDomain(CargoHoldSmall);
        ShipComponents.AddComponentToPublicDomain(CargoHoldLarge);
        ShipComponents.AddComponentToPublicDomain(SparePartsLocker);


        ShipComponents.AddComponentToPublicDomain(bridge);
        ShipComponents.AddComponentToPublicDomain(smBerths);
        ShipComponents.AddComponentToPublicDomain(Engineering);
        ShipComponents.AddComponentToPublicDomain(berths);
        ShipComponents.AddComponentToPublicDomain(turnThruster);
        ShipComponents.AddComponentToPublicDomain(CivEngine);


        ShipComponents.AddComponentToPublicDomain(MilEngine);
        ShipComponents.AddComponentToPublicDomain(c);
        ShipComponents.AddComponentToPublicDomain(b);

        ShipComponents.AllShipComponents.Add(FuelSmall);
        ShipComponents.AllShipComponents.Add(FuelLarge);
        ShipComponents.AllShipComponents.Add(CargoHoldSmall);
        ShipComponents.AllShipComponents.Add(CargoHoldLarge);
        ShipComponents.AllShipComponents.Add(SparePartsLocker);


        ShipComponents.AllShipComponents.Add(bridge);
        ShipComponents.AllShipComponents.Add(smBerths);
        ShipComponents.AllShipComponents.Add(Engineering);
        ShipComponents.AllShipComponents.Add(berths);
        ShipComponents.AllShipComponents.Add(turnThruster);
        ShipComponents.AllShipComponents.Add(CivEngine);


        ShipComponents.AllShipComponents.Add(MilEngine);
        ShipComponents.AllShipComponents.Add(c);
        ShipComponents.AllShipComponents.Add(b);

        DesignScreenManager.LoadAllComponents = true;
    }