Esempio n. 1
0
 public static void Postfix(GameOptionsMenu __instance)
 {
     __instance.Children
     .Single(o => o.Title == StringNames.GameNumImpostors)
     .Cast <NumberOption>()
     .ValidRange = new FloatRange(0, byte.MaxValue);
 }
Esempio n. 2
0
        public static void Postfix(GameOptionsMenu __instance)
        {
            __instance.GetComponentInParent <Scroller>().YBounds.max = -0.5F + __instance.MCAHCPOHNFI.Length * 0.55F;
            timer += Time.deltaTime;
            if (timer < 0.1f)
            {
                return;
            }
            timer = 0f;

            float offset = -7.85f;

            foreach (CustomOption option in CustomOption.options)
            {
                if (option?.optionBehaviour?.gameObject != null)
                {
                    bool enabled = true;
                    var  parent  = option.parent;
                    while (parent != null && enabled)
                    {
                        enabled = parent.selection != 0;
                        parent  = parent.parent;
                    }
                    option.optionBehaviour.gameObject.SetActive(enabled);
                    if (enabled)
                    {
                        offset -= option.isHeader ? 0.75f : 0.5f;
                        option.optionBehaviour.transform.localPosition = new Vector3(option.optionBehaviour.transform.localPosition.x, offset, option.optionBehaviour.transform.localPosition.z);
                    }
                }
            }
        }
Esempio n. 3
0
        private static void GameOptionsMenuUpdate(GameOptionsMenu __instance)
        {
            if (Options.Count > 0)
            {
                List <OptionBehaviour> options = __instance.Children.Take(defaultGameOptionsCount).ToList();

                float lowestY = options.Min(option => option.transform.localPosition.y);
                int   i       = 0;

                foreach (CustomOption option in Options)
                {
                    if (!option.GameSetting?.gameObject)
                    {
                        continue;
                    }

                    option.GameSetting.gameObject.SetActive(option.MenuVisible);

                    if (option.MenuVisible)
                    {
                        option.GameSetting.transform.localPosition = new Vector3(option.GameSetting.transform.localPosition.x, lowestY - ++i * 0.5F, option.GameSetting.transform.localPosition.z);

                        options.Add(option.GameSetting);
                    }
                }

                __instance.Children = options.ToArray();
            }

            __instance.GetComponentInParent <Scroller>().YBounds.max = (__instance.Children.Length - 7) * 0.5F + 0.13F;
        }
Esempio n. 4
0
        public static void Postfix(GameOptionsMenu __instance)
        {
            var template = UnityEngine.Object.FindObjectsOfType <StringOption>().FirstOrDefault();

            if (template == null)
            {
                return;
            }

            List <OptionBehaviour> allOptions = __instance.IGFJIPMAJHF.ToList();

            for (int i = 0; i < CustomOption.options.Count; i++)
            {
                CustomOption option = CustomOption.options[i];
                if (option.optionBehaviour == null)
                {
                    StringOption stringOption = UnityEngine.Object.Instantiate(template, template.transform.parent);
                    allOptions.Add(stringOption);
                    stringOption.transform.localPosition = new Vector3(template.transform.localPosition.x, -7.85f - (i + 1) * 0.5F, template.transform.localPosition.z);

                    stringOption.OnValueChanged = new Action <OptionBehaviour>((o) => {});
                    stringOption.TitleText.Text = option.name;
                    stringOption.Value          = stringOption.IOFLMCGMJBA = option.selection;
                    stringOption.ValueText.Text = option.selections[option.selection].ToString();

                    option.optionBehaviour = stringOption;
                }
                option.optionBehaviour.gameObject.SetActive(true);
            }
            __instance.IGFJIPMAJHF = allOptions.ToArray();
        }
