//credits and licenses in the resources folder
using AmongUs.GameOptions;
using BanMod;
using HarmonyLib;
using Il2CppSystem;
using Il2CppSystem.Data;
using InnerNet;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Intrinsics.X86;
using System.Threading.Tasks;
using UnityEngine;

namespace BanMod
{
    public static class TaskVisibilityController
    {
        private static readonly System.Collections.Generic.Dictionary<MapNames, System.Collections.Generic.List<int>> MapTaskIds = new()
        {
            { MapNames.Skeld, new() {
                9401, 9402, 9408, 9409, 9410, 9412, 9437, 9438, 9439, 9445, 9446, 9467, 9468, 9469, 9472, 9473
            } },
            { MapNames.MiraHQ, new() {
                9401, 9403, 9410, 9417, 9429, 9440, 9441, 9446, 9467, 9471, 9472
            } },
            { MapNames.Polus, new() {
                9401, 9402, 9404, 9405, 9411, 9413, 9415, 9416, 9418, 9419, 9420, 9421, 9438, 9439, 9467, 9474
            } },
            { MapNames.Airship, new() {
                9401, 9424, 9425, 9426, 9428, 9430, 9431, 9432, 9433, 9434, 9435, 9436, 9445, 9467, 9470, 9472
            } },
            { MapNames.Fungle, new() {
                9401, 9414, 9423, 9427, 9428, 9442, 9443, 9444, 9447, 9462, 9463, 9464, 9465, 9467, 9472
            } },
        };

        public static void UpdateTaskVisibility()
        {
            var currentMap = GetActiveMapName();
            UpdateTaskVisibility(currentMap);
        }

        public static void UpdateTaskVisibility(MapNames currentMap)
        {
            if (currentMap < 0)
                return;

            if (!MapTaskIds.TryGetValue(currentMap, out var visibleIds))
                return;

            foreach (var task in OptionItem.ShortOptions)
                task.SetEnabled(visibleIds.Contains(task.Id));

            foreach (var task in OptionItem.CommonOptions)
                task.SetEnabled(visibleIds.Contains(task.Id));

            foreach (var task in OptionItem.LongOptions)
                task.SetEnabled(visibleIds.Contains(task.Id));

            BMLogger.Info($"Visibilità task aggiornata per mappa: {currentMap} ({visibleIds.Count} visibili)", "TaskVisibility");
        }


        public static MapNames GetActiveMapName()
        {
            if (GameOptionsManager.Instance == null || GameOptionsManager.Instance.CurrentGameOptions == null)
                return (MapNames)(-1);

            return (MapNames)GameOptionsManager.Instance.CurrentGameOptions.MapId;
        }
    }
    [HarmonyPatch]
    public static class Options
    {
        static Task taskOptionsLoad;

        [HarmonyPatch(typeof(TranslationController), nameof(TranslationController.Initialize)), HarmonyPostfix]
        public static void OptionsLoadStart()
        {
            taskOptionsLoad = Task.Run(() =>
            {
                try
                {
                    Load();
                }
                catch (System.Exception)
                {
                }
            });
        }

        [HarmonyPatch(typeof(MainMenuManager), nameof(MainMenuManager.Start)), HarmonyPostfix]
        public static void WaitOptionsLoad()
        {
            taskOptionsLoad.Wait();
        }

