private float GetSpaceUsed(Technology whichTech, bool useSecondary)
 {
     Equipment equipment = new Equipment(whichTech, useSecondary);
     return equipment.GetSize(_techLevels, _shipDesign.Size) + equipment.GetPower(_shipDesign.Size) * _spacePerPower;
 }
        private bool AtLeastOneHigherLevelSpecial(Equipment special, float remainingSpace)
        {
            float currentSpecialSpaceUsage = 0;
            int index = -1;
            if (special != null)
            {
                currentSpecialSpaceUsage = special.GetSize(_techLevels, _shipDesign.Size);
                index = _availableSpecialTechs.IndexOf(special.Technology);
            }
            float totalAvailableSpace = currentSpecialSpaceUsage + remainingSpace;

            for (int i = index + 1; i < _availableSpecialTechs.Count; i++)
            {
                if (GetSpaceUsed(_availableSpecialTechs[i], false) <= totalAvailableSpace)
                {
                    return true;
                }
            }
            return false;
        }
 private bool AtLeastOneBetterEngine(float remainingSpace)
 {
     if (_shipDesign.Engine.Key.Technology == _availableEngineTechs[_availableEngineTechs.Count - 1])
     {
         //Already the best engine
         return false;
     }
     int index = _availableEngineTechs.IndexOf(_shipDesign.Engine.Key.Technology) + 1; //Just one level higher will suffice
     Equipment engine = new Equipment(_availableEngineTechs[index], false);
     float totalSpace = (engine.GetSize(_techLevels, _shipDesign.Size) / (engine.Technology.Speed * 10)) * _shipDesign.PowerUsed;
     return totalSpace <= remainingSpace;
 }
        private bool AtLeastOneBetterWeapon(KeyValuePair<Equipment, int> weapon, float remainingSpace)
        {
            float currentWeaponSpaceUsage = 0;
            int index = -1;
            if (weapon.Key != null)
            {
                currentWeaponSpaceUsage = weapon.Key.GetSize(_techLevels, _shipDesign.Size) * weapon.Value;
                index = _availableWeaponTechs.IndexOf(weapon.Key.Technology);
            }
            float totalAvailableSpace = remainingSpace + currentWeaponSpaceUsage;

            if (weapon.Key != null && !weapon.Key.UseSecondary && weapon.Key.Technology.MaximumSecondaryWeaponDamage > 0)
            {
                //There is a bigger version of the weapon, see if there's room for it
                Equipment bigWeapon = new Equipment(weapon.Key.Technology, true);
                if (bigWeapon.GetSize(_techLevels, _shipDesign.Size) <= totalAvailableSpace)
                {
                    return true;
                }
            }
            for (int i = index + 1; i < _availableWeaponTechs.Count; i++)
            {
                if (GetSpaceUsed(_availableWeaponTechs[i], false) <= totalAvailableSpace)
                {
                    return true;
                }
            }
            return false;
        }
 private bool AtLeastOneBetterArmor(float remainingSpace)
 {
     if (_shipDesign.Armor.Technology == _availableArmorTechs[_availableArmorTechs.Count - 1])
     {
         if (_shipDesign.Armor.UseSecondary)
         {
             //Already the best armor with double hull
             return false;
         }
         Equipment armor = new Equipment(_shipDesign.Armor.Technology, true);
         return armor.GetSize(_techLevels, _shipDesign.Size) <= remainingSpace;
     }
     int index = _availableArmorTechs.IndexOf(_shipDesign.Armor.Technology) + 1; //Just one level higher will suffice
     return GetSpaceUsed(_availableArmorTechs[index], false) <= remainingSpace;
 }