Esempio n. 5
0
        public static void Postfix(GameOptionsMenu __instance)
        {
            var template = UnityEngine.Object.FindObjectsOfType <StringOption>().FirstOrDefault();

            if (template == null)
            {
                return;
            }

            List <OptionBehaviour> allOptions = __instance.MCAHCPOHNFI.ToList();

            for (int i = 0; i < CustomOption.options.Count; i++)
            {
                CustomOption option = CustomOption.options[i];
                if (option.optionBehaviour == null)
                {
                    StringOption stringOption = UnityEngine.Object.Instantiate(template, template.transform.parent);
                    allOptions.Add(stringOption);

                    stringOption.OnValueChanged = new Action <OptionBehaviour>((o) => {});
                    stringOption.TitleText.text = option.name;
                    stringOption.Value          = stringOption.LCDAKOCANPH = option.selection;
                    stringOption.ValueText.text = option.selections[option.selection].ToString();

                    option.optionBehaviour = stringOption;
                }
                option.optionBehaviour.gameObject.SetActive(true);
            }
            __instance.MCAHCPOHNFI = allOptions.ToArray();
        }
        public static void Postfix1(GameOptionsMenu __instance)
        {
            if (showJesterOption != null)
            {
                showJesterOption.transform.position = option.transform.position - new Vector3(0, 0.5f, 0);

                __instance.GetComponentInParent <Scroller>().YBounds.max = defaultBounds + 0.5f;
            }
        }
Esempio n. 7
0
        public static void Postfix2(GameOptionsMenu __instance)
        {
            OptionBehaviour option = __instance.MCAHCPOHNFI[__instance.MCAHCPOHNFI.Count - 2];

            if (bothLoversDie != null)
            {
                bothLoversDie.transform.position = option.transform.position - new Vector3(0, 0.5f, 0);
            }
        }
Esempio n. 8
0
        private static void GameOptionsMenuStart(GameOptionsMenu __instance)
        {
            List <OptionBehaviour> customOptions = GetGameOptions(__instance.GetComponentsInChildren <OptionBehaviour>().Min(option => option.transform.localPosition.y));

            OptionBehaviour[] defaultOptions = __instance.Children;

            defaultGameOptionsCount = defaultOptions.Length;

            __instance.Children = defaultOptions.Concat(customOptions).ToArray();
        }
Esempio n. 9
0
            public static void Postfix(GameOptionsMenu __instance)
            {
                var customOptions = GetGameOptions(__instance
                                                   .GetComponentsInChildren <OptionBehaviour>().Min(option => option.transform.localPosition.y));
                var defaultOptions = __instance.Children;

                var options = defaultOptions.Concat(customOptions).ToArray();

                __instance.Children = new Il2CppReferenceArray <OptionBehaviour>(options);
            }
Esempio n. 10
0
        public static void Postfix(GameOptionsMenu __instance)
        {
            instance = __instance;

            defaultBounds = __instance.GetComponentInParent <Scroller>().YBounds.max;

            option = __instance.Children[__instance.Children.Count - 1];

            CustomPlayerMenuPatch.AddOptions();
        }
        public static void Postfix2(GameOptionsMenu __instance)
        {
            OptionBehaviour option = __instance.MCAHCPOHNFI[__instance.MCAHCPOHNFI.Count - 3];

            if (SheriffCooldown != null & showSheriffOption != null)
            {
                showSheriffOption.transform.position = option.transform.position - new Vector3(0, 0.5f, 0);
                SheriffCooldown.transform.position   = option.transform.position - new Vector3(0, 1f, 0);
            }
        }
Esempio n. 12
0
        public static void Postfix2(GameOptionsMenu __instance)
        {
            __instance.GetComponentInParent <Scroller>().YBounds.max = (__instance.MCAHCPOHNFI.Count - 7) * 0.5F + 0.13F;
            OptionBehaviour option = __instance.MCAHCPOHNFI[CurrentCount - 1];

            if (MorphDuration != null & MorphCooldown != null)
            {
                MorphDuration.transform.position = option.transform.position - new Vector3(0, 0.5f, 0);
                MorphCooldown.transform.position = option.transform.position - new Vector3(0, 1f, 0);
            }
        }