        public static OptionItem EnableDetector;
        public static OptionItem EnableAfkKick;
        public static OptionItem EnableShield;
        public static IntegerOptionItem TimeToActivate;
        public static IntegerOptionItem DetectionDelay;
        public static OptionItem EnableCamDetector;
        public static OptionItem EnableCamKick;
        public static IntegerOptionItem TimeToCamActivate;
        public static IntegerOptionItem DetectionCamDelay;
        public static IntegerOptionItem MaxCam;
        public static OptionItem EnableCamTaskDetector;
        public static OptionItem EnableCamTaskKick;
        public static IntegerOptionItem TimeToCamTaskActivate;
        public static IntegerOptionItem DetectionCamTaskDelay;
        public static IntegerOptionItem MinTasksToUseCamCrew;
        public static IntegerOptionItem MinTasksToUseCamImp;
        public static IntegerOptionItem MinKillsToUseCamImp;
        public static StringOptionItem ImpostorCamCondition;
        public static OptionItem EnableProximityMonitor;
        public static IntegerOptionItem ProximityDistance;
        public static IntegerOptionItem ProximityTimeSeconds;
        public static StringOptionItem ProximityAction;
        public static OptionItem AutoKickStopWords;
        public static StringOptionItem AutoKickStopWordsAction;
        public static IntegerOptionItem AutoKickStopWordsTimes;
        public static OptionItem SendAutoKickStopWordsMsg;
        public static OptionItem AutoKickStart;
        public static StringOptionItem AutoKickStartAction;
        public static IntegerOptionItem AutoKickStartTimes;
        public static OptionItem SendAutoKickStartMsg;
        public static OptionItem ApplyDenyNameList;
        public static OptionItem CheckBanList;
        public static OptionItem CheckBlockList;
        public static OptionItem CheckFriendCode;
        public static OptionItem KickLevel;
        public static IntegerOptionItem KickLevelLevel;
        public static IntegerOptionItem SubmitScanMax;
        public static OptionItem DisableCleanVent;
        public static OptionItem SharedAllTasks;
        public static OptionItem DisableCalibrateDistributor;
        public static OptionItem DisableChartCourse;
        public static OptionItem DisableStabilizeSteering;
        public static OptionItem DisableCleanO2Filter;
        public static OptionItem DisableUnlockManifolds;
        public static OptionItem DisablePrimeShields;
        public static OptionItem DisableMeasureWeather;
        public static OptionItem DisableBuyBeverage;
        public static OptionItem DisableAssembleArtifact;
        public static OptionItem DisableSortSamples;
        public static OptionItem DisableProcessData;
        public static OptionItem DisableRunDiagnostics;
        public static OptionItem DisableRepairDrill;
        public static OptionItem DisableAlignTelescope;
        public static OptionItem DisableRecordTemperature;
        public static OptionItem DisableFillCanisters;
        public static OptionItem DisableMonitorTree;
        public static OptionItem DisableStoreArtifacts;
        public static OptionItem DisablePutAwayPistols;
        public static OptionItem DisablePutAwayRifles;
        public static OptionItem DisableMakeBurger;
        public static OptionItem DisableCleanToilet;
        public static OptionItem DisableDecontaminate;
        public static OptionItem DisableSortRecords;
        public static OptionItem DisableFixShower;
        public static OptionItem DisablePickUpTowels;
        public static OptionItem DisablePolishRuby;
        public static OptionItem DisableDressMannequin;
        public static OptionItem DisableSwipeCard;
        public static OptionItem DisableFixWiring;
        public static OptionItem DisableEnterIdCode;
        public static OptionItem DisableInsertKeys;
        public static OptionItem DisableScanBoardingPass;
        public static OptionItem DisableSubmitScan;
        public static OptionItem DisableUnlockSafe;
        public static OptionItem DisableStartReactor;
        public static OptionItem DisableResetBreaker;
        public static OptionItem DisableAlignEngineOutput;
        public static OptionItem DisableInspectSample;
        public static OptionItem DisableEmptyChute;
        public static OptionItem DisableClearAsteroids;
        public static OptionItem DisableWaterPlants;
        public static OptionItem DisableOpenWaterways;
        public static OptionItem DisableReplaceWaterJug;
        public static OptionItem DisableRebootWifi;
        public static OptionItem DisableDevelopPhotos;
        public static OptionItem DisableRewindTapes;
        public static OptionItem DisableStartFans;
        public static OptionItem DisableUploadData;
        public static OptionItem DisableEmptyGarbage;
        public static OptionItem DisableFuelEngines;
        public static OptionItem DisableDivertPower;
        public static OptionItem DisableActivateWeatherNodes;
        public static OptionItem DisableRoastMarshmallow;
        public static OptionItem DisableCollectSamples;
        public static OptionItem DisableReplaceParts;
        public static OptionItem DisableCollectVegetables;
        public static OptionItem DisableMineOres;
        public static OptionItem DisableExtractFuel;
        public static OptionItem DisableCatchFish;
        public static OptionItem DisablePolishGem;
        public static OptionItem DisableHelpCritter;
        public static OptionItem DisableHoistSupplies;
        public static OptionItem DisableFixAntenna;
        public static OptionItem DisableBuildSandcastle;
        public static OptionItem DisableCrankGenerator;
        public static OptionItem DisableMonitorMushroom;
        public static OptionItem DisablePlayVideoGame;
        public static OptionItem DisableFindSignal;
        public static OptionItem DisableThrowFisbee;
        public static OptionItem DisableLiftWeights;
        public static OptionItem DisableCollectShells;
        public static OptionItem DisableUnknown;
        public static IntegerOptionItem AutoVoteTime;
        public static OptionItem AutoVote;
        public static StringOptionItem AutoVoteAction;
        public static OptionItem sendInfocomand;
        public static OptionItem buttonvisibile;
        public static OptionItem EngineerFixer;
        public static OptionItem Watcher;
        public static StringOptionItem ExilerAction;
        public static StringOptionItem KickLevelAction;
        public static StringOptionItem ActionTeamers;
        public static StringOptionItem GuesserAction;
        public static OptionItem ResetDoorsEveryTurns;
        public static StringOptionItem DoorsResetMode;
        public static IntegerOptionItem VentTimes;
        public static OptionItem sendwelcome;
        public static OptionItem ScientistTime;
        public static OptionItem Guess;
        public static OptionItem Jester;
        public static OptionItem JesterVent;
        public static OptionItem PhantomGuess;
        public static OptionItem ShapeGuess;
        public static OptionItem ViperGuess;
        public static OptionItem ImpostorGuess;
        public static OptionItem ExilerExe;
        public static OptionItem killexiler;
        public static OptionItem SendSummary;
        public static OptionItem Immortalesentvote;
        public static OptionItem aktive_notimmplayer;
        public static OptionItem ProtectFirst;
        public static OptionItem EnableImmortal;
        public static OptionItem sendtoimmortal;
        public static OptionItem sendtoAll;
        public static OptionItem BlockSwitches;
        public static OptionItem Enablesabotage;
        public static OptionItem Veryshort;
        public static OptionItem DisableAllSabotages;
        public static OptionItem DisableReactorSabotage;
        public static OptionItem DisableCommsSabotage;
        public static OptionItem DisableO2Sabotage;
        public static OptionItem DisableElectricalSabotage;
        public static OptionItem DisableLaboratorySabotage;
        public static OptionItem DisableHeliSabotage;
        public static OptionItem DisableMushroomSabotage;
        public static OptionItem DisableDoorSabotage;
        public static IntegerOptionItem FloatSismic;
        public static IntegerOptionItem FloatReactor;
        public static IntegerOptionItem FloatCrashCourse;
        public static OptionItem EnableAntiCheat;
        public static StringOptionItem ActionCheater;
        public static OptionItem SentWarning;
        public static OptionItem AutoStart;
        public static IntegerOptionItem AutoStartTime;
        public static IntegerOptionItem AutoStartCount;
        public static IntegerOptionItem AutoStartDelay;
        public static OptionItem AutoRejoin;
        public static OptionItem DisableRole;
        public static OptionItem ClooseDoorsCheat;
        public static OptionItem CompleteTaskCheat;
        public static OptionItem KickVentCheat;
        public static OptionItem SabotageCheat2;
        public static OptionItem UseVentCheat;
        public static StringOptionItem GameMode;
        public static StringOptionItem PresetSelection;
        public static OptionItem TcommandforAll;
        public static OptionItem MisfiresToSuicide;
        public static OptionItem CantKillTime;
        public static OptionItem ProtectHostFirstRound;
        public static IntegerOptionItem NumSeekers;
        public static IntegerOptionItem DecontaminationTime;
        public static OptionItem MoreImp;
        public static OptionItem MoreSeek;
        public static IntegerOptionItem NumImpostor;
        public static IntegerOptionItem SabotageCooldown;
        public static IntegerOptionItem FfaVentMaxSeconds;
        public static StringOptionItem FFAVentTeleportMode;
        public static OptionItem specialvote;
        public static List<StringOptionItem> SeekerSelections = new List<StringOptionItem>();
        public static OptionItem CustomSkin;
        public static OptionItem CameraCommsSabotage;
        public static bool ForceOwnLanguage = true;
        public static OptionItem Judge;
        public static IntegerOptionItem JudgeEndUse;
        public static OptionItem Profiler;
        public static StringOptionItem ProfilerHintMode;

        public static bool IsLoaded = false;
        private static bool _reOpenSettingsScheduled = false;

