D:\ValheimDev\Dumps\Old\assembly_valheim\ServerOptionsGUI.cs D:\ValheimDev\Dumps\Latest\assembly_valheim\ServerOptionsGUI.cs
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using TMPro; using TMPro;
using UnityEngine; using UnityEngine;
using UnityEngine.EventSystems; using UnityEngine.EventSystems;
   
public class ServerOptionsGUI : MonoBehaviour public class ServerOptionsGUI : MonoBehaviour
{ {
    public void Awake()     public void Awake()
    {     {
        ServerOptionsGUI.m_instance = this;         ServerOptionsGUI.m_instance = this;
        ServerOptionsGUI.m_modifiers = this.m_modifiersRoot.transform.GetComponentsInChildren<KeyUI>();         ServerOptionsGUI.m_modifiers = this.m_modifiersRoot.transform.GetComponentsInChildren<KeyUI>();
        ServerOptionsGUI.m_presets = this.m_presetsRoot.transform.GetComponentsInChildren<KeyButton>();         ServerOptionsGUI.m_presets = this.m_presetsRoot.transform.GetComponentsInChildren<KeyButton>();
    }     }
   
    private void Update()     private void Update()
    {     {
        if (ZNet.instance != null)         if (ZNet.instance != null)
        {         {
            base.gameObject.SetActive(false);             base.gameObject.SetActive(false);
            return;             return;
        }         }
        this.m_toolTipPanel.gameObject.SetActive(this.m_toolTipText.text.Length > 0);         this.m_toolTipPanel.gameObject.SetActive(this.m_toolTipText.text.Length > 0);
        if (EventSystem.current.currentSelectedGameObject == null)         if (EventSystem.current.currentSelectedGameObject == null)
        {         {
            EventSystem.current.SetSelectedGameObject(this.m_doneButton);             EventSystem.current.SetSelectedGameObject(this.m_doneButton);
        }         }
    }     }
   
    public void ReadKeys(World world)     public void ReadKeys(World world)
    {     {
        if (world == null)         if (world == null)
        {         {
            return;             return;
        }         }
        KeyUI[] modifiers = ServerOptionsGUI.m_modifiers;         KeyUI[] modifiers = ServerOptionsGUI.m_modifiers;
        for (int i = 0; i < modifiers.Length; i++)         for (int i = 0; i < modifiers.Length; i++)
        {         {
            modifiers[i].TryMatch(world, false);             modifiers[i].TryMatch(world, false);
        }         }
    }     }
   
    public void SetKeys(World world)     public void SetKeys(World world)
    {     {
        if (world == null)         if (world == null)
        {         {
            return;             return;
        }         }
        string text = "";         string text = "";
        bool flag = false;         bool flag = false;
        foreach (KeyUI keyUI in ServerOptionsGUI.m_modifiers)         foreach (KeyUI keyUI in ServerOptionsGUI.m_modifiers)
        {         {
            keyUI.SetKeys(world);             keyUI.SetKeys(world);
            KeySlider keySlider = keyUI as KeySlider;             KeySlider keySlider = keyUI as KeySlider;
            if (keySlider != null && keySlider.m_manualSet)             if (keySlider != null && keySlider.m_manualSet)
            {             {
                flag = true;                 flag = true;
            }             }
        }         }
        if (flag)         if (flag)
        {         {
            KeyUI[] array = ServerOptionsGUI.m_modifiers;             KeyUI[] array = ServerOptionsGUI.m_modifiers;
            for (int i = 0; i < array.Length; i++)             for (int i = 0; i < array.Length; i++)
            {             {
                KeySlider keySlider2 = array[i] as KeySlider;                 KeySlider keySlider2 = array[i] as KeySlider;
                if (keySlider2 != null)                 if (keySlider2 != null)
                {                 {
                    if (text.Length > 0)                     if (text.Length > 0)
                    {                     {
                        text += ":";                         text += ":";
                    }                     }
                    text = text + keySlider2.m_modifier.ToString().ToLower() + "_" + keySlider2.GetValue().ToString().ToLower();                     text = text + keySlider2.m_modifier.ToString().ToLower() + "_" + keySlider2.GetValue().ToString().ToLower();
                }                 }
            }             }
        }         }
        else if (text.Length == 0 && this.m_preset > WorldPresets.Custom)         else if (text.Length == 0 && this.m_preset > WorldPresets.Custom)
        {         {
            text = this.m_preset.ToString().ToLower();             text = this.m_preset.ToString().ToLower();
        }         }
        if (text.Length > 0)         if (text.Length > 0)
        {         {
            string text2 = GlobalKeys.Preset.ToString().ToLower() + " " + text;             string text2 = GlobalKeys.Preset.ToString().ToLower() + " " + text;
            if (ZoneSystem.instance)             if (ZoneSystem.instance)
            {             {
                ZoneSystem.instance.SetGlobalKey(text2);                 ZoneSystem.instance.SetGlobalKey(text2);
            }             }
            else             else
            {             {
                world.m_startingGlobalKeys.Add(text2);                 world.m_startingGlobalKeys.Add(text2);
            }             }
            Terminal.Log("Saving modifier preset: " + text);             Terminal.Log("Saving modifier preset: " + text);
        }         }
    }     }
   
    public void OnPresetButton(KeyButton button)     public void OnPresetButton(KeyButton button)
    {     {
        foreach (KeyUI keyUI in ServerOptionsGUI.m_modifiers)         foreach (KeyUI keyUI in ServerOptionsGUI.m_modifiers)
        {         {
            string text;             string text;
            keyUI.TryMatch(button.m_keys, out text, true);             keyUI.TryMatch(button.m_keys, out text, true);
            KeySlider keySlider = keyUI as KeySlider;             KeySlider keySlider = keyUI as KeySlider;
            if (keySlider != null)             if (keySlider != null)
            {             {
                keySlider.m_manualSet = false;                 keySlider.m_manualSet = false;
            }             }
        }         }
        this.m_preset = button.m_preset;         this.m_preset = button.m_preset;
    }     }
   
    public void SetPreset(World world, string combinedString)     public void SetPreset(World world, string combinedString)
    {     {
        WorldPresets worldPresets;         WorldPresets worldPresets;
        if (Enum.TryParse<WorldPresets>(combinedString, true, out worldPresets))         if (Enum.TryParse<WorldPresets>(combinedString, true, out worldPresets))
        {         {
            this.SetPreset(world, worldPresets);             this.SetPreset(world, worldPresets);
            return;             return;
        }         }
        foreach (string text in combinedString.Split(':', StringSplitOptions.None))         foreach (string text in combinedString.Split(':', StringSplitOptions.None))
        {         {
            string[] array2 = text.Split('_', StringSplitOptions.None);             string[] array2 = text.Split('_', StringSplitOptions.None);
            WorldModifiers worldModifiers;             WorldModifiers worldModifiers;
            WorldModifierOption worldModifierOption;             WorldModifierOption worldModifierOption;
            if (array2.Length == 2 && Enum.TryParse<WorldModifiers>(array2[0], true, out worldModifiers) && Enum.TryParse<WorldModifierOption>(array2[1], true, out worldModifierOption))             if (array2.Length == 2 && Enum.TryParse<WorldModifiers>(array2[0], true, out worldModifiers) && Enum.TryParse<WorldModifierOption>(array2[1], true, out worldModifierOption))
            {             {
                this.SetPreset(world, worldModifiers, worldModifierOption);                 this.SetPreset(world, worldModifiers, worldModifierOption);
            }             }
            else             else
            {             {
                Terminal.LogError("Invalid preset string data '" + text + "'");                 Terminal.LogError("Invalid preset string data '" + text + "'");
            }             }
        }         }
    }     }
   
    public void SetPreset(World world, WorldPresets preset)     public void SetPreset(World world, WorldPresets preset)
    {     {
        Terminal.Log(string.Format("Setting World preset: {0}", preset));         Terminal.Log(string.Format("Setting World preset: {0}", preset));
        foreach (KeyButton keyButton in ServerOptionsGUI.m_presets)         foreach (KeyButton keyButton in ServerOptionsGUI.m_presets)
        {         {
            if (keyButton.m_preset == preset)             if (keyButton.m_preset == preset)
            {             {
                keyButton.SetKeys(world);                 keyButton.SetKeys(world);
                ZoneSystem instance = ZoneSystem.instance;                 ZoneSystem instance = ZoneSystem.instance;
                if (instance != null)                 if (instance != null)
                {                 {
                    instance.UpdateWorldRates();                     instance.UpdateWorldRates();
                }                 }
                this.m_preset = preset;                 this.m_preset = preset;
                return;                 return;
            }             }
        }         }
        Terminal.LogError(string.Format("Missing settings for preset: {0}", preset));         Terminal.LogError(string.Format("Missing settings for preset: {0}", preset));
    }     }
   
    public void SetPreset(World world, WorldModifiers preset, WorldModifierOption value)     public void SetPreset(World world, WorldModifiers preset, WorldModifierOption value)
    {     {
        Terminal.Log(string.Format("Setting WorldModifiers preset: '{0}' to '{1}'", preset, value));         Terminal.Log(string.Format("Setting WorldModifiers preset: '{0}' to '{1}'", preset, value));
        KeyUI[] modifiers = ServerOptionsGUI.m_modifiers;         KeyUI[] modifiers = ServerOptionsGUI.m_modifiers;
        int i = 0;         int i = 0;
        while (i < modifiers.Length)         while (i < modifiers.Length)
        {         {
            KeySlider keySlider = modifiers[i] as KeySlider;             KeySlider keySlider = modifiers[i] as KeySlider;
            if (keySlider != null && keySlider.m_modifier == preset)             if (keySlider != null && keySlider.m_modifier == preset)
            {             {
                keySlider.SetValue(value);                 keySlider.SetValue(value);
                keySlider.SetKeys(world);                 keySlider.SetKeys(world);
                ZoneSystem instance = ZoneSystem.instance;                 ZoneSystem instance = ZoneSystem.instance;
                if (instance == null)                 if (instance == null)
                {                 {
                    return;                     return;
                }                 }
                instance.UpdateWorldRates();                 instance.UpdateWorldRates();
                return;                 return;
            }             }
            else             else
            {             {
                i++;                 i++;
            }             }
        }         }
        Terminal.LogError(string.Format("Missing settings for preset: '{0}' to '{1}'", preset, value));         Terminal.LogError(string.Format("Missing settings for preset: '{0}' to '{1}'", preset, value));
    }     }
   
    public void OnCustomValueChanged(KeyUI element)     public void OnCustomValueChanged(KeyUI element)
    {     {
        this.m_preset = WorldPresets.Custom;         this.m_preset = WorldPresets.Custom;
    }     }
   
    public static void Initizalize()     public static void Initizalize()
    {     {
        KeyUI[] modifiers = ServerOptionsGUI.m_modifiers;         KeyUI[] modifiers = ServerOptionsGUI.m_modifiers;
        for (int i = 0; i < modifiers.Length; i++)         for (int i = 0; i < modifiers.Length; i++)
        {         {
            KeySlider keySlider = modifiers[i] as KeySlider;             KeySlider keySlider = modifiers[i] as KeySlider;
            if (keySlider != null)             if (keySlider != null)
            {             {
                if (keySlider.m_modifier == WorldModifiers.Default)                 if (keySlider.m_modifier == WorldModifiers.Default)
                {                 {
                    ZLog.LogError(string.Format("Modifier {0} is setup without a defined modifier", keySlider.m_nameLabel));                     ZLog.LogError(string.Format("Modifier {0} is setup without a defined modifier", keySlider.m_nameLabel));
                }                 }
                List<WorldModifierOption> list = new List<WorldModifierOption>();                 List<WorldModifierOption> list = new List<WorldModifierOption>();
                ServerOptionsGUI.m_modifierSetups[keySlider.m_modifier] = list;                 ServerOptionsGUI.m_modifierSetups[keySlider.m_modifier] = list;
                foreach (KeySlider.SliderSetting sliderSetting in keySlider.m_settings)                 foreach (KeySlider.SliderSetting sliderSetting in keySlider.m_settings)
                {                 {
                    if (sliderSetting.m_modifierValue == WorldModifierOption.Default)                     if (sliderSetting.m_modifierValue == WorldModifierOption.Default)
                    {                     {
                        ZLog.LogError(string.Format("Modifier setting {0} in {1} is setup without a modifier option", sliderSetting.m_name, keySlider.m_nameLabel));                         ZLog.LogError(string.Format("Modifier setting {0} in {1} is setup without a modifier option", sliderSetting.m_name, keySlider.m_nameLabel));
                    }                     }
                    list.Add(sliderSetting.m_modifierValue);                     list.Add(sliderSetting.m_modifierValue);
                }                 }
            }             }
        }         }
    }     }
   
    public static string GetWorldModifierSummary(IEnumerable<string> keys, bool alwaysShort = false, string divider = ", ")     public static string GetWorldModifierSummary(IEnumerable<string> keys, bool alwaysShort = false, string divider = ", ")
    {     {
        string text = "";         string text = "";
        string text2 = "";         string text2 = "";
        ServerOptionsGUI.m_tempKeys.Clear();         ServerOptionsGUI.m_tempKeys.Clear();
        ServerOptionsGUI.m_tempKeys.AddRange(keys);         ServerOptionsGUI.m_tempKeys.AddRange(keys);
        if (ServerOptionsGUI.m_tempKeys.Count == 0)         if (ServerOptionsGUI.m_tempKeys.Count == 0)
        {         {
            return "";             return "";
        }         }
.          if (ServerOptionsGUI.m_presets == null)
          {
              ZLog.LogWarning("Can't get world modifier summary until prefab has been initiated.");
              return "Error!";
          }
        KeyButton keyButton = null;         KeyButton keyButton = null;
        int num = 0;         int num = 0;
        foreach (KeyButton keyButton2 in ServerOptionsGUI.m_presets)         foreach (KeyButton keyButton2 in ServerOptionsGUI.m_presets)
        {         {
            if (keyButton2.m_preset != WorldPresets.Default && keyButton2.TryMatch(ServerOptionsGUI.m_tempKeys) && keyButton2.m_keys.Count > num)             if (keyButton2.m_preset != WorldPresets.Default && keyButton2.TryMatch(ServerOptionsGUI.m_tempKeys) && keyButton2.m_keys.Count > num)
            {             {
                keyButton = keyButton2;                 keyButton = keyButton2;
                num = keyButton2.m_keys.Count;                 num = keyButton2.m_keys.Count;
            }             }
        }         }
        if (keyButton != null)         if (keyButton != null)
        {         {
            text2 = keyButton.m_preset.GetDisplayString();             text2 = keyButton.m_preset.GetDisplayString();
            foreach (string text3 in keyButton.m_keys)             foreach (string text3 in keyButton.m_keys)
            {             {
                ServerOptionsGUI.m_tempKeys.Remove(text3);                 ServerOptionsGUI.m_tempKeys.Remove(text3);
            }             }
        }         }
        KeyUI[] modifiers = ServerOptionsGUI.m_modifiers;         KeyUI[] modifiers = ServerOptionsGUI.m_modifiers;
        for (int i = 0; i < modifiers.Length; i++)         for (int i = 0; i < modifiers.Length; i++)
        {         {
            string text4;             string text4;
            if (modifiers[i].TryMatch(ServerOptionsGUI.m_tempKeys, out text4, false))             if (modifiers[i].TryMatch(ServerOptionsGUI.m_tempKeys, out text4, false))
            {             {
                if (text.Length > 0)                 if (text.Length > 0)
                {                 {
                    text += divider;                     text += divider;
                }                 }
                text += text4;                 text += text4;
            }             }
        }         }
        if (alwaysShort)         if (alwaysShort)
        {         {
            if (text.Length > 0)             if (text.Length > 0)
            {             {
                if (text2.Length > 0)                 if (text2.Length > 0)
                {                 {
                    text2 += "+";                     text2 += "+";
                }                 }
                else                 else
                {                 {
                    text2 = "$menu_modifier_custom";                     text2 = "$menu_modifier_custom";
                }                 }
            }             }
            return text2;             return text2;
        }         }
        if (text.Length > 0)         if (text.Length > 0)
        {         {
            if (text2.Length <= 0)             if (text2.Length <= 0)
            {             {
                return text;                 return text;
            }             }
            text2 = text2 + divider + text;             text2 = text2 + divider + text;
        }         }
        return text2;         return text2;
    }     }
   
    public static bool TryConvertModifierKeysToCompactKVP<T>(ICollection<string> keys, out T result) where T : IDictionary<string, string>, new()     public static bool TryConvertModifierKeysToCompactKVP<T>(ICollection<string> keys, out T result) where T : IDictionary<string, string>, new()
    {     {
        result = new T();         result = new T();
        foreach (string text in keys)         foreach (string text in keys)
        {         {
            int num = text.IndexOf(' ');             int num = text.IndexOf(' ');
            string text2;             string text2;
            string text3;             string text3;
            if (num >= 0)             if (num >= 0)
            {             {
                text2 = text.Substring(0, num);                 text2 = text.Substring(0, num);
                text3 = text.Substring(num + 1);                 text3 = text.Substring(num + 1);
            }             }
            else             else
            {             {
                text2 = text;                 text2 = text;
                text3 = null;                 text3 = null;
            }             }
            GlobalKeys globalKeys;             GlobalKeys globalKeys;
            if (!Enum.TryParse<GlobalKeys>(text2, true, out globalKeys) || globalKeys.ToString().ToLower() != text2.ToLower())             if (!Enum.TryParse<GlobalKeys>(text2, true, out globalKeys) || globalKeys.ToString().ToLower() != text2.ToLower())
            {             {
                ZLog.LogError("Failed to parse key " + text + " as GlobalKeys!");                 ZLog.LogError("Failed to parse key " + text + " as GlobalKeys!");
                return false;                 return false;
            }             }
            int num5;             int num5;
            if (globalKeys == GlobalKeys.Preset)             if (globalKeys == GlobalKeys.Preset)
            {             {
                string text4 = "";                 string text4 = "";
                int[] array = text3.AllIndicesOf(':');                 int[] array = text3.AllIndicesOf(':');
                for (int i = 0; i < array.Length + 1; i++)                 for (int i = 0; i < array.Length + 1; i++)
                {                 {
                    int num2;                     int num2;
                    if (i > 0)                     if (i > 0)
                    {                     {
                        text4 += ":";                         text4 += ":";
                        num2 = array[i - 1] + 1;                         num2 = array[i - 1] + 1;
                    }                     }
                    else                     else
                    {                     {
                        num2 = 0;                         num2 = 0;
                    }                     }
                    int num3 = text3.IndexOf('_', num2);                     int num3 = text3.IndexOf('_', num2);
                    int num4 = ((i >= array.Length) ? text3.Length : array[i]);                     int num4 = ((i >= array.Length) ? text3.Length : array[i]);
                    if (num3 >= num4)                     if (num3 >= num4)
                    {                     {
                        ZLog.LogError("Failed to parse value " + text3 + "'s subkey as WorldModifiers and WorldModifierOption: separator index in wrong location!");                         ZLog.LogError("Failed to parse value " + text3 + "'s subkey as WorldModifiers and WorldModifierOption: separator index in wrong location!");
                    }                     }
                    if (num3 < 0)                     if (num3 < 0)
                    {                     {
                        string text5 = text3.Substring(num2, num4 - num2);                         string text5 = text3.Substring(num2, num4 - num2);
                        WorldPresets worldPresets;                         WorldPresets worldPresets;
                        if (!Enum.TryParse<WorldPresets>(text5, true, out worldPresets) || worldPresets.ToString().ToLower() != text5.ToLower())                         if (!Enum.TryParse<WorldPresets>(text5, true, out worldPresets) || worldPresets.ToString().ToLower() != text5.ToLower())
                        {                         {
                            ZLog.LogError(string.Concat(new string[] { "Failed to parse value ", text3, "'s subvalue ", text5, " as WorldPresets: Value enum couldn't be parsed!" }));                             ZLog.LogError(string.Concat(new string[] { "Failed to parse value ", text3, "'s subvalue ", text5, " as WorldPresets: Value enum couldn't be parsed!" }));
                            return false;                             return false;
                        }                         }
                        string text6 = text4;                         string text6 = text4;
                        num5 = (int)worldPresets;                         num5 = (int)worldPresets;
                        text4 = text6 + num5.ToString();                         text4 = text6 + num5.ToString();
                    }                     }
                    else                     else
                    {                     {
                        string text7 = text3.Substring(num2, num3 - num2);                         string text7 = text3.Substring(num2, num3 - num2);
                        string text8 = text3.Substring(num3 + 1, num4 - (num3 + 1));                         string text8 = text3.Substring(num3 + 1, num4 - (num3 + 1));
                        WorldModifiers worldModifiers;                         WorldModifiers worldModifiers;
                        if (!Enum.TryParse<WorldModifiers>(text7, true, out worldModifiers) || worldModifiers.ToString().ToLower() != text7.ToLower())                         if (!Enum.TryParse<WorldModifiers>(text7, true, out worldModifiers) || worldModifiers.ToString().ToLower() != text7.ToLower())
                        {                         {
                            ZLog.LogError(string.Concat(new string[] { "Failed to parse value ", text3, "'s subkey ", text7, " as WorldModifiers: Key enum couldn't be parsed!" }));                             ZLog.LogError(string.Concat(new string[] { "Failed to parse value ", text3, "'s subkey ", text7, " as WorldModifiers: Key enum couldn't be parsed!" }));
                            return false;                             return false;
                        }                         }
                        WorldModifierOption worldModifierOption;                         WorldModifierOption worldModifierOption;
                        if (!Enum.TryParse<WorldModifierOption>(text8, true, out worldModifierOption) || worldModifierOption.ToString().ToLower() != text8.ToLower())                         if (!Enum.TryParse<WorldModifierOption>(text8, true, out worldModifierOption) || worldModifierOption.ToString().ToLower() != text8.ToLower())
                        {                         {
                            ZLog.LogError(string.Concat(new string[] { "Failed to parse value ", text3, "'s subvalue ", text8, " as WorldModifierOption: Value enum couldn't be parsed!" }));                             ZLog.LogError(string.Concat(new string[] { "Failed to parse value ", text3, "'s subvalue ", text8, " as WorldModifierOption: Value enum couldn't be parsed!" }));
                            return false;                             return false;
                        }                         }
                        string text9 = text4;                         string text9 = text4;
                        num5 = (int)worldModifiers;                         num5 = (int)worldModifiers;
                        string text10 = num5.ToString();                         string text10 = num5.ToString();
                        string text11 = "_";                         string text11 = "_";
                        num5 = (int)worldModifierOption;                         num5 = (int)worldModifierOption;
                        text4 = text9 + text10 + text11 + num5.ToString();                         text4 = text9 + text10 + text11 + num5.ToString();
                    }                     }
                }                 }
                text3 = text4;                 text3 = text4;
            }             }
            num5 = (int)globalKeys;             num5 = (int)globalKeys;
            result[num5.ToString()] = text3;             result[num5.ToString()] = text3;
        }         }
        return true;         return true;
    }     }
   
    public static bool TryConvertCompactKVPToModifierKeys<T>(IDictionary<string, string> kvps, out T result) where T : ICollection<string>, new()     public static bool TryConvertCompactKVPToModifierKeys<T>(IDictionary<string, string> kvps, out T result) where T : ICollection<string>, new()
    {     {
        GlobalKeys[] array = new GlobalKeys[kvps.Count];         GlobalKeys[] array = new GlobalKeys[kvps.Count];
        string[] array2 = new string[kvps.Count];         string[] array2 = new string[kvps.Count];
        int num = 0;         int num = 0;
        result = new T();         result = new T();
        foreach (KeyValuePair<string, string> keyValuePair in kvps)         foreach (KeyValuePair<string, string> keyValuePair in kvps)
        {         {
            int num2;             int num2;
            if (!int.TryParse(keyValuePair.Key, out num2))             if (!int.TryParse(keyValuePair.Key, out num2))
            {             {
                ZLog.LogError(string.Concat(new string[] { "Failed to parse key ", keyValuePair.Key, " as GlobalKeys: ", keyValuePair.Key, " could not be parsed as an integer!" }));                 ZLog.LogError(string.Concat(new string[] { "Failed to parse key ", keyValuePair.Key, " as GlobalKeys: ", keyValuePair.Key, " could not be parsed as an integer!" }));
                return false;                 return false;
            }             }
            if (!Enum.IsDefined(typeof(GlobalKeys), num2))             if (!Enum.IsDefined(typeof(GlobalKeys), num2))
            {             {
                ZLog.LogError(string.Format("Failed to parse key {0} as {1}: {2} is out of range!", keyValuePair.Key, "GlobalKeys", num2));                 ZLog.LogError(string.Format("Failed to parse key {0} as {1}: {2} is out of range!", keyValuePair.Key, "GlobalKeys", num2));
            }             }
            array[num] = (GlobalKeys)num2;             array[num] = (GlobalKeys)num2;
            array2[num] = keyValuePair.Value;             array2[num] = keyValuePair.Value;
            num++;             num++;
        }         }
        for (int i = 0; i < array.Length; i++)         for (int i = 0; i < array.Length; i++)
        {         {
            GlobalKeys globalKeys = array[i];             GlobalKeys globalKeys = array[i];
            string text = array2[i];             string text = array2[i];
            if (string.IsNullOrEmpty(text))             if (string.IsNullOrEmpty(text))
            {             {
                result.Add(globalKeys.ToString());                 result.Add(globalKeys.ToString());
            }             }
            else             else
            {             {
                if (globalKeys == GlobalKeys.Preset)                 if (globalKeys == GlobalKeys.Preset)
                {                 {
                    string text2 = "";                     string text2 = "";
                    int[] array3 = array2[i].AllIndicesOf(':');                     int[] array3 = array2[i].AllIndicesOf(':');
                    for (int j = 0; j < array3.Length + 1; j++)                     for (int j = 0; j < array3.Length + 1; j++)
                    {                     {
                        int num3;                         int num3;
                        if (j > 0)                         if (j > 0)
                        {                         {
                            text2 += ":";                             text2 += ":";
                            num3 = array3[j - 1] + 1;                             num3 = array3[j - 1] + 1;
                        }                         }
                        else                         else
                        {                         {
                            num3 = 0;                             num3 = 0;
                        }                         }
                        int num4 = text.IndexOf('_', num3);                         int num4 = text.IndexOf('_', num3);
                        int num5 = ((j >= array3.Length) ? text.Length : array3[j]);                         int num5 = ((j >= array3.Length) ? text.Length : array3[j]);
                        if (num4 >= num5)                         if (num4 >= num5)
                        {                         {
                            ZLog.LogError("Failed to parse value " + text + "'s subkey as WorldModifiers and WorldModifierOption: separator index in wrong location!");                             ZLog.LogError("Failed to parse value " + text + "'s subkey as WorldModifiers and WorldModifierOption: separator index in wrong location!");
                        }                         }
                        if (num4 < 0)                         if (num4 < 0)
                        {                         {
                            string text3 = text.Substring(num3, num5 - num3);                             string text3 = text.Substring(num3, num5 - num3);
                            int num6;                             int num6;
                            if (!int.TryParse(text3, out num6))                             if (!int.TryParse(text3, out num6))
                            {                             {
                                ZLog.LogError(string.Concat(new string[] { "Failed to parse value ", text3, " as WorldPresets: ", text3, " could not be parsed as an integer!" }));                                 ZLog.LogError(string.Concat(new string[] { "Failed to parse value ", text3, " as WorldPresets: ", text3, " could not be parsed as an integer!" }));
                                return false;                                 return false;
                            }                             }
                            if (!Enum.IsDefined(typeof(WorldPresets), num6))                             if (!Enum.IsDefined(typeof(WorldPresets), num6))
                            {                             {
                                ZLog.LogError(string.Format("Failed to parse value {0} as {1}: {2} is out of range!", text3, "WorldPresets", num6));                                 ZLog.LogError(string.Format("Failed to parse value {0} as {1}: {2} is out of range!", text3, "WorldPresets", num6));
                            }                             }
                            string text4 = text2;                             string text4 = text2;
                            WorldPresets worldPresets = (WorldPresets)num6;                             WorldPresets worldPresets = (WorldPresets)num6;
                            text2 = text4 + worldPresets.ToString();                             text2 = text4 + worldPresets.ToString();
                        }                         }
                        else                         else
                        {                         {
                            string text5 = text.Substring(num3, num4 - num3);                             string text5 = text.Substring(num3, num4 - num3);
                            string text6 = text.Substring(num4 + 1, num5 - (num4 + 1));                             string text6 = text.Substring(num4 + 1, num5 - (num4 + 1));
                            int num7;                             int num7;
                            if (!int.TryParse(text5, out num7))                             if (!int.TryParse(text5, out num7))
                            {                             {
                                ZLog.LogError(string.Concat(new string[] { "Failed to parse value ", text5, " as WorldModifiers: ", text5, " could not be parsed as an integer!" }));                                 ZLog.LogError(string.Concat(new string[] { "Failed to parse value ", text5, " as WorldModifiers: ", text5, " could not be parsed as an integer!" }));
                                return false;                                 return false;
                            }                             }
                            if (!Enum.IsDefined(typeof(WorldModifiers), num7))                             if (!Enum.IsDefined(typeof(WorldModifiers), num7))
                            {                             {
                                ZLog.LogError(string.Format("Failed to parse value {0} as {1}: {2} is out of range!", text5, "WorldModifiers", num7));                                 ZLog.LogError(string.Format("Failed to parse value {0} as {1}: {2} is out of range!", text5, "WorldModifiers", num7));
                            }                             }
                            int num8;                             int num8;
                            if (!int.TryParse(text6, out num8))                             if (!int.TryParse(text6, out num8))
                            {                             {
                                ZLog.LogError(string.Concat(new string[] { "Failed to parse value ", text6, " as WorldModifierOption: ", text6, " could not be parsed as an integer!" }));                                 ZLog.LogError(string.Concat(new string[] { "Failed to parse value ", text6, " as WorldModifierOption: ", text6, " could not be parsed as an integer!" }));
                                return false;                                 return false;
                            }                             }
                            if (!Enum.IsDefined(typeof(WorldModifierOption), num8))                             if (!Enum.IsDefined(typeof(WorldModifierOption), num8))
                            {                             {
                                ZLog.LogError(string.Format("Failed to parse value {0} as {1}: {2} is out of range!", text6, "WorldModifierOption", num8));                                 ZLog.LogError(string.Format("Failed to parse value {0} as {1}: {2} is out of range!", text6, "WorldModifierOption", num8));
                            }                             }
                            string text7 = text2;                             string text7 = text2;
                            WorldModifiers worldModifiers = (WorldModifiers)num7;                             WorldModifiers worldModifiers = (WorldModifiers)num7;
                            string text8 = worldModifiers.ToString();                             string text8 = worldModifiers.ToString();
                            string text9 = "_";                             string text9 = "_";
                            WorldModifierOption worldModifierOption = (WorldModifierOption)num8;                             WorldModifierOption worldModifierOption = (WorldModifierOption)num8;
                            text2 = text7 + text8 + text9 + worldModifierOption.ToString();                             text2 = text7 + text8 + text9 + worldModifierOption.ToString();
                        }                         }
                    }                     }
                    text = text2;                     text = text2;
                }                 }
                result.Add(array[i].ToString() + " " + text);                 result.Add(array[i].ToString() + " " + text);
            }             }
        }         }
        return true;         return true;
    }     }
   
    private static bool TryMatch(List<string> keys, List<string> others)     private static bool TryMatch(List<string> keys, List<string> others)
    {     {
        if (others.Count != keys.Count)         if (others.Count != keys.Count)
        {         {
            return false;             return false;
        }         }
        for (int i = 0; i < keys.Count; i++)         for (int i = 0; i < keys.Count; i++)
        {         {
            keys[i] = keys[i].ToLower();             keys[i] = keys[i].ToLower();
        }         }
        for (int j = 0; j < others.Count; j++)         for (int j = 0; j < others.Count; j++)
        {         {
            if (!keys.Contains(others[j].ToLower()))             if (!keys.Contains(others[j].ToLower()))
            {             {
                return false;                 return false;
            }             }
        }         }
        return true;         return true;
    }     }
   
    private static List<string> m_tempKeys = new List<string>();     private static List<string> m_tempKeys = new List<string>();
   
    public static ServerOptionsGUI m_instance;     public static ServerOptionsGUI m_instance;
   
    public RectTransform m_toolTipPanel;     public RectTransform m_toolTipPanel;
   
    public TMP_Text m_toolTipText;     public TMP_Text m_toolTipText;
   
    public GameObject m_modifiersRoot;     public GameObject m_modifiersRoot;
   
    public GameObject m_presetsRoot;     public GameObject m_presetsRoot;
   
    public GameObject m_doneButton;     public GameObject m_doneButton;
   
    private WorldPresets m_preset;     private WorldPresets m_preset;
   
    private static KeyUI[] m_modifiers;     private static KeyUI[] m_modifiers;
   
    private static KeyButton[] m_presets;     private static KeyButton[] m_presets;
   
    private static Dictionary<WorldModifiers, List<WorldModifierOption>> m_modifierSetups = new Dictionary<WorldModifiers, List<WorldModifierOption>>();     private static Dictionary<WorldModifiers, List<WorldModifierOption>> m_modifierSetups = new Dictionary<WorldModifiers, List<WorldModifierOption>>();
} }