public void LoadFromFile()
    {
        string address = ModFolder;

        Debug.Log("Checking for: " + address);

        if (Directory.Exists(address))
        {
            Debug.Log(address + " exists!");
            try
            {
                Debug.Log("Checking for: " + address + @"\settings.json");
                string temp = File.ReadAllText(address + @"\settings.json");

                settings        = JsonConvert.DeserializeObject <CheesesAISettings>(temp);
                settingsChanged = false;
            }
            catch
            {
                Debug.Log("no json found, making one");
                SaveToFile();
            }
        }
        else
        {
            Debug.Log("Mod folder not found?");
        }
    }
    public override void ModLoaded()
    {
        HarmonyInstance harmony = HarmonyInstance.Create("cheese.cheesesAITweaks");

        harmony.PatchAll(Assembly.GetExecutingAssembly());

        Debug.Log("Patched the AI");

        instance = this;

        base.ModLoaded();
        VTOLAPI.SceneLoaded     += SceneLoaded;
        VTOLAPI.MissionReloaded += MissionReloaded;

        apToHelper = new Dictionary <AutoPilot, CheeseAIHelper>();
        aiToHelper = new Dictionary <AIPilot, CheeseAIHelper>();

        settings = new CheesesAISettings();
        LoadFromFile();

        StartCoroutine(LoadAssetBundle());

        Settings modSettings = new Settings(this);

        modSettings.CreateCustomLabel("Cheese's AI Tweaks Settings");

        modSettings.CreateCustomLabel("");

        modSettings.CreateCustomLabel("Control Noise Settings");
        modSettings.CreateCustomLabel("The control noise adds random noise to the AIs inputs, to make them seem more human");

        controlNoiseEnabled_changed += controlNoiseEnabled_Setting;
        modSettings.CreateCustomLabel("Control Noise Enabled:");
        modSettings.CreateBoolSetting("(Default = true)", controlNoiseEnabled_changed, settings.controlNoiseEnabled);

        controlNoiseIntensity_changed += controlNoiseIntensity_Setting;
        modSettings.CreateCustomLabel("Control Noise Intensity:");
        modSettings.CreateCustomLabel("This is the size of the noise added to the inputs");
        modSettings.CreateFloatSetting("(Default = 5%)", controlNoiseIntensity_changed, settings.controlNoiseIntensity * 100, 0, 100);

        controlNoiseFrequency_changed += controlNoiseFrequency_Setting;
        modSettings.CreateCustomLabel("Control Noise Frequency:");
        modSettings.CreateCustomLabel("This is the frequency at which the noise changes");
        modSettings.CreateFloatSetting("(Default = 2)", controlNoiseFrequency_changed, settings.controlNoiseFrequency, 1, 60);

        controlNoiseLargeAircraftFrequency_changed += controlNoiseLargeAircraftFrequency_Setting;
        modSettings.CreateCustomLabel("Control Noise Frequency:");
        modSettings.CreateCustomLabel("This is the frequency at which the noise changes for large aircraft");
        modSettings.CreateFloatSetting("(Default = 5)", controlNoiseLargeAircraftFrequency_changed, settings.controlNoiseLargeAircraftFrequency, 0, 60);

        controlNoiseLayers_changed += controlNoiseLayers_Setting;
        modSettings.CreateCustomLabel("Control Noise Layers:");
        modSettings.CreateCustomLabel("This is the ammount of perlin noise layers used to create the noise");
        modSettings.CreateIntSetting("(Default = 3)", controlNoiseLayers_changed, settings.controlNoiseLayers, 0, 5);

        allowRefuelingNoise_changed += allowRefuelingNoise_Setting;
        modSettings.CreateCustomLabel("Allow noise when refueling another aircraft:");
        modSettings.CreateCustomLabel("Makes air to air refueling much harder");
        modSettings.CreateBoolSetting("(Default = false)", allowRefuelingNoise_changed, settings.allowRefuelingNoise);

        /*formationDriftIntensity_changed += formationDriftIntensity_Setting;
         * modSettings.CreateCustomLabel("Formation Drift Intensity:");
         * modSettings.CreateCustomLabel("This is the radius the aircraft can drift from its target");
         * modSettings.CreateFloatSetting("(Default = 3m)", formationDriftIntensity_changed, settings.formationDriftIntensity, 0, 10);
         *
         * formationDriftFrequency_changed += formationDriftFrequency_Setting;
         * modSettings.CreateCustomLabel("Formation Drift Frequency:");
         * modSettings.CreateCustomLabel("This is the frequency at which the aircraft drifts in formation");
         * modSettings.CreateFloatSetting("(Default = 5)", formationDriftFrequency_changed, settings.formationDriftFrequency, 1, 60);*/

        modSettings.CreateCustomLabel("");


        rockWingsOnContact_changed += rockWingsOnContact_Setting;
        modSettings.CreateCustomLabel("Rock wings on contact:");
        modSettings.CreateBoolSetting("(Default = true)", rockWingsOnContact_changed, settings.rockWingsOnContact);

        modSettings.CreateCustomLabel("");


        dropTankMode_changed += dropTankMode_Setting;
        modSettings.CreateCustomLabel("Drop Tank Mode:");
        modSettings.CreateIntSetting("(Default = 0)", dropTankMode_changed, (int)settings.dropTankMode, 0, 1);
        modSettings.CreateCustomLabel("0 = Normal (Only drop when empty)");
        modSettings.CreateCustomLabel("1 = Drop On Contact");

        modSettings.CreateCustomLabel("");


        enemyEjectorSeats_changed += enemyEjectorSeats_Setting;
        modSettings.CreateCustomLabel("Enemy Aircraft Ejector Seats:");
        modSettings.CreateBoolSetting("(Default = true)", enemyEjectorSeats_changed, settings.enemyEjectorSeats);

        modSettings.CreateCustomLabel("");


        collisionMode_changed += collisionMode_Setting;
        modSettings.CreateCustomLabel("Collsion Mode:");
        modSettings.CreateIntSetting("(Default = 0)", collisionMode_changed, (int)settings.collisionMode, 0, 2);
        modSettings.CreateCustomLabel("0 = Normal");
        modSettings.CreateCustomLabel("1 = Always On");
        modSettings.CreateCustomLabel("2 = Always Off");

        modSettings.CreateCustomLabel("");

        modSettings.CreateCustomLabel("AI aircraft don't have collisions on the ground normally,");
        modSettings.CreateCustomLabel("You can enable them, but the AI could get stuck");
        modSettings.CreateCustomLabel("on missions with many taxiing aircraft");

        modSettings.CreateCustomLabel("");
        modSettings.CreateCustomLabel("Detection Settings");

        allAICanEvade_changed += allAICanEvade_Setting;
        modSettings.CreateCustomLabel("All AI can evade:");
        modSettings.CreateCustomLabel("AWACS and the KC-49 cannot normaly evade missiles");
        modSettings.CreateBoolSetting("(Default = true)", allAICanEvade_changed, settings.allAICanEvade);

        //rockShips_changed += rockShips_Setting;
        //modSettings.CreateCustomLabel("Rock Ships:");
        //modSettings.CreateCustomLabel("Should ships be rocked by the wind?");
        //modSettings.CreateBoolSetting("(Default = true)", rockShips_changed, settings.rockShips);

        //windSpeed_changed += windSpeed_Setting;
        //modSettings.CreateCustomLabel("Wind Speed (kts):");
        //modSettings.CreateCustomLabel("This is the windspeed used to work out how much to rock the ships");
        //modSettings.CreateFloatSetting("(Default = 50kts)", windSpeed_changed, settings.windSpeed, 0f, 100f);

        /*
         * tweakTargetFinders_changed += tweakTargetFinders_Setting;
         * modSettings.CreateCustomLabel("Tweak Visual Target Finders:");
         * modSettings.CreateBoolSetting("(Default = true)", tweakTargetFinders_changed, settings.tweakTargetFinders);
         */

        modSettings.CreateCustomLabel("");

        modSettings.CreateCustomLabel("Joke Settings");

        modSettings.CreateCustomLabel("");

        eyes_changed += eyes_Setting;
        modSettings.CreateCustomLabel("Googly Eyes:");
        modSettings.CreateCustomLabel("Adds googly eyes to various AI units");
        modSettings.CreateBoolSetting("(Default = false)", eyes_changed, settings.eyes);

        invertedAI_changed += invertedAI_Setting;
        modSettings.CreateCustomLabel("Inverted AI:");
        modSettings.CreateCustomLabel("Causes the AI to fly upside down");
        modSettings.CreateBoolSetting("(Default = false)", invertedAI_changed, settings.invertedAI);

        modSettings.CreateCustomLabel("");

        modSettings.CreateCustomLabel("Please feel free to @ me on the discord if");
        modSettings.CreateCustomLabel("you think of any more features I could add!");
        VTOLAPI.CreateSettingsMenu(modSettings);
    }