        public static void Load()
        {
            if (IsLoaded) return;
            MoreSeek = BooleanOptionItem.Create("MoreSeek", false, OptionCategory.Seeker, true).SetColor(new Color32(0, 153, 255, 255));
            NumSeekers = (IntegerOptionItem)IntegerOptionItem.Create(950000, "NumSeekers", new(1, 14, 1), 1, OptionCategory.Seeker, true).SetParent(MoreSeek).SetColor(new Color32(0, 153, 255, 255));
            SeekerSelections.Clear();
            for (int i = 1; i <= 14; i++)
            {
                var opt = (StringOptionItem)StringOptionItem.Create(
                    950001 + i,
                    $"SetSeeker {i}",
                    new[] { "Round-robin" },
                    0,
                    OptionCategory.Seeker,
                    true,
                    false
                ).SetParent(NumSeekers).SetColor(new Color32(0, 153, 255, 255));
                SeekerSelections.Add(opt);
            }

            NumSeekers.RegisterUpdateValueEvent((sender, args) =>
            {
                int current = NumSeekers.GetInt();
                for (int i = 0; i < SeekerSelections.Count; i++)
                {
                    if (SeekerSelections[i].OptionBehaviour != null)
                        SeekerSelections[i].SetEnabled(i < current);
                }
            });

            GameMode = (StringOptionItem)StringOptionItem.Create(9200, "GameMode", new[] { "SnS", "BanMod", "KaitoRun", "Default", "TaskRun", "JBMode", "FFA" }, 3,
            OptionCategory.GameMode,
            true,
            true,
            BanMod.ApplyPresetAutomatically
            ).SetColor(new Color32(255, 204, 0, 255));

            GameMode.RegisterUpdateValueEvent((sender, args) =>
            {
                FfaExternalBridge.SyncGameMode();
                ReOpenSettings();
            });

            PresetSelection = (StringOptionItem)StringOptionItem.Create(9201,"Preset",new[] { "Default", "Preset1", "Preset2", "Preset3" },0,
                OptionCategory.GameMode,
                true,
                true,
                BanMod.ApplyPresetAutomatically
            ).SetColor(new Color32(255, 204, 0, 255));

            PresetSelection.RegisterUpdateValueEvent((sender, args) =>
            {
                FfaExternalBridge.SyncGameMode();
                ReOpenSettings();
            });

            FfaVentMaxSeconds = (IntegerOptionItem)IntegerOptionItem.Create("FfaVentMaxSeconds",new(0, 30, 1), 5, OptionCategory.FFA, true).SetColor(new Color32(0, 153, 255, 255));
            FfaVentMaxSeconds.RegisterUpdateValueEvent((sender, args) =>
            {
                FfaExternalBridge.SyncVentSeconds();
            });
            FFAVentTeleportMode = (StringOptionItem)StringOptionItem.Create("FFAVentTeleportMode", new[] { "Always", "RandomEvery15Seconds", "Never" }, 0, OptionCategory.FFA, true, true).SetColor(new Color32(255, 204, 0, 255));
            FfaVentMaxSeconds.RegisterUpdateValueEvent((sender, args) =>
            {
                FfaExternalBridge.SyncVentMode();
            });
            MisfiresToSuicide = (IntegerOptionItem)IntegerOptionItem.Create(9202, "SuicideAfterMisfiresAmount", new(1, 10, 1), 2, OptionCategory.SNS, false).SetColor(new Color32(0, 153, 255, 255));
            CantKillTime = (IntegerOptionItem)IntegerOptionItem.Create(9203, "MisfireKillCooldown", new(0, 60, 5), 20, OptionCategory.SNS, false).SetColor(new Color32(0, 153, 255, 255));

            TcommandforAll = BooleanOptionItem.Create(9102, "EnableTCommandForAll", false, OptionCategory.General, true).SetColor(new Color32(0, 153, 255, 255));
            sendwelcome = BooleanOptionItem.Create(9103, "SendWelcomeMessage", false, OptionCategory.General, true).SetColor(new Color32(0, 153, 255, 255));
            SendSummary = BooleanOptionItem.Create(9104, "SendSummary1", false, OptionCategory.General, true).SetColor(new Color32(0, 153, 255, 255));
            sendInfocomand = BooleanOptionItem.Create(9105, "SendCommandInfo", false, OptionCategory.General, true).SetColor(new Color32(0, 153, 255, 255));
            buttonvisibile = BooleanOptionItem.Create(9302, "QuickMenusVisible", false, OptionCategory.General, true).SetColor(new Color32(0, 153, 255, 255));
            MoreImp = BooleanOptionItem.Create(9107, "MoreImpostors", false, OptionCategory.General, true).SetColor(new Color32(0, 153, 255, 255));
            NumImpostor = (IntegerOptionItem)IntegerOptionItem.Create("NumImpostorMax", new(4, 7, 1), 4, OptionCategory.General, false).SetParent(MoreImp).SetColor(new Color32(0, 153, 255, 255));
            specialvote = BooleanOptionItem.Create(9109, "SpecialVote", false, OptionCategory.General, true).SetColor(new Color32(0, 153, 255, 255));
            CustomSkin = BooleanOptionItem.Create(9110, "CustomSkin", true, OptionCategory.General, true).SetColor(new Color32(0, 153, 255, 255));

            ProtectHostFirstRound = BooleanOptionItem.Create(9697, "ProtectHostFirstRound", false, OptionCategory.Game, true).SetColor(new Color32(0, 153, 255, 255));
            ProtectFirst = BooleanOptionItem.Create(9698, "ProtectFirst", false, OptionCategory.Game, true).SetColor(new Color32(0, 153, 255, 255));
            Veryshort = BooleanOptionItem.Create(9208, "VeryShortKillDistance", false, OptionCategory.Game, true).SetColor(new Color32(0, 153, 255, 255));
            AutoRejoin = BooleanOptionItem.Create(9209, "AutoRejoin", false, OptionCategory.Game, true).SetColor(new Color32(0, 153, 255, 255));
            CameraCommsSabotage = BooleanOptionItem.Create("CameraCommsSabotage",false,OptionCategory.Game,true).SetColor(new Color32(0, 153, 255, 255));
            AutoVote = BooleanOptionItem.Create(9210, "AutoVote", false, OptionCategory.Game, true).SetColor(new Color32(0, 153, 255, 255));
            AutoVoteTime = (IntegerOptionItem)IntegerOptionItem.Create(9211, "AutoVoteTime", new(0, 120, 10), 30, OptionCategory.Game, true).SetParent(AutoVote).SetColor(new Color32(0, 153, 255, 255));
            AutoVoteAction = (StringOptionItem)StringOptionItem.Create(9212, "AutoVoteAction", new[] { "Always", "OnlyAfk" }, 0, OptionCategory.Game, true).SetParent(AutoVote).SetColor(new Color32(0, 153, 255, 255));
            AutoStart = BooleanOptionItem.Create(9204, "AutoStart", false, OptionCategory.Game, true).SetColor(new Color32(0, 153, 255, 255));
            AutoStartTime = (IntegerOptionItem)IntegerOptionItem.Create(9205, "AutoStartTime", new(0, 600, 10), 60, OptionCategory.Game, true).SetParent(AutoStart).SetColor(new Color32(0, 153, 255, 255));
            AutoStartCount = (IntegerOptionItem)IntegerOptionItem.Create(9206, "AutoStartCount", new(1, 15, 1), 14, OptionCategory.Game, true).SetParent(AutoStart).SetColor(new Color32(0, 153, 255, 255));
            AutoStartDelay = (IntegerOptionItem)IntegerOptionItem.Create(9207, "AutoStarDelay", new(0, 60, 5), 30, OptionCategory.Game, true).SetParent(AutoStart).SetColor(new Color32(0, 153, 255, 255));

            SubmitScanMax = (IntegerOptionItem)IntegerOptionItem.Create(9399, "SubmitScanMax", new(-1, 15, 1), -1, OptionCategory.Task, true).SetColor(new Color32(0, 153, 255, 255));
            SharedAllTasks = BooleanOptionItem.Create(9400, "SharedAllTasks", false, OptionCategory.Task, true).SetColor(new Color32(0, 153, 255, 255));
            DisableFixWiring = BooleanOptionItem.Create(9401, "DisableFixWiring", false, OptionCategory.Common, true).SetColor(new Color32(0, 153, 255, 255));
            DisableSwipeCard = BooleanOptionItem.Create(9402, "DisableSwipeCard", false, OptionCategory.Common, true).SetColor(new Color32(0, 153, 255, 255));
            DisableEnterIdCode = BooleanOptionItem.Create(9403, "DisableEnterIdCode", false, OptionCategory.Common, true).SetColor(new Color32(0, 153, 255, 255));
            DisableInsertKeys = BooleanOptionItem.Create(9404, "DisableInsertKeys", false, OptionCategory.Common, true).SetColor(new Color32(0, 153, 255, 255));
            DisableScanBoardingPass = BooleanOptionItem.Create(9405, "DisableScanBoardingPass", false, OptionCategory.Common, true).SetColor(new Color32(0, 153, 255, 255));
            DisableCalibrateDistributor = BooleanOptionItem.Create(9407, "DisableCalibrateDistributor", false, OptionCategory.Short, true).SetColor(new Color32(0, 153, 255, 255));
            DisableChartCourse = BooleanOptionItem.Create(9408, "DisableChartCourse", false, OptionCategory.Short, true).SetColor(new Color32(0, 153, 255, 255));
            DisableStabilizeSteering = BooleanOptionItem.Create(9409, "DisableStabilizeSteering", false, OptionCategory.Short, true).SetColor(new Color32(0, 153, 255, 255));
            DisableCleanO2Filter = BooleanOptionItem.Create(9410, "DisableCleanO2Filter", false, OptionCategory.Short, true).SetColor(new Color32(0, 153, 255, 255));
            DisableUnlockManifolds = BooleanOptionItem.Create(9411, "DisableUnlockManifolds", false, OptionCategory.Short, true).SetColor(new Color32(0, 153, 255, 255));
            DisablePrimeShields = BooleanOptionItem.Create(9412, "DisablePrimeShields", false, OptionCategory.Short, true).SetColor(new Color32(0, 153, 255, 255));
            DisableMeasureWeather = BooleanOptionItem.Create(9413, "DisableMeasureWeather", false, OptionCategory.Short, true).SetColor(new Color32(0, 153, 255, 255));
            DisableBuyBeverage = BooleanOptionItem.Create(9414, "DisableBuyBeverage", false, OptionCategory.Short, true).SetColor(new Color32(0, 153, 255, 255));
            DisableAssembleArtifact = BooleanOptionItem.Create(9415, "DisableAssembleArtifact", false, OptionCategory.Long, true).SetColor(new Color32(0, 153, 255, 255));
            DisableSortSamples = BooleanOptionItem.Create(9416, "DisableSortSamples", false, OptionCategory.Long, true).SetColor(new Color32(0, 153, 255, 255));
            DisableProcessData = BooleanOptionItem.Create(9417, "DisableProcessData", false, OptionCategory.Long, true).SetColor(new Color32(0, 153, 255, 255));
            DisableRunDiagnostics = BooleanOptionItem.Create(9418, "DisableRunDiagnostics", false, OptionCategory.Long, true).SetColor(new Color32(0, 153, 255, 255));
            DisableRepairDrill = BooleanOptionItem.Create(9419, "DisableRepairDrill", false, OptionCategory.Long, true).SetColor(new Color32(0, 153, 255, 255));
            DisableAlignTelescope = BooleanOptionItem.Create(9420, "DisableAlignTelescope", false, OptionCategory.Short, true).SetColor(new Color32(0, 153, 255, 255));
            DisableRecordTemperature = BooleanOptionItem.Create(9421, "DisableRecordTemperature", false, OptionCategory.Short, true).SetColor(new Color32(0, 153, 255, 255));
            DisableFillCanisters = BooleanOptionItem.Create(9422, "DisableFillCanisters", false, OptionCategory.Long, true).SetColor(new Color32(0, 153, 255, 255));
            DisableMonitorTree = BooleanOptionItem.Create(9423, "DisableMonitorTree", false, OptionCategory.Short, true).SetColor(new Color32(0, 153, 255, 255));
            DisableStoreArtifacts = BooleanOptionItem.Create(9424, "DisableStoreArtifacts", false, OptionCategory.Short, true).SetColor(new Color32(0, 153, 255, 255));
            DisablePutAwayPistols = BooleanOptionItem.Create(9425, "DisablePutAwayPistols", false, OptionCategory.Short, true).SetColor(new Color32(0, 153, 255, 255));
            DisablePutAwayRifles = BooleanOptionItem.Create(9426, "DisablePutAwayRifles", false, OptionCategory.Short, true).SetColor(new Color32(0, 153, 255, 255));
            DisableMakeBurger = BooleanOptionItem.Create(9427, "DisableMakeBurger", false, OptionCategory.Short, true).SetColor(new Color32(0, 153, 255, 255));
            DisableCleanToilet = BooleanOptionItem.Create(9428, "DisableCleanToilet", false, OptionCategory.Short, true).SetColor(new Color32(0, 153, 255, 255));
            DisableDecontaminate = BooleanOptionItem.Create(9429, "DisableDecontaminate", false, OptionCategory.Long, true).SetColor(new Color32(0, 153, 255, 255));
            DisableSortRecords = BooleanOptionItem.Create(9430, "DisableSortRecords", false, OptionCategory.Short, true).SetColor(new Color32(0, 153, 255, 255));
            DisableFixShower = BooleanOptionItem.Create(9431, "DisableFixShower", false, OptionCategory.Short, true).SetColor(new Color32(0, 153, 255, 255));
            DisablePickUpTowels = BooleanOptionItem.Create(9432, "DisablePickUpTowels", false, OptionCategory.Short, true).SetColor(new Color32(0, 153, 255, 255));
            DisablePolishRuby = BooleanOptionItem.Create(9433, "DisablePolishRuby", false, OptionCategory.Long, true).SetColor(new Color32(0, 153, 255, 255));
            DisableDressMannequin = BooleanOptionItem.Create(9434, "DisableDressMannequin", false, OptionCategory.Long, true).SetColor(new Color32(0, 153, 255, 255));
            DisableUnlockSafe = BooleanOptionItem.Create(9435, "DisableUnlockSafe", false, OptionCategory.Short, true).SetColor(new Color32(0, 153, 255, 255));
            DisableResetBreaker = BooleanOptionItem.Create(9436, "DisableResetBreaker", false, OptionCategory.Short, true).SetColor(new Color32(0, 153, 255, 255));
            DisableAlignEngineOutput = BooleanOptionItem.Create(9437, "DisableAlignEngineOutput", false, OptionCategory.Long, true).SetColor(new Color32(0, 153, 255, 255));
            DisableEmptyChute = BooleanOptionItem.Create(9438, "DisableEmptyChute", false, OptionCategory.Long, true).SetColor(new Color32(0, 153, 255, 255));
            DisableClearAsteroids = BooleanOptionItem.Create(9439, "DisableClearAsteroids", false, OptionCategory.Short, true).SetColor(new Color32(0, 153, 255, 255));
            DisableWaterPlants = BooleanOptionItem.Create(9440, "DisableWaterPlants", false, OptionCategory.Short, true).SetColor(new Color32(0, 153, 255, 255));
            DisableReplaceWaterJug = BooleanOptionItem.Create(9441, "DisableReplaceWaterJug", false, OptionCategory.Short, true).SetColor(new Color32(0, 153, 255, 255));
            DisableDevelopPhotos = BooleanOptionItem.Create(9442, "DisableDevelopPhotos", false, OptionCategory.Short, true).SetColor(new Color32(0, 153, 255, 255));
            DisableRewindTapes = BooleanOptionItem.Create(9443, "DisableRewindTapes", false, OptionCategory.Short, true).SetColor(new Color32(0, 153, 255, 255));
            DisableStartFans = BooleanOptionItem.Create(9444, "DisableStartFans", false, OptionCategory.Short, true).SetColor(new Color32(0, 153, 255, 255));
            DisableEmptyGarbage = BooleanOptionItem.Create(9445, "DisableEmptyGarbage", false, OptionCategory.Long, true).SetColor(new Color32(0, 153, 255, 255));
            DisableDivertPower = BooleanOptionItem.Create(9446, "DisableDivertPower", false, OptionCategory.Long, true).SetColor(new Color32(0, 153, 255, 255));
            DisableRoastMarshmallow = BooleanOptionItem.Create(9447, "DisableRoastMarshmallow", false, OptionCategory.Short, true).SetColor(new Color32(0, 153, 255, 255));
            DisableCollectSamples = BooleanOptionItem.Create(9448, "DisableCollectSamples", false, OptionCategory.Long, true).SetColor(new Color32(0, 153, 255, 255));
            DisableReplaceParts = BooleanOptionItem.Create(9449, "DisableReplaceParts", false, OptionCategory.Long, true).SetColor(new Color32(0, 153, 255, 255));
            DisableCollectVegetables = BooleanOptionItem.Create(9450, "DisableCollectVegetables", false, OptionCategory.Long, true).SetColor(new Color32(0, 153, 255, 255));
            DisableMineOres = BooleanOptionItem.Create(9451, "DisableMineOres", false, OptionCategory.Long, true).SetColor(new Color32(0, 153, 255, 255));
            DisableExtractFuel = BooleanOptionItem.Create(9452, "DisableExtractFuel", false, OptionCategory.Long, true).SetColor(new Color32(0, 153, 255, 255));
            DisableCatchFish = BooleanOptionItem.Create(9453, "DisableCatchFish", false, OptionCategory.Long, true).SetColor(new Color32(0, 153, 255, 255));
            DisablePolishGem = BooleanOptionItem.Create(9454, "DisablePolishGem", false, OptionCategory.Long, true).SetColor(new Color32(0, 153, 255, 255));
            DisableHelpCritter = BooleanOptionItem.Create(9455, "DisableHelpCritter", false, OptionCategory.Long, true).SetColor(new Color32(0, 153, 255, 255));
            DisableHoistSupplies = BooleanOptionItem.Create(9456, "DisableHoistSupplies", false, OptionCategory.Long, true).SetColor(new Color32(0, 153, 255, 255));
            DisableFixAntenna = BooleanOptionItem.Create(9457, "DisableFixAntenna", false, OptionCategory.Long, true).SetColor(new Color32(0, 153, 255, 255));
            DisableBuildSandcastle = BooleanOptionItem.Create(9458, "DisableBuildSandcastle", false, OptionCategory.Long, true).SetColor(new Color32(0, 153, 255, 255));
            DisableCrankGenerator = BooleanOptionItem.Create(9459, "DisableCrankGenerator", false, OptionCategory.Long, true).SetColor(new Color32(0, 153, 255, 255));
            DisableMonitorMushroom = BooleanOptionItem.Create(9460, "DisableMonitorMushroom", false, OptionCategory.Long, true).SetColor(new Color32(0, 153, 255, 255));
            DisablePlayVideoGame = BooleanOptionItem.Create(9461, "DisablePlayVideoGame", false, OptionCategory.Long, true).SetColor(new Color32(0, 153, 255, 255));
            DisableFindSignal = BooleanOptionItem.Create(9462, "DisableFindSignal", false, OptionCategory.Short, true).SetColor(new Color32(0, 153, 255, 255));
            DisableThrowFisbee = BooleanOptionItem.Create(9463, "DisableThrowFisbee", false, OptionCategory.Short, true).SetColor(new Color32(0, 153, 255, 255));
            DisableLiftWeights = BooleanOptionItem.Create(9464, "DisableLiftWeights", false, OptionCategory.Short, true).SetColor(new Color32(0, 153, 255, 255));
            DisableCollectShells = BooleanOptionItem.Create(9465, "DisableCollectShells", false, OptionCategory.Short, true).SetColor(new Color32(0, 153, 255, 255));
            DisableCleanVent = BooleanOptionItem.Create(9476, "DisableCleanVent", false, OptionCategory.Short, true).SetColor(new Color32(0, 153, 255, 255));
            DisableSubmitScan = BooleanOptionItem.Create(9467, "DisableSubmitScan", false, OptionCategory.Long, true).SetColor(new Color32(0, 153, 255, 255));
            DisableStartReactor = BooleanOptionItem.Create(9468, "DisableStartReactor", false, OptionCategory.Long, true).SetColor(new Color32(0, 153, 255, 255));
            DisableInspectSample = BooleanOptionItem.Create(9469, "DisableInspectSample", false, OptionCategory.Long, true).SetColor(new Color32(0, 153, 255, 255));
            DisableOpenWaterways = BooleanOptionItem.Create(9470, "DisableOpenWaterways", false, OptionCategory.Long, true).SetColor(new Color32(0, 153, 255, 255));
            DisableRebootWifi = BooleanOptionItem.Create(9471, "DisableRebootWifi", false, OptionCategory.Short, true).SetColor(new Color32(0, 153, 255, 255));
            DisableUploadData = BooleanOptionItem.Create(9472, "DisableUploadData", false, OptionCategory.Long, true).SetColor(new Color32(0, 153, 255, 255));
            DisableFuelEngines = BooleanOptionItem.Create(9473, "DisableFuelEngines", false, OptionCategory.Long, true).SetColor(new Color32(0, 153, 255, 255));
            DisableActivateWeatherNodes = BooleanOptionItem.Create(9474, "DisableActivateWeatherNodes", false, OptionCategory.Long, true).SetColor(new Color32(0, 153, 255, 255));

            Profiler = BooleanOptionItem.Create("Profiler", false, OptionCategory.Profiler, true).SetColor(new Color32(0, 153, 255, 255));
            ProfilerHintMode = (StringOptionItem)StringOptionItem.Create("ProfilerHintMode", new[] { "Lieve", "Medio", "Forte", "Task" }, 0, OptionCategory.Profiler, true, true).SetParent(Profiler).SetColor(new Color32(255, 204, 0, 255));

            Judge = BooleanOptionItem.Create("Judge", false, OptionCategory.Judge, true).SetColor(new Color32(0, 153, 255, 255));
            JudgeEndUse = (IntegerOptionItem)IntegerOptionItem.Create("JudgeEndUse", new(0, 5, 1), 3, OptionCategory.Judge, true).SetParent(Judge).SetColor(new Color32(0, 153, 255, 255));

            Watcher = BooleanOptionItem.Create(9703, "Watcher", false, OptionCategory.Watcher, true).SetColor(new Color32(0, 153, 255, 255));

            Jester = BooleanOptionItem.Create(9699, "Jester", false, OptionCategory.Jester, true).SetColor(new Color32(0, 153, 255, 255));
            JesterVent = BooleanOptionItem.Create(9700, "JesterVent", false, OptionCategory.Jester, true).SetParent(Jester).SetColor(new Color32(0, 153, 255, 255));

            Guess = BooleanOptionItem.Create(9701, "Guess", false, OptionCategory.Guesser, true).SetColor(new Color32(0, 153, 255, 255));
            GuesserAction = (StringOptionItem)StringOptionItem.Create(9702, "Action", new[] { "Kill", "Exile" }, 0, OptionCategory.Guesser, true).SetParent(Guess).SetColor(new Color32(0, 153, 255, 255));

            EnableImmortal = BooleanOptionItem.Create(9800, "EnableImmortal", false, OptionCategory.Immortal, true).SetColor(new Color32(0, 153, 255, 255));
            sendtoAll = BooleanOptionItem.Create(9801, "NotifyAll", false, OptionCategory.Immortal, true).SetParent(EnableImmortal).SetColor(new Color32(0, 153, 255, 255));
            sendtoimmortal = BooleanOptionItem.Create(9802, "NotifyImmortal", false, OptionCategory.Immortal, true).SetParent(EnableImmortal).SetColor(new Color32(0, 153, 255, 255));
            Immortalesentvote = BooleanOptionItem.Create(9803, "Immortalesentvote", false, OptionCategory.Immortal, true).SetParent(EnableImmortal).SetColor(new Color32(0, 153, 255, 255));

            EngineerFixer = BooleanOptionItem.Create(9900, "EnginerFixer", false, OptionCategory.Engineer, true).SetColor(new Color32(0, 153, 255, 255));
            VentTimes = (IntegerOptionItem)IntegerOptionItem.Create(9901, "VentTimes", new(0, 5, 1), 3, OptionCategory.Engineer, true).SetParent(EngineerFixer).SetColor(new Color32(0, 153, 255, 255));

            PhantomGuess = BooleanOptionItem.Create(91001, "PhantomGuess", false, OptionCategory.Impostor, true).SetColor(new Color32(0, 153, 255, 255));
            ShapeGuess = BooleanOptionItem.Create(91002, "ShapeGuess", false, OptionCategory.Impostor, true).SetColor(new Color32(0, 153, 255, 255));
            ViperGuess = BooleanOptionItem.Create(91003, "ViperGuess", false, OptionCategory.Impostor, true).SetColor(new Color32(0, 153, 255, 255));
            ImpostorGuess = BooleanOptionItem.Create(91004, "ImpostorGuess1", false, OptionCategory.Impostor, true).SetColor(new Color32(0, 153, 255, 255));
            aktive_notimmplayer = BooleanOptionItem.Create(91005, "aktive_notimmplayer", false, OptionCategory.Impostor, true).SetColor(new Color32(0, 153, 255, 255));

            ScientistTime = BooleanOptionItem.Create(91100, "ScientistTime", false, OptionCategory.Scientist, true).SetColor(new Color32(0, 153, 255, 255));

            ExilerExe = BooleanOptionItem.Create(91300, "ExilerExe", false, OptionCategory.Exiler, true).SetColor(new Color32(0, 153, 255, 255));
            ExilerAction = (StringOptionItem)StringOptionItem.Create(91301, "Action", new[] { "Kill", "Exile" }, 0, OptionCategory.Exiler, true).SetParent(ExilerExe).SetColor(new Color32(0, 153, 255, 255));
            killexiler = BooleanOptionItem.Create(91302, "DiesAfterCommand", false, OptionCategory.Exiler, true).SetParent(ExilerExe).SetColor(new Color32(0, 153, 255, 255));

            KickLevel = BooleanOptionItem.Create(91405, "KickLevel", false, OptionCategory.Blocklist, true).SetColor(new Color32(0, 153, 255, 255));
            KickLevelLevel = (IntegerOptionItem)IntegerOptionItem.Create(91406, "KickLevelLevel", new(5, 100, 5), 50, OptionCategory.Blocklist, true).SetParent(KickLevel).SetColor(new Color32(0, 153, 255, 255));
            KickLevelAction = (StringOptionItem)StringOptionItem.Create(91407, "Action", new[] { "Ban", "Kick" }, 0, OptionCategory.Blocklist, true).SetParent(KickLevel).SetColor(new Color32(0, 153, 255, 255));

            ApplyDenyNameList = BooleanOptionItem.Create(91401, "ApplyDenyNameList", false, OptionCategory.Blocklist, true).SetColor(new Color32(0, 153, 255, 255));
            CheckBanList = BooleanOptionItem.Create(91402, "CheckBanList", false, OptionCategory.Blocklist, true).SetColor(new Color32(0, 153, 255, 255));
            CheckBlockList = BooleanOptionItem.Create(91403, "CheckBlockList", false, OptionCategory.Blocklist, true).SetColor(new Color32(0, 153, 255, 255));
            CheckFriendCode = BooleanOptionItem.Create(91404, "CheckFriendCode", false, OptionCategory.Blocklist, true).SetColor(new Color32(0, 153, 255, 255));
            ActionTeamers = (StringOptionItem)StringOptionItem.Create("ActionTeamers", new[] { "OnlyWarm", "Kick", "Ban" }, 0, OptionCategory.Blocklist, true).SetColor(new Color32(0, 153, 255, 255));

            EnableAntiCheat = BooleanOptionItem.Create(9500, "EnableAntiCheat", false, OptionCategory.Cheat, true).SetColor(new Color32(0, 153, 255, 255));
            ClooseDoorsCheat = BooleanOptionItem.Create(9501, "CloseDoorsCheat", false, OptionCategory.Cheat, true).SetParent(EnableAntiCheat).SetColor(new Color32(0, 153, 255, 255));
            CompleteTaskCheat = BooleanOptionItem.Create(9502, "CompleteTaskCheat", false, OptionCategory.Cheat, true).SetParent(EnableAntiCheat).SetColor(new Color32(0, 153, 255, 255));
            KickVentCheat = BooleanOptionItem.Create(9503, "KickVentCheat", false, OptionCategory.Cheat, true).SetParent(EnableAntiCheat).SetColor(new Color32(0, 153, 255, 255));
            SabotageCheat2 = BooleanOptionItem.Create(9504, "SabotageCheat2", false, OptionCategory.Cheat, true).SetParent(EnableAntiCheat).SetColor(new Color32(0, 153, 255, 255));
            UseVentCheat = BooleanOptionItem.Create(9505, "UseVentCheat", false, OptionCategory.Cheat, true).SetParent(EnableAntiCheat).SetColor(new Color32(0, 153, 255, 255));
            SentWarning = BooleanOptionItem.Create(9506, "SentWarning", false, OptionCategory.Cheat, true).SetParent(EnableAntiCheat).SetColor(new Color32(0, 153, 255, 255));
            ActionCheater = (StringOptionItem)StringOptionItem.Create(9507, "ActionCheaterlist", new[] { "OnlyWarm", "Kick", "Ban" }, 0, OptionCategory.Cheat, true).SetParent(EnableAntiCheat).SetColor(new Color32(0, 153, 255, 255));

            EnableDetector = BooleanOptionItem.Create(91500, "EnableAFKDetector", false, OptionCategory.Afk, true).SetColor(new Color32(0, 153, 255, 255));
            EnableAfkKick = BooleanOptionItem.Create(91501, "EnableAfkKick", false, OptionCategory.Afk, true).SetParent(EnableDetector).SetColor(new Color32(0, 153, 255, 255));
            EnableShield = BooleanOptionItem.Create(91502, "EnableShield", false, OptionCategory.Afk, true).SetParent(EnableDetector).SetColor(new Color32(0, 153, 255, 255));
            DetectionDelay = (IntegerOptionItem)IntegerOptionItem.Create(91503, "AFKDetectionDelay(sec)", new(5, 60, 5), 45, OptionCategory.Afk, true).SetParent(EnableDetector).SetColor(new Color32(0, 153, 255, 255));
            TimeToActivate = (IntegerOptionItem)IntegerOptionItem.Create(91504, "TimeToActivate(min)", new(1, 10, 1), 1, OptionCategory.Afk, true).SetParent(EnableDetector).SetColor(new Color32(0, 153, 255, 255));

            EnableCamDetector = BooleanOptionItem.Create(91600, "EnableCamDetector", false, OptionCategory.Cam, true).SetColor(new Color32(0, 153, 255, 255));
            EnableCamKick = BooleanOptionItem.Create(91601, "EnableCamKick", false, OptionCategory.Cam, true).SetParent(EnableCamDetector).SetColor(new Color32(0, 153, 255, 255));
            DetectionCamDelay = (IntegerOptionItem)IntegerOptionItem.Create(91602, "CamDetectionDelaySeconds", new(0, 60, 5), 20, OptionCategory.Cam, true).SetParent(EnableCamDetector).SetColor(new Color32(0, 153, 255, 255));
            TimeToCamActivate = (IntegerOptionItem)IntegerOptionItem.Create(91603, "CamKickDelaySeconds", new(0, 60, 5), 30, OptionCategory.Cam, true).SetParent(EnableCamDetector).SetColor(new Color32(0, 153, 255, 255));
            MaxCam = (IntegerOptionItem)IntegerOptionItem.Create(91604, "MaxCam", new(0, 5, 1), 3, OptionCategory.Cam, true).SetParent(EnableCamDetector).SetColor(new Color32(0, 153, 255, 255));

            EnableCamTaskDetector = BooleanOptionItem.Create(91700, "EnableCamTaskDetector", false, OptionCategory.CamTask, true).SetColor(new Color32(0, 153, 255, 255));
            EnableCamTaskKick = BooleanOptionItem.Create(91701, "EnableCamKick", false, OptionCategory.CamTask, true).SetColor(new Color32(0, 153, 255, 255)).SetParent(EnableCamTaskDetector);
            DetectionCamTaskDelay = (IntegerOptionItem)IntegerOptionItem.Create(91702, "CamDetectionDelaySeconds", new(0, 60, 5), 20, OptionCategory.CamTask, true).SetParent(EnableCamTaskDetector).SetColor(new Color32(0, 153, 255, 255));
            TimeToCamTaskActivate = (IntegerOptionItem)IntegerOptionItem.Create(91703, "CamKickDelaySeconds", new(0, 60, 5), 30, OptionCategory.CamTask, true).SetParent(EnableCamTaskDetector).SetColor(new Color32(0, 153, 255, 255));
            MinTasksToUseCamCrew = (IntegerOptionItem)IntegerOptionItem.Create(91704, "MinTasksToUseCamCrew", new(1, 10, 1), 3, OptionCategory.CamTask, true).SetParent(EnableCamTaskDetector).SetColor(new Color32(0, 153, 255, 255));
            ImpostorCamCondition = (StringOptionItem)StringOptionItem.Create(91705, "ImpostorCamCondition", new[] { "Task", "KillMin", "Both", "Either" }, 0, OptionCategory.CamTask, true).SetParent(EnableCamTaskDetector).SetColor(new Color32(0, 153, 255, 255));
            MinKillsToUseCamImp = (IntegerOptionItem)IntegerOptionItem.Create(91706, "KillsLabel", new(1, 10, 1), 3, OptionCategory.CamTask, true).SetParent(EnableCamTaskDetector).SetColor(new Color32(0, 153, 255, 255));
            MinTasksToUseCamImp = (IntegerOptionItem)IntegerOptionItem.Create(91707, "MinTasksToUseCamImp", new(1, 10, 1), 3, OptionCategory.CamTask, true).SetParent(EnableCamTaskDetector).SetColor(new Color32(0, 153, 255, 255));

            EnableProximityMonitor = BooleanOptionItem.Create(91800, "EnableProximityMonitor", false, OptionCategory.Follow, true).SetColor(new Color32(0, 153, 255, 255));
            ProximityDistance = (IntegerOptionItem)IntegerOptionItem.Create(91801, "ProximityDistance", new(0, 10, 1), 5, OptionCategory.Follow, true).SetParent(EnableProximityMonitor).SetColor(new Color32(0, 153, 255, 255));
            ProximityTimeSeconds = (IntegerOptionItem)IntegerOptionItem.Create(91802, "ProximityTimeSeconds", new(0, 120, 5), 30, OptionCategory.Follow, true).SetParent(EnableProximityMonitor).SetColor(new Color32(0, 153, 255, 255));
            ProximityAction = (StringOptionItem)StringOptionItem.Create(91803, "Action", new[] { "Warm", "Kick" }, 0, OptionCategory.Follow, true).SetParent(EnableProximityMonitor).SetColor(new Color32(0, 153, 255, 255));

            AutoKickStart = BooleanOptionItem.Create(91900, "AutoKickStart", false, OptionCategory.Spamlist, true).SetColor(new Color32(0, 153, 255, 255));
            AutoKickStartTimes = (IntegerOptionItem)IntegerOptionItem.Create(91901, "WarningsBeforeKick", new(0, 5, 1), 2, OptionCategory.Spamlist, true).SetParent(AutoKickStart).SetColor(new Color32(0, 153, 255, 255));
            SendAutoKickStartMsg = BooleanOptionItem.Create(91902, "SendWarningMessageToPlayer", false, OptionCategory.Spamlist, true).SetParent(AutoKickStart).SetColor(new Color32(0, 153, 255, 255));
            AutoKickStartAction = (StringOptionItem)StringOptionItem.Create(91903, "Action", new[] { "Kick", "Ban" }, 0, OptionCategory.Spamlist, true).SetParent(AutoKickStart).SetColor(new Color32(0, 153, 255, 255));

            AutoKickStopWords = BooleanOptionItem.Create(92000, "AutoKickStopWords", false, OptionCategory.Wordlist, true).SetColor(new Color32(0, 153, 255, 255));
            AutoKickStopWordsTimes = (IntegerOptionItem)IntegerOptionItem.Create(92001, "WarningsBeforeKick", new(0, 5, 1), 1, OptionCategory.Wordlist, true).SetParent(AutoKickStopWords).SetColor(new Color32(0, 153, 255, 255));
            SendAutoKickStopWordsMsg = BooleanOptionItem.Create(92002, "SendWarningMessageToPlayer", false, OptionCategory.Wordlist, true).SetParent(AutoKickStopWords).SetColor(new Color32(0, 153, 255, 255));
            AutoKickStopWordsAction = (StringOptionItem)StringOptionItem.Create(92003, "Action", new[] { "Kick", "Ban" }, 0, OptionCategory.Wordlist, true).SetParent(AutoKickStopWords).SetColor(new Color32(0, 153, 255, 255));

            Enablesabotage = BooleanOptionItem.Create(92100, "Enablesabotage", false, OptionCategory.SabotageOption, true).SetColor(new Color32(0, 153, 255, 255));
            DecontaminationTime = (IntegerOptionItem)IntegerOptionItem.Create(9106, "DecontaminationTime", new(3, 30, 1), 9, OptionCategory.SabotageOption, true).SetColor(new Color32(0, 153, 255, 255));
            SabotageCooldown = (IntegerOptionItem)IntegerOptionItem.Create(9398, "SabotageCooldown", new(1, 60, 1), 30, OptionCategory.SabotageOption, true).SetColor(new Color32(0, 153, 255, 255));
            ResetDoorsEveryTurns = BooleanOptionItem.Create(92110, "ResetDoorsEveryTurns", false, OptionCategory.SabotageOption, true).SetColor(new Color32(0, 153, 255, 255));
            DoorsResetMode = (StringOptionItem)StringOptionItem.Create(92111, "Action", new[] { "Open", "Close" }, 0, OptionCategory.SabotageOption, true).SetParent(ResetDoorsEveryTurns).SetColor(new Color32(0, 153, 255, 255));
            BlockSwitches = BooleanOptionItem.Create(92112, "BlockSwitches", false, OptionCategory.SabotageOption, true).SetColor(new Color32(0, 153, 255, 255));

            DisableAllSabotages = BooleanOptionItem.Create(92101, "DisableAllSabotages", false, OptionCategory.Sabotage, true).SetColor(new Color32(0, 153, 255, 255));
            DisableReactorSabotage = BooleanOptionItem.Create(92102, "DisableReactorSabotage", false, OptionCategory.Sabotage, true).SetColor(new Color32(0, 153, 255, 255));
            DisableCommsSabotage = BooleanOptionItem.Create(92103, "DisableCommsSabotage", false, OptionCategory.Sabotage, true).SetColor(new Color32(0, 153, 255, 255));
            DisableO2Sabotage = BooleanOptionItem.Create(92104, "DisableO2Sabotage", false, OptionCategory.Sabotage, true).SetColor(new Color32(0, 153, 255, 255));
            DisableElectricalSabotage = BooleanOptionItem.Create(92105, "DisableElectricalSabotage", false, OptionCategory.Sabotage, true).SetColor(new Color32(0, 153, 255, 255));
            DisableLaboratorySabotage = BooleanOptionItem.Create(92106, "DisableLaboratorySabotage", false, OptionCategory.Sabotage, true).SetColor(new Color32(0, 153, 255, 255));
            DisableHeliSabotage = BooleanOptionItem.Create(92107, "DisableHeliSabotage", false, OptionCategory.Sabotage, true).SetColor(new Color32(0, 153, 255, 255));
            DisableMushroomSabotage = BooleanOptionItem.Create(92108, "DisableMushroomSabotage", false, OptionCategory.Sabotage, true).SetColor(new Color32(0, 153, 255, 255));
            DisableDoorSabotage = BooleanOptionItem.Create(92109, "DisableDoorSabotage", false, OptionCategory.Sabotage, true).SetColor(new Color32(0, 153, 255, 255));
            void UpdateSabotageOptions(bool disable)
            {
                DisableReactorSabotage.SetEnabled(!disable);
                DisableCommsSabotage.SetEnabled(!disable);
                DisableO2Sabotage.SetEnabled(!disable);
                DisableElectricalSabotage.SetEnabled(!disable);
                DisableLaboratorySabotage.SetEnabled(!disable);
                DisableHeliSabotage.SetEnabled(!disable);
                DisableMushroomSabotage.SetEnabled(!disable);

                if (disable)
                {
                    DisableReactorSabotage.SetValue(0);
                    DisableCommsSabotage.SetValue(0);
                    DisableO2Sabotage.SetValue(0);
                    DisableElectricalSabotage.SetValue(0);
                    DisableLaboratorySabotage.SetValue(0);
                    DisableHeliSabotage.SetValue(0);
                    DisableMushroomSabotage.SetValue(0);
                }
            }
            DisableAllSabotages.RegisterUpdateValueEvent((sender, args) =>
            {
                bool disable = ((OptionItem)sender).GetBool();
                UpdateSabotageOptions(disable);
            });
            TaskVisibilityController.UpdateTaskVisibility();
            IsLoaded = true;
        }
        public static void ReOpenSettings()
        {
            if (_reOpenSettingsScheduled)
                return;

            _reOpenSettingsScheduled = true;

            OptionItem.SyncAllOptions();

            var menu = GameObject.FindObjectOfType<GameSettingMenu>();
            if (menu != null)
                menu.Close();

            LateTask.New(() =>
            {
                if (!GameStates.isLobby)
                    return;

                var hostButtons = GameObject.Find("Host Buttons");
                var editBtn = hostButtons?.transform.FindChild("Edit")?.GetComponent<PassiveButton>() ??
                              hostButtons?.transform.FindChild("EditButton")?.GetComponent<PassiveButton>();

                if (editBtn != null)
                    editBtn.ReceiveClickDown();

            }, 0.01f, "Reopen Step 1: Open Menu");

            LateTask.New(() =>
            {
                try
                {
                    var newMenu = GameObject.Find("PlayerOptionsMenu(Clone)");
                    if (newMenu == null)
                        return;

                    if (GameSettingMenuPatch.SettingsButton != null)
                    {
                        GameSettingMenuPatch.SettingsButton.ReceiveClickDown();
                        GameSettingMenuPatch.SettingsButton.OnClick.Invoke();
                    }
                }
                finally
                {
                    _reOpenSettingsScheduled = false;
                }

            }, 0.18f, "Reopen Step 2: Switch to Mod Tab");
        }
    }
    [HarmonyPatch(typeof(GameOptionsMenu), nameof(GameOptionsMenu.Update))]
    public static class GameOptionsMenu_Update_ForceFFA_HnSOnly_Patch
    {
        private static float seekerSyncTimer = 0f;