Esempio n. 13
0
 public static void Postfix(GameOptionsMenu __instance)
 {
     foreach (var child in __instance.Children)
     {
         if (child.name == "CrewmateVision" || child.name == "ImpostorVision")
         {
             var option = child.GetComponent <NumberOption>();
             option.Increment      = 0.1f;
             option.ValidRange.min = 0f;
         }
     }
 }
Esempio n. 14
0
 public static void Postfix(ref GameOptionsMenu __instance)
 {
     /*
      * 2 options need 1 = / 2
      * __instance.Children.Length = number of options
      * don't calculate the first 7 options = -7
      * bottom margin = 0.2
      * For v2021.11.9 :
      * no need for the bottom margin anymore
      * don't calculate the first 8.5 options = -8.5
      * = (__instance.Children.Length - 8.5) / 2;
      */
     __instance.GetComponentInParent <Scroller>().YBounds.max = (__instance.Children.Length - 7) / 2.0f + 0.2f;
 }
Esempio n. 15
0
            static void Postfix(ref GameOptionsMenu __instance)
            {
                var   lowestY = GetLowestConfigY(__instance);
                float offset  = 0.0f;

                foreach (var opt in options)
                {
                    offset += 0.5f;

                    opt.Start(__instance, lowestY, offset, OnValueChanged);
                }

                __instance.GetComponentInParent <Scroller>().YBounds.max += offset - 0.9f;
            }
Esempio n. 16
0
            static void Postfix(ref GameOptionsMenu __instance)
            {
                var lowestY = GetLowestConfigY(__instance);

                var countOption = UnityEngine.Object.Instantiate(__instance.GetComponentsInChildren <NumberOption>()[1],
                                                                 __instance.transform);

                countOption.transform.localPosition = new Vector3(countOption.transform.localPosition.x, lowestY - 0.5f,
                                                                  countOption.transform.localPosition.z);
                countOption.Title = maxPlayerAdminTitle;
                countOption.Value = maxPlayerAdmin;
                var str = "";

                TranslationController_GetString.Prefix(countOption.Title, ref str);
                countOption.TitleText.Text = str;
                countOption.OnValueChanged = new Action <OptionBehaviour>(OnValueChanged);
                countOption.gameObject.AddComponent <OptionBehaviour>();
                countOption.ValidRange.max = 10;
                countOption.ValidRange.min = 3;

                countOption = UnityEngine.Object.Instantiate(__instance.GetComponentsInChildren <NumberOption>()[1],
                                                             __instance.transform);
                countOption.transform.localPosition = new Vector3(countOption.transform.localPosition.x, lowestY - 1.0f,
                                                                  countOption.transform.localPosition.z);
                countOption.Title = maxPlayerCamsTitle;
                countOption.Value = maxPlayerCams;
                str = "";
                TranslationController_GetString.Prefix(countOption.Title, ref str);
                countOption.TitleText.Text = str;
                countOption.OnValueChanged = new Action <OptionBehaviour>(OnValueChanged);
                countOption.gameObject.AddComponent <OptionBehaviour>();
                countOption.ValidRange.max = 10;
                countOption.ValidRange.min = 3;

                countOption = UnityEngine.Object.Instantiate(__instance.GetComponentsInChildren <NumberOption>()[1],
                                                             __instance.transform);
                countOption.transform.localPosition = new Vector3(countOption.transform.localPosition.x, lowestY - 1.5f,
                                                                  countOption.transform.localPosition.z);
                countOption.Title = maxPlayerVitalsTitle;
                countOption.Value = maxPlayerVitals;
                str = "";
                TranslationController_GetString.Prefix(countOption.Title, ref str);
                countOption.TitleText.Text = str;
                countOption.OnValueChanged = new Action <OptionBehaviour>(OnValueChanged);
                countOption.gameObject.AddComponent <OptionBehaviour>();
                countOption.ValidRange.max = 10;
                countOption.ValidRange.min = 3;

                __instance.GetComponentInParent <Scroller>().YBounds.max += 0.6f;
            }