        public static void Postfix()
        {
            try
            {

                GameModeType gameMode = (GameModeType)Options.GameMode.GetValue();

                if (GameStates.isHideNSeek)
                {
                    if (gameMode == GameModeType.FFA)
                    {
                        Options.GameMode.SetValue(3);
                    }

                    seekerSyncTimer += Time.deltaTime;

                    if (seekerSyncTimer >= 2f)
                    {
                        seekerSyncTimer = 0f;
                        UpdateSeekerSelectionsAndSyncFirstSeeker();
                    }
                }
                else
                {
                    seekerSyncTimer = 0f;
                }
            }
            catch
            {
            }
        }

        private static void UpdateSeekerSelectionsAndSyncFirstSeeker()
        {
            try
            {
                if (AmongUsClient.Instance == null || GameData.Instance == null)
                    return;

                if (Options.SeekerSelections == null || Options.SeekerSelections.Count <= 0)
                    return;

                var namesList = new System.Collections.Generic.List<string>();
                namesList.Add("Round-robin");

                foreach (var player in GameData.Instance.AllPlayers)
                {
                    if (player != null && !player.Disconnected)
                        namesList.Add(player.PlayerName);
                }

                string[] namesArray = namesList.ToArray();

                foreach (var opt in Options.SeekerSelections)
                {
                    if (opt == null)
                        continue;

                    opt.Selections = namesArray;
                    opt.Rule = (0, namesArray.Length - 1, 1);
                }

                SyncVanillaSeekerToSetSeeker1(namesArray);
            }
            catch
            {
            }
        }

        private static void SyncVanillaSeekerToSetSeeker1(string[] namesArray)
        {
            try
            {
                if (namesArray == null || namesArray.Length <= 1)
                    return;

                var hnsOptions = GameOptionsManager.Instance.CurrentGameOptions.Cast<HideNSeekGameOptionsV10>();

                if (hnsOptions == null)
                    return;

                int vanillaSeekerId = hnsOptions.ImpostorPlayerID;

                if (vanillaSeekerId < 0)
                    return;

                string vanillaSeekerName = GetPlayerNameById(vanillaSeekerId);

                if (string.IsNullOrEmpty(vanillaSeekerName))
                    return;

                int index = -1;

                for (int i = 0; i < namesArray.Length; i++)
                {
                    if (namesArray[i] == vanillaSeekerName)
                    {
                        index = i;
                        break;
                    }
                }

                if (index <= 0)
                    return;

                StringOptionItem setSeeker1 = Options.SeekerSelections[0];

                if (setSeeker1 == null)
                    return;

                try
                {
                    if (setSeeker1.GetString() == vanillaSeekerName)
                        return;
                }
                catch
                {
                }

                setSeeker1.SetValue(index);
            }
            catch
            {
            }
        }

        private static string GetPlayerNameById(int playerId)
        {
            try
            {
                if (GameData.Instance != null)
                {
                    foreach (var player in GameData.Instance.AllPlayers)
                    {
                        if (player == null || player.Disconnected)
                            continue;

                        if (player.PlayerId == playerId)
                            return player.PlayerName;
                    }
                }
            }
            catch
            {
            }

            try
            {
                foreach (var player in PlayerControl.AllPlayerControls)
                {
                    if (player == null || player.Data == null)
                        continue;

                    if (player.PlayerId == playerId)
                        return player.Data.PlayerName;
                }
            }
            catch
            {
            }

            return "";
        }
    }
    [HarmonyPatch(typeof(PlayerControl), nameof(PlayerControl.RpcSyncSettings))]
    public class RpcSyncSettingsPatch
    {
        public static void Postfix()
        {
            OptionItem.SyncAllOptions();
        }
    }
}