Esempio n. 17
0
            private static void InitializeString(GameOptionsMenu __instance, string name, string title,
                                                 int initialSelection, float y)
            {
                var cloneSource = Object.FindObjectOfType <StringOption>();
                var option      = Object.Instantiate(cloneSource.gameObject, __instance.gameObject.transform);

                option.name = name;
                var localPosition = option.transform.localPosition;
                var kv            = option.GetComponent <StringOption>();

                kv.TitleText.Text = title;
                kv.Value          = initialSelection;
                option.transform.localPosition = new Vector3(localPosition.x, y, localPosition.z);
            }
Esempio n. 18
0
        public override void Start(GameOptionsMenu __instance, float lowestY, float offset,
                                   Action <OptionBehaviour> callback)
        {
            var toggleOption = UnityEngine.Object.Instantiate(
                __instance.GetComponentsInChildren <ToggleOption>()[1],
                __instance.transform);

            toggleOption.transform.localPosition = new Vector3(toggleOption.transform.localPosition.x,
                                                               lowestY - offset, toggleOption.transform.localPosition.z);
            toggleOption.Title             = optionTitleName;
            toggleOption.CheckMark.enabled = value;
            toggleOption.TitleText.Text    = optionTitle;
            toggleOption.OnValueChanged    = new Action <OptionBehaviour>(callback);
            toggleOption.gameObject.AddComponent <OptionBehaviour>();
        }
Esempio n. 19
0
            public static void Postfix(GameOptionsMenu __instance)
            {
                var customOptions = CreateOptions(__instance);
                var y             = __instance.GetComponentsInChildren <OptionBehaviour>()
                                    .Max(option => option.transform.localPosition.y);
                var x = __instance.Children[1].transform.localPosition.x;
                var z = __instance.Children[1].transform.localPosition.z;
                var i = 0;

                foreach (var option in customOptions)
                {
                    option.transform.localPosition = new Vector3(x, y - i++ *0.5f, z);
                }

                __instance.Children = new Il2CppReferenceArray <OptionBehaviour>(customOptions.ToArray());
            }
            public static void Postfix(GameOptionsMenu __instance)
            {
                List <OptionBehaviour> customOptions = GetGameOptions(__instance.GetComponentsInChildren <OptionBehaviour>().Min(option => option.transform.localPosition.y));
                Il2CppReferenceArray <OptionBehaviour> defaultOptions = __instance.Children;

                OptionBehaviour[] options = defaultOptions.Concat(customOptions).ToArray();

                //EssentialsPlugin.Logger.LogInfo($"__instance.Children.Count {__instance.Children.Count}");

                __instance.Children = new Il2CppReferenceArray <OptionBehaviour>(options);

                //__instance.GetComponentInParent<Scroller>().YBounds.max = options.Length * /*0.3455F*/0.4F;
                //__instance.GetComponentInParent<Scroller>().YBounds.max = -0.5F + options.Length * 0.4F;

                //EssentialsPlugin.Logger.LogInfo($"__instance.Children.Count2 {__instance.Children.Count}");
            }
Esempio n. 21
0
            static void Postfix(ref GameOptionsMenu __instance)
            {
                var   lowestY = GetLowestConfigY(__instance);
                float offset  = 0.0f;

                foreach (var opt in options)
                {
                    offset += 0.5f;
                    if (opt.onlyHost && !AmongUsClient.Instance.HHBLOCGKFAB)
                    {
                        continue;
                    }
                    opt.Start(__instance, lowestY, offset, OnValueChanged);
                }

                __instance.GetComponentInParent <Scroller>().YBounds.max += offset - 0.9f;
            }
Esempio n. 22
0
            static void Postfix(ref GameOptionsMenu __instance)
            {
                var thisPos  = -8.35f;
                var killCool = __instance.GetComponentsInChildren <NumberOption>()[1];

                foreach (NumberOption num in __instance.GetComponentsInChildren <NumberOption>())
                {
                    if (num.name == "KillCooldown")
                    {
                        killCool = num;
                    }
                }

                foreach (CustomNumberOption custom in numOpts)
                {
                    var countOption = UnityEngine.Object.Instantiate(killCool, __instance.transform);
                    countOption.transform.localPosition = new Vector3(countOption.transform.localPosition.x, thisPos, countOption.transform.localPosition.z);
                    countOption.Title = custom.numOptionTitle;
                    countOption.Value = custom.value;
                    var str = "";
                    customTranslationController.Prefix(countOption.Title, ref str);
                    countOption.TitleText.text = str;
                    countOption.OnValueChanged = new Action <OptionBehaviour>(OnValueChanged);
                    countOption.gameObject.AddComponent <OptionBehaviour>();
                    __instance.GetComponentInParent <Scroller>().YBounds.max += 0.3f;
                    thisPos -= 0.50f;
                }

                foreach (CustomBoolOption custom in boolOpts)
                {
                    var toggleOption = UnityEngine.Object.Instantiate(__instance.GetComponentsInChildren <ToggleOption>()[1], __instance.transform);
                    toggleOption.transform.localPosition = new Vector3(toggleOption.transform.localPosition.x, thisPos, toggleOption.transform.localPosition.z);
                    toggleOption.Title             = custom.boolOptionTitle;
                    toggleOption.CheckMark.enabled = custom.value;
                    var str2 = "";
                    customTranslationController.Prefix(toggleOption.Title, ref str2);
                    toggleOption.TitleText.text = str2;
                    toggleOption.OnValueChanged = new Action <OptionBehaviour>(OnValueChanged);
                    toggleOption.gameObject.AddComponent <OptionBehaviour>();
                    __instance.GetComponentInParent <Scroller>().YBounds.max += 0.3f;
                    thisPos -= 0.50f;
                }
            }
Esempio n. 23
0
        public override void Start(GameOptionsMenu __instance, float lowestY, float offset,
                                   Action <OptionBehaviour> callback)
        {
            var countOption = UnityEngine.Object.Instantiate(
                __instance.GetComponentsInChildren <NumberOption>()[1],
                __instance.transform);

            countOption.transform.localPosition = new Vector3(countOption.transform.localPosition.x,
                                                              lowestY - offset,
                                                              countOption.transform.localPosition.z);
            countOption.Title          = optionTitleName;
            countOption.Value          = value;
            countOption.TitleText.Text = optionTitle;
            countOption.OnValueChanged = new Action <OptionBehaviour>(callback);
            countOption.gameObject.AddComponent <OptionBehaviour>();
            countOption.ValidRange.max = max;
            countOption.ValidRange.min = min;
            countOption.Increment      = step;
            countOption.FormatString   = format;
        }
Esempio n. 24
0
            public static void Postfix(ref GameOptionsMenu __instance)
            {
                float        lowestY      = __instance.GetComponentsInChildren <OptionBehaviour>().Min(o => o.transform.position.y) - 0.2f;
                ToggleOption togglePrefab = __instance.Children.Where(o => o.TryCast <ToggleOption>() != null).First(o => o.Title != StringNames.GameRecommendedSettings).Cast <ToggleOption>(); // GameRecommendedSettings has a specific design
                NumberOption numberPrefab = __instance.GetComponentInChildren <NumberOption>();
                StringOption stringPrefab = __instance.GetComponentInChildren <StringOption>();
                byte         optionsAdded = 0;

                foreach (var baseOption in
                         OptionsManager.LimitOptions.Values
                         .Concat(OptionsManager.CustomOptions.SelectMany(p => p.Value))
                         )
                {
                    var option = Object.Instantiate <OptionBehaviour>(
                        baseOption switch
                    {
                        CustomToggleOption => togglePrefab,
                        CustomNumberOption => numberPrefab,
                        CustomStringOption => stringPrefab,
                        _ => throw new InvalidCastException($"{nameof(baseOption)} was unknown type")
                    },
Esempio n. 25
0
            public static void Postfix(GameOptionsMenu __instance)
            {
                var y = __instance.GetComponentsInChildren <OptionBehaviour>()
                        .Max(option => option.transform.localPosition.y);
                float x, z;

                if (__instance.Children.Length == 1)
                {
                    x = __instance.Children[0].transform.localPosition.x;
                    z = __instance.Children[0].transform.localPosition.z;
                }
                else
                {
                    x = __instance.Children[1].transform.localPosition.x;
                    z = __instance.Children[1].transform.localPosition.z;
                }

                var i = 0;

                foreach (var option in __instance.Children)
                {
                    option.transform.localPosition = new Vector3(x, y - i++ *0.5f, z);
                }
            }
Esempio n. 26
0
 public abstract void Start(GameOptionsMenu __instance, float lowestY, float offset,
                            Action <OptionBehaviour> callback);
 static void Postfix(ref GameOptionsMenu __instance)
 {
     defaultBounds = __instance.GetComponentInParent <Scroller>().YBounds.max;
 }
Esempio n. 28
0
 static float GetLowestConfigY(GameOptionsMenu __instance)
 {
     return(__instance.GetComponentsInChildren <OptionBehaviour>()
            .Min(option => option.transform.localPosition.y));
 }
Esempio n. 29
0
        /// <summary>
        /// Sets the option's value.
        /// </summary>
        /// <remarks>
        /// Does nothing when the value type differs or when the value matches the current value.
        /// </remarks>
        /// <param name="value">The new value</param>
        /// <param name="raiseEvents">Whether or not to raise events</param>
        protected virtual void SetValue(object value, bool raiseEvents)
        {
            if (value?.GetType() != Value?.GetType() || Value == value)
            {
                return;                                                         // Refuse value updates that don't match the option type.
            }
            if (raiseEvents && OnValueChanged != null && AmongUsClient.Instance?.AmHost == true && PlayerControl.LocalPlayer)
            {
                object lastValue = value;

                OptionOnValueChangedEventArgs args = OnValueChangedEventArgs(value, Value);
                foreach (EventHandler <OptionOnValueChangedEventArgs> handler in OnValueChanged.GetInvocationList())
                {
                    handler(this, args);

                    if (args.Value.GetType() != value.GetType())
                    {
                        args.Value  = lastValue;
                        args.Cancel = false;

                        EssentialsPlugin.Logger.LogWarning($"A handler for option \"{Name}\" attempted to change value type, ignored.");
                    }

                    lastValue = args.Value;

                    if (args.Cancel)
                    {
                        return;              // Handler cancelled value change.
                    }
                }

                value = args.Value;
            }

            if (OldValue != Value)
            {
                OldValue = Value;
            }

            Value = value;

            //if (SendRpc && GameSetting != null && AmongUsClient.Instance?.AmHost == true && PlayerControl.LocalPlayer) Rpc.Send(new (string, CustomOptionType, object)[] { this });
            if (SendRpc && GameObject != null && AmongUsClient.Instance?.AmHost == true && PlayerControl.LocalPlayer)
            {
                Rpc.Instance.Send(this);
            }

            UpdateGameObject();

            if (raiseEvents)
            {
                ValueChanged?.SafeInvoke(this, ValueChangedEventArgs(value, Value), nameof(ValueChanged));
            }

            if (GameObject == null)
            {
                return;                     // Game object does not exist, menu is closed
            }
            // Refresh the value of all options in the menu, in case an option affects another.
            try
            {
                GameOptionsMenu optionsMenu = Object.FindObjectOfType <GameOptionsMenu>();

                if (optionsMenu == null)
                {
                    return;
                }

                for (int i = 0; i < optionsMenu.Children.Length; i++)
                {
                    OptionBehaviour optionBehaviour = optionsMenu.Children[i];
                    optionBehaviour.enabled = false;
                    optionBehaviour.enabled = true;
                }
            }
            catch
            {
            }
        }
Esempio n. 30
0
 public static void Postfix(ref GameOptionsMenu __instance)
 {
     __instance.GetComponentInParent <Scroller>().YBounds.max = 70f;
 }