Decompiled source of Gentlemens Mod Manager v3.1.0
ModManager/ModManager.dll
Decompiled a month ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Text; using AGD.ModAPI; using AGD.Modding; using AGDKit; using Character; using Core; using DisputeLib; using FMOD; using FMOD.Studio; using FMODUnity; using FishNet; using FishNet.Managing; using FishNet.Object; using Game; using HeldItems; using Items; using Menus; using Newtonsoft.Json.Linq; using Player; using Steamworks; using TMPro; using UI.Menu; using UnityEngine; using UnityEngine.Animations; using UnityEngine.EventSystems; using UnityEngine.Events; using UnityEngine.InputSystem; using UnityEngine.InputSystem.Controls; using UnityEngine.Playables; using UnityEngine.Rendering; using UnityEngine.SceneManagement; using UnityEngine.UI; using Util; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyVersion("0.0.0.0")] namespace ModManager { internal static class FriendPicker { private class Friend { public string Name; public ulong Id; public Image Face; public TextMeshProUGUI Label; } private static List<Friend> _friends; private static TextMeshProUGUI _current; private static GameObject _clear; private static RectTransform _list; public static bool Wanted(string rootPath) { try { return File.Exists(Path.Combine(Path.Combine(rootPath, "assets"), "friend-picker.txt")); } catch (Exception) { return false; } } private static string FileOf(string modId) { return Path.Combine(Path.Combine(Path.Combine(Application.persistentDataPath, "ModData"), modId), "target.json"); } private static string Current(string modId, out ulong id) { id = 0uL; try { string path = FileOf(modId); if (!File.Exists(path)) { return ""; } string json = File.ReadAllText(path); ulong.TryParse(Field(json, "steamId"), out id); return Field(json, "name"); } catch (Exception) { return ""; } } private static string Field(string json, string key) { int num = json.IndexOf("\"" + key + "\"", StringComparison.Ordinal); if (num < 0) { return ""; } num = json.IndexOf(':', num); if (num < 0) { return ""; } int num2 = json.IndexOf('"', num); if (num2 < 0) { return ""; } int num3 = json.IndexOf('"', num2 + 1); if (num3 < 0) { return ""; } return json.Substring(num2 + 1, num3 - num2 - 1); } private static void Save(string modId, Friend f) { try { string path = FileOf(modId); Directory.CreateDirectory(Path.GetDirectoryName(path)); if (f == null) { if (File.Exists(path)) { File.Delete(path); } return; } string text = f.Name.Replace("\\", "").Replace("\"", ""); File.WriteAllText(path, "{\"steamId\":\"" + f.Id + "\",\"name\":\"" + text + "\"}"); } catch (Exception ex) { Kit.Warn("friend picker: " + ex.Message); } } private static void Load() { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) _friends = new List<Friend>(); try { int friendCount = SteamFriends.GetFriendCount((EFriendFlags)4); for (int i = 0; i < friendCount; i++) { CSteamID friendByIndex = SteamFriends.GetFriendByIndex(i, (EFriendFlags)4); _friends.Add(new Friend { Id = friendByIndex.m_SteamID, Name = SteamFriends.GetFriendPersonaName(friendByIndex) }); } _friends.Sort((Friend a, Friend b) => string.Compare(a.Name, b.Name, StringComparison.OrdinalIgnoreCase)); } catch (Exception ex) { Kit.Warn("friend picker: steam friends unavailable: " + ex.Message); } } public static void Build(RectTransform parent, string modId) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Unknown result type (might be due to invalid IL or missing references) //IL_01a8: Unknown result type (might be due to invalid IL or missing references) //IL_01a9: Unknown result type (might be due to invalid IL or missing references) //IL_01bf: Unknown result type (might be due to invalid IL or missing references) //IL_01ce: Expected O, but got Unknown //IL_01d4: Unknown result type (might be due to invalid IL or missing references) //IL_01d5: Unknown result type (might be due to invalid IL or missing references) //IL_01eb: Unknown result type (might be due to invalid IL or missing references) //IL_01fa: Expected O, but got Unknown //IL_0225: Unknown result type (might be due to invalid IL or missing references) //IL_022f: Expected O, but got Unknown Ui.Size(((Component)Ui.Text((Transform)(object)parent, "TARGET", 28f, Ui.Gold, (TextAlignmentOptions)513)).gameObject, -1f, 44f); string selfFlag = Path.Combine(Path.GetDirectoryName(FileOf(modId)), "self.flag"); RectTransform obj = Ui.Node("Self", (Transform)(object)parent); ((HorizontalOrVerticalLayoutGroup)Ui.HGroup(((Component)obj).gameObject, 16f, null, (TextAnchor)3)).childForceExpandHeight = false; Ui.Size(((Component)obj).gameObject, -1f, 56f); Ui.Checkbox((Transform)(object)obj, File.Exists(selfFlag), delegate(bool want) { try { Directory.CreateDirectory(Path.GetDirectoryName(selfFlag)); if (want) { File.WriteAllText(selfFlag, "1"); } else { File.Delete(selfFlag); } } catch (Exception ex) { Kit.Warn("friend picker: " + ex.Message); } }, out var _, 48f); Ui.Text((Transform)(object)obj, "Target myself (solo testing)", 27f, Ui.Dark, (TextAlignmentOptions)513); _current = Ui.Text((Transform)(object)parent, "", 27f, Ui.Dark, (TextAlignmentOptions)513); Ui.Size(((Component)_current).gameObject, -1f, 38f); RectTransform obj2 = Ui.Node("Buttons", (Transform)(object)parent); ((HorizontalOrVerticalLayoutGroup)Ui.HGroup(((Component)obj2).gameObject, 12f, null, (TextAnchor)3)).childForceExpandHeight = false; Ui.Size(((Component)obj2).gameObject, -1f, 66f); Color bg = default(Color); ((Color)(ref bg))..ctor(0.965f, 0.961f, 0.973f); Ui.Pill((Transform)(object)obj2, "REFRESH", bg, Ui.Dark, 220f, 60f, (UnityAction)delegate { Load(); Fill(parent, modId, null); }, 27f); _clear = ((Component)((Component)Ui.Pill((Transform)(object)obj2, "CLEAR", bg, Ui.Dark, 190f, 60f, (UnityAction)delegate { Save(modId, null); Recolor(modId); }, 27f)).transform.parent).gameObject; ScrollRect sr; RectTransform list = Ui.Scroll((Transform)(object)parent, "Friends", out sr, 8f, new RectOffset(6, 6, 6, 10)); Ui.Size(((Component)sr).gameObject, -1f, 330f); if (_friends == null) { Load(); } Fill(parent, modId, list); } private static void Fill(RectTransform parent, string modId, RectTransform list) { //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Expected O, but got Unknown //IL_00de: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)list != (Object)null) { _list = list; } if ((Object)(object)_list == (Object)null) { return; } Ui.Clear((Transform)(object)_list); foreach (Friend friend in _friends) { Friend fr = friend; Image val = Ui.Card((Transform)(object)_list, "Friend", Ui.RowBg); Ui.Size(((Component)((Transform)((Graphic)val).rectTransform).parent).gameObject, -1f, 58f); Button obj = ((Component)val).gameObject.AddComponent<Button>(); ((Selectable)obj).targetGraphic = (Graphic)(object)val; ((UnityEvent)obj.onClick).AddListener((UnityAction)delegate { Save(modId, fr); Recolor(modId); }); TextMeshProUGUI val2 = Ui.Text((Transform)(object)((Graphic)val).rectTransform, friend.Name, 27f, Ui.Dark, (TextAlignmentOptions)513); Ui.Stretch(((TMP_Text)val2).rectTransform, 18f, 0f, 18f); friend.Face = val; friend.Label = val2; } Recolor(modId); } private static void Recolor(string modId) { //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) ulong id; string text = Current(modId, out id); if ((Object)(object)_current != (Object)null) { ((TMP_Text)_current).text = ((id == 0L) ? "Nobody picked." : ("Target: " + text)); } if ((Object)(object)_clear != (Object)null) { _clear.SetActive(id != 0); } if (_friends == null) { return; } foreach (Friend friend in _friends) { if (!((Object)(object)friend.Face == (Object)null)) { bool flag = friend.Id == id && id != 0; ((Graphic)friend.Face).color = (flag ? Ui.Red : Ui.RowBg); ((Graphic)friend.Label).color = (flag ? Ui.RedText : Ui.Dark); } } } } internal static class GameMenu { private const string PillName = "ModManager Settings"; private const string OverlayName = "ModManager Settings Overlay"; private const float PillW = 150f; private const float PillH = 46f; private const float VersionLeft = 214f; private static GameObject _overlay; private static SettingsPage _page; private static readonly HashSet<int> _seen = new HashSet<int>(); private static float _next; private static GameObject _returnTo; private static CanvasGroup _menuGroup; private static bool _unsubscribed; public static SettingsPage Page => _page; public static bool IsOpen { get { if ((Object)(object)_overlay != (Object)null) { return _overlay.activeSelf; } return false; } } public static void Tick() { WorkshopMenuUI instance = WorkshopMenuUI.Instance; if ((Object)(object)instance == (Object)null) { return; } if (!instance.IsOpen) { if (IsOpen) { Close(); } return; } if (!IsOpen) { Gamepad current = Gamepad.current; if (current != null && current.buttonNorth.wasPressedThisFrame) { OpenSelected(instance); } } float realtimeSinceStartup = Time.realtimeSinceStartup; if (!(realtimeSinceStartup < _next)) { _next = realtimeSinceStartup + 0.2f; Inject(instance); } } private static string SettingsIdOf(ModsMenuRow row) { DiscoveredMod mod = row.Mod; if (mod == null || string.IsNullOrEmpty(mod.ModId)) { return null; } if (!(mod.ModId == Kit.ModId)) { return mod.ModId; } return "base-game"; } private static void Inject(WorkshopMenuUI wm) { if (!EnsureOverlay(wm)) { return; } ModsMenuRow[] componentsInChildren = ((Component)wm).GetComponentsInChildren<ModsMenuRow>(false); foreach (ModsMenuRow val in componentsInChildren) { int instanceID = ((Object)val).GetInstanceID(); if (_seen.Contains(instanceID)) { continue; } string text = SettingsIdOf(val); if (text != null && _page.HasSettings(text)) { _seen.Add(instanceID); if ((Object)(object)((Component)val).transform.Find("ModManager Settings") == (Object)null) { AddPill(val, text); } } } } private static void AddPill(ModsMenuRow row, string id) { //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Expected O, but got Unknown //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Expected O, but got Unknown //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_0127: Unknown result type (might be due to invalid IL or missing references) //IL_012c: Unknown result type (might be due to invalid IL or missing references) //IL_013f: Unknown result type (might be due to invalid IL or missing references) string target = id; Button obj = Ui.Pill(((Component)row).transform, (id == "base-game") ? "BASE GAME" : "SETTINGS", Ui.Dark, Ui.HeaderText, 150f, 46f, (UnityAction)delegate { Open(target); }, 22f); RectTransform val = (RectTransform)((Component)obj).transform.parent; ((Object)val).name = "ModManager Settings"; TMP_Text componentInChildren = ((Component)obj).GetComponentInChildren<TMP_Text>(); if ((Object)(object)componentInChildren != (Object)null) { componentInChildren.enableAutoSizing = true; componentInChildren.fontSizeMin = 14f; componentInChildren.fontSizeMax = 22f; } Ui.Anchor(val, new Vector2(1f, 0.5f), new Vector2(1f, 0.5f), new Vector2(1f, 0.5f), new Vector2(-222f, 0f), new Vector2(150f, 46f)); Navigation navigation = default(Navigation); ((Navigation)(ref navigation)).mode = (Mode)0; ((Selectable)obj).navigation = navigation; Transform obj2 = ((Component)row).transform.Find("Name"); RectTransform val2 = (RectTransform)(object)((obj2 is RectTransform) ? obj2 : null); if ((Object)(object)val2 != (Object)null) { Vector2 sizeDelta = val2.sizeDelta; sizeDelta.x -= 162f; val2.sizeDelta = sizeDelta; TMP_Text component = ((Component)val2).GetComponent<TMP_Text>(); if ((Object)(object)component != (Object)null) { component.fontSizeMax = component.fontSize; component.fontSizeMin = Mathf.Min(22f, component.fontSize); component.enableAutoSizing = true; } } } private static void OpenSelected(WorkshopMenuUI wm) { EventSystem current = EventSystem.current; GameObject val = (((Object)(object)current != (Object)null) ? current.currentSelectedGameObject : null); ModsMenuRow val2 = (((Object)(object)val != (Object)null) ? val.GetComponentInParent<ModsMenuRow>() : null); if (!((Object)(object)val2 == (Object)null) && !((Object)(object)((Component)val2).transform.Find("ModManager Settings") == (Object)null)) { string text = SettingsIdOf(val2); if (text != null) { Open(text); } } } private static bool EnsureOverlay(WorkshopMenuUI wm) { //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_0102: Unknown result type (might be due to invalid IL or missing references) //IL_0132: Expected O, but got Unknown if ((Object)(object)_overlay != (Object)null) { return true; } if (!Ui.Init()) { return false; } GameObject val = new GameObject("ModManager Settings Overlay", new Type[1] { typeof(RectTransform) }) { layer = 5 }; val.SetActive(false); val.transform.SetParent(Kit.Host.transform, false); Canvas component = ((Component)wm).GetComponent<Canvas>(); Canvas obj = val.AddComponent<Canvas>(); obj.renderMode = (RenderMode)0; obj.overrideSorting = true; obj.sortingOrder = (((Object)(object)component != (Object)null) ? component.sortingOrder : 0) + 10; CanvasScaler obj2 = val.AddComponent<CanvasScaler>(); CanvasScaler component2 = ((Component)wm).GetComponent<CanvasScaler>(); obj2.uiScaleMode = (ScaleMode)1; obj2.referenceResolution = (Vector2)(((Object)(object)component2 != (Object)null) ? component2.referenceResolution : new Vector2(1920f, 1080f)); obj2.screenMatchMode = (ScreenMatchMode)(((Object)(object)component2 != (Object)null) ? ((int)component2.screenMatchMode) : 0); obj2.matchWidthOrHeight = (((Object)(object)component2 != (Object)null) ? component2.matchWidthOrHeight : 0.5f); val.AddComponent<GraphicRaycaster>(); _page = val.AddComponent<SettingsPage>(); _page.Build(); _page.Closed = Close; _overlay = val; return true; } public static void Open(string id) { WorkshopMenuUI instance = WorkshopMenuUI.Instance; if ((Object)(object)instance == (Object)null || !EnsureOverlay(instance)) { return; } EventSystem current = EventSystem.current; if (!IsOpen) { _returnTo = (((Object)(object)current != (Object)null) ? current.currentSelectedGameObject : null); try { Reflect.Call(instance, "Unsubscribe"); _unsubscribed = true; } catch (Exception ex) { Kit.Warn("mods menu input: " + ex.Message); } _menuGroup = ((Component)instance).GetComponent<CanvasGroup>(); if ((Object)(object)_menuGroup != (Object)null) { _menuGroup.interactable = false; } _overlay.SetActive(true); } _page.Show(id, 0); if ((Object)(object)current != (Object)null && (Object)(object)_page.DefaultSelectable != (Object)null) { current.SetSelectedGameObject(((Component)_page.DefaultSelectable).gameObject); } } public static void Close() { if (!IsOpen) { return; } _overlay.SetActive(false); Options.Save(); WorkshopMenuUI instance = WorkshopMenuUI.Instance; bool flag = (Object)(object)instance != (Object)null && instance.IsOpen; if ((Object)(object)_menuGroup != (Object)null && flag) { _menuGroup.interactable = true; } _menuGroup = null; if (_unsubscribed && flag) { try { Reflect.Call(instance, "Subscribe"); } catch (Exception ex) { Kit.Warn("mods menu input: " + ex.Message); } } _unsubscribed = false; EventSystem current = EventSystem.current; if ((Object)(object)current != (Object)null && (Object)(object)_returnTo != (Object)null) { current.SetSelectedGameObject(_returnTo); } _returnTo = null; } public static void Uninstall() { //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) Close(); if ((Object)(object)_overlay != (Object)null) { Object.Destroy((Object)(object)_overlay); } _overlay = null; _page = null; _seen.Clear(); WorkshopMenuUI instance = WorkshopMenuUI.Instance; if ((Object)(object)instance == (Object)null) { return; } ModsMenuRow[] componentsInChildren = ((Component)instance).GetComponentsInChildren<ModsMenuRow>(true); foreach (ModsMenuRow val in componentsInChildren) { Transform val2 = ((Component)val).transform.Find("ModManager Settings"); if (!((Object)(object)val2 == (Object)null)) { val2.SetParent((Transform)null, false); Object.Destroy((Object)(object)((Component)val2).gameObject); Transform obj = ((Component)val).transform.Find("Name"); RectTransform val3 = (RectTransform)(object)((obj is RectTransform) ? obj : null); if ((Object)(object)val3 != (Object)null) { Vector2 sizeDelta = val3.sizeDelta; sizeDelta.x += 162f; val3.sizeDelta = sizeDelta; } } } } } internal enum OptKind { Number, Toggle, Choice } internal class OptionDef { public string ModId; public string Id; public string Label; public string Info; public string Group; public OptKind Kind; public double Min; public double Max = 1.0; public double Step; public double Default; public bool DefaultOn; public string[] Choices = new string[0]; public int DefaultIndex; public bool Host = true; public string Item; public string Field; public bool Multiply; public string Prefix = ""; public string Suffix = ""; public string GroupNote; public RarityKind Rarity; public Sprite Icon; private string _key; public string Key => _key ?? (_key = ModId + "." + Id); public string DefaultText { get { if (Kind == OptKind.Toggle) { if (!DefaultOn) { return "false"; } return "true"; } if (Kind == OptKind.Choice) { if (Choices.Length == 0) { return ""; } return Choices[Math.Min(DefaultIndex, Choices.Length - 1)]; } return Fmt(Default); } } public static string Fmt(double v) { return v.ToString("0.####", CultureInfo.InvariantCulture); } } internal static class Options { private static readonly List<OptionDef> _defs = new List<OptionDef>(); private static readonly Dictionary<string, string> _local = new Dictionary<string, string>(StringComparer.Ordinal); private static Dictionary<string, string> _remote; private static readonly Dictionary<string, string> _effective = new Dictionary<string, string>(StringComparer.Ordinal); private static int _version; private static bool _loaded; private static bool _dirty; private static float _saveAt; public static bool Dry; public static List<OptionDef> Defs => _defs; public static bool FromHost => _remote != null; public static int Version => _version; private static string FilePath => Path.Combine(Kit.DataDir, "options.json"); public static IEnumerable<OptionDef> For(string modId) { return _defs.Where((OptionDef d) => d.ModId == modId); } public static void Load() { //IL_018f: Unknown result type (might be due to invalid IL or missing references) //IL_0196: Invalid comparison between Unknown and I4 _defs.Clear(); foreach (DiscoveredMod m in LocalModProvider.Mods ?? new List<DiscoveredMod>()) { if (m == null || string.IsNullOrEmpty(m.ModId) || !m.IsValid || !m.IsEnabled) { continue; } string text = Path.Combine(m.RootPath, "options.json"); bool rarity = true; if (File.Exists(text)) { try { ParseFile(m.ModId, text, out rarity); } catch (Exception ex) { Kit.Warn("options.json of " + m.ModId + ": " + ex.Message); } } if (rarity) { Kit.Try("rarity of " + m.ModId, delegate { Rarity.AddFor(m.ModId, _defs); }); } } Kit.Try("rarity of the base game", delegate { Rarity.AddBase(_defs); }); _local.Clear(); try { if (File.Exists(FilePath)) { foreach (JProperty item in JObject.Parse(File.ReadAllText(FilePath)).Properties()) { _local[item.Name] = (((int)item.Value.Type == 9) ? (((bool)item.Value) ? "true" : "false") : Convert.ToString(item.Value, CultureInfo.InvariantCulture)); } } } catch (Exception ex2) { Kit.Warn("saved options unreadable, using defaults: " + ex2.Message); } _loaded = true; Publish(all: true); Kit.Log(_defs.Count + " option(s) from " + _defs.Select((OptionDef d) => d.ModId).Distinct().Count() + " mod(s)"); } private static void ParseFile(string modId, string file, out bool rarity) { JObject val = JObject.Parse(File.ReadAllText(file)); rarity = val["rarity"] == null || (bool)val["rarity"]; JToken obj = val["options"]; JArray val2 = (JArray)(object)((obj is JArray) ? obj : null); if (val2 == null) { return; } foreach (JObject item in ((IEnumerable)val2).OfType<JObject>()) { OptionDef d = new OptionDef { ModId = modId }; d.Id = (string)item["id"]; if (string.IsNullOrEmpty(d.Id) || _defs.Any((OptionDef x) => x.Key == modId + "." + d.Id)) { Kit.Warn(modId + ": option without a unique id skipped"); continue; } d.Label = ((string)item["label"]) ?? d.Id; d.Info = (string)item["info"]; d.Group = ((string)item["group"]) ?? ""; d.Suffix = ((string)item["unit"]) ?? ""; d.Host = (((string)item["scope"]) ?? "game") != "local"; switch ((((string)item["type"]) ?? "number").ToLowerInvariant()) { case "toggle": case "bool": d.Kind = OptKind.Toggle; d.DefaultOn = item["default"] != null && (bool)item["default"]; break; case "choice": { d.Kind = OptKind.Choice; JToken obj2 = item["choices"]; JArray val3 = (JArray)(object)((obj2 is JArray) ? obj2 : null); d.Choices = ((val3 != null) ? ((IEnumerable<JToken>)val3).Select((JToken c) => (string)c).ToArray() : new string[0]); if (d.Choices.Length == 0) { Kit.Warn(modId + "." + d.Id + ": choice without choices skipped"); continue; } string value = (string)item["default"]; d.DefaultIndex = Math.Max(0, Array.IndexOf(d.Choices, value)); break; } default: d.Kind = OptKind.Number; d.Min = ((item["min"] != null) ? ((double)item["min"]) : 0.0); d.Max = ((item["max"] != null) ? ((double)item["max"]) : 1.0); d.Step = ((item["step"] != null) ? ((double)item["step"]) : 0.0); d.Default = ((item["default"] != null) ? ((double)item["default"]) : d.Min); break; } string text = (string)item["set"]; if (!string.IsNullOrEmpty(text)) { d.Item = (string)item["item"]; d.Field = text; d.Multiply = (((string)item["mode"]) ?? "set").ToLowerInvariant() == "multiply"; if (string.IsNullOrEmpty(d.Item) || text.IndexOf('.') < 1 || d.Kind == OptKind.Choice) { Kit.Warn(modId + "." + d.Id + ": a stat hook needs \"item\", \"set\":\"Component.field\" and a number or toggle"); d.Item = null; d.Field = null; } } _defs.Add(d); } } public static string Own(OptionDef d) { if (!_local.TryGetValue(d.Key, out var value)) { return d.DefaultText; } return Clean(d, value); } public static string Effective(OptionDef d) { if (!_effective.TryGetValue(d.Key, out var value)) { return d.DefaultText; } return value; } public static bool IsDefault(OptionDef d) { return Own(d) == d.DefaultText; } private static string Clean(OptionDef d, string raw) { if (d.Kind == OptKind.Toggle) { if (!(raw == "true")) { return "false"; } return "true"; } if (d.Kind == OptKind.Choice) { if (!d.Choices.Contains(raw)) { return d.DefaultText; } return raw; } if (!double.TryParse(raw, NumberStyles.Float, CultureInfo.InvariantCulture, out var result)) { return d.DefaultText; } if (d.Step > 0.0) { result = d.Min + Math.Round((result - d.Min) / d.Step) * d.Step; } return OptionDef.Fmt(Math.Max(d.Min, Math.Min(d.Max, result))); } public static double Num(OptionDef d, bool effective = false) { if (!double.TryParse(effective ? Effective(d) : Own(d), NumberStyles.Float, CultureInfo.InvariantCulture, out var result)) { return d.Default; } return result; } public static void SetOwn(OptionDef d, string value) { value = Clean(d, value); if (value == d.DefaultText) { _local.Remove(d.Key); } else { _local[d.Key] = value; } _dirty = true; _saveAt = Time.realtimeSinceStartup + 0.6f; Publish(all: false); } public static void ResetMod(string modId) { foreach (OptionDef item in For(modId)) { if (!FromHost || !item.Host) { _local.Remove(item.Key); } } _dirty = true; _saveAt = Time.realtimeSinceStartup + 0.2f; Publish(all: false); } public static Dictionary<string, string> HostValues() { Dictionary<string, string> dictionary = new Dictionary<string, string>(StringComparer.Ordinal); foreach (OptionDef def in _defs) { if (def.Host) { string text = Own(def); if (text != def.DefaultText) { dictionary[def.Key] = text; } } } return dictionary; } public static void SetRemote(Dictionary<string, string> map) { if ((map != null || _remote != null) && (map == null || _remote == null || map.Count != _remote.Count || !map.All((KeyValuePair<string, string> kv) => _remote.TryGetValue(kv.Key, out var value) && value == kv.Value))) { _remote = map; Kit.Log((map == null) ? "left the host's lobby, using my own option values" : ("using the host's option values (" + map.Count + ")")); Publish(all: false); } } private static void Publish(bool all) { List<OptionDef> list = new List<OptionDef>(); foreach (OptionDef def in _defs) { string text = Own(def); if (def.Host && _remote != null) { text = (_remote.TryGetValue(def.Key, out var value) ? Clean(def, value) : def.DefaultText); } string value2; bool num = _effective.TryGetValue(def.Key, out value2); _effective[def.Key] = text; if (!num || value2 != text) { list.Add(def); } } if (_effective.Count > _defs.Count) { HashSet<string> live = new HashSet<string>(_defs.Select((OptionDef optionDef) => optionDef.Key), StringComparer.Ordinal); foreach (string item in _effective.Keys.Where((string k) => !live.Contains(k)).ToList()) { _effective.Remove(item); } } AppDomain.CurrentDomain.SetData("agd.options", _effective); if (list.Count > 0) { _version++; AppDomain.CurrentDomain.SetData("agd.options.v", _version); } foreach (OptionDef d in list) { if (d.Item != null && (!all || !(Effective(d) == d.DefaultText))) { Kit.Try("stat hook " + d.Key, delegate { StatHook.Apply(d, Effective(d)); }); } } } public static void Unload() { Kit.Try("stat hook restore", delegate { StatHook.RestoreAll(); }); if (_dirty) { Save(); } _effective.Clear(); _defs.Clear(); _remote = null; _loaded = false; AppDomain.CurrentDomain.SetData("agd.options", null); AppDomain.CurrentDomain.SetData("agd.options.v", null); } public static void Tick() { if (_dirty && Time.realtimeSinceStartup >= _saveAt) { Save(); } } public static void Save() { //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Expected O, but got Unknown _dirty = false; if (Dry || !_loaded) { return; } try { Directory.CreateDirectory(Path.GetDirectoryName(FilePath)); JObject val = new JObject(); foreach (KeyValuePair<string, string> item in _local.OrderBy<KeyValuePair<string, string>, string>((KeyValuePair<string, string> k) => k.Key, StringComparer.Ordinal)) { val[item.Key] = JToken.op_Implicit(item.Value); } File.WriteAllText(FilePath, ((object)val).ToString()); } catch (Exception ex) { Kit.Warn("could not save options: " + ex.Message); } } } internal static class StatHook { private class Captured { public object Target; public FieldInfo Field; public object Orig; } private static readonly Dictionary<string, Captured> _captured = new Dictionary<string, Captured>(); public static void Apply(OptionDef d, string value) { //IL_0220: Unknown result type (might be due to invalid IL or missing references) //IL_0225: Unknown result type (might be due to invalid IL or missing references) Item val = FindItem(d); if ((Object)(object)val == (Object)null) { Kit.Warn("option " + d.Key + ": item '" + d.Item + "' not found"); return; } int num = d.Field.IndexOf('.'); string comp = d.Field.Substring(0, num); string text = d.Field.Substring(num + 1); object v = ((d.Kind == OptKind.Toggle) ? ((object)(value == "true")) : ((object)double.Parse(value, CultureInfo.InvariantCulture))); if (comp == "Item") { Report(d, ((Object)val).name + ".Item." + text, Set(val, text, v, d.Multiply, double.NaN)); return; } if ((Object)(object)val.prefab == (Object)null) { Kit.Warn("option " + d.Key + ": " + ((Object)val).name + " has no prefab"); return; } Component val2 = ((IEnumerable<Component>)val.prefab.GetComponentsInChildren<Component>(true)).FirstOrDefault((Func<Component, bool>)((Component c) => (Object)(object)c != (Object)null && ((object)c).GetType().Name == comp)); if ((Object)(object)val2 == (Object)null) { Kit.Warn("option " + d.Key + ": " + ((Object)val).name + " has no component " + comp); return; } string text2 = Set(val2, text, v, d.Multiply, double.NaN); double baseValue = (d.Multiply ? OrigOf(val2, text) : double.NaN); int num2 = 0; foreach (Component item in Resources.FindObjectsOfTypeAll(((object)val2).GetType()).Cast<Component>()) { if (!((Object)(object)item == (Object)null) && !((Object)(object)item == (Object)(object)val2)) { Scene scene = item.gameObject.scene; if (((Scene)(ref scene)).IsValid() && IsInstanceOf(((Object)item.gameObject).name, ((Object)val.prefab).name)) { Set(item, text, v, d.Multiply, baseValue); num2++; } } } Report(d, ((Object)val).name + "." + comp + "." + text, text2 + ((num2 > 0) ? (" (+" + num2 + " live)") : "")); } private static void Report(OptionDef d, string target, string result) { string msg = "stat " + d.Key + " -> " + target + ": " + result; if (result.StartsWith("no field", StringComparison.Ordinal)) { Kit.Warn(msg); } else { Kit.Log(msg); } } private static Item FindItem(OptionDef d) { if ((Object)(object)Kit.Design == (Object)null) { return null; } if (d.ModId == "base-game") { return ((IEnumerable<Item>)Kit.Design.itemList).FirstOrDefault((Func<Item, bool>)((Item i) => (Object)(object)i != (Object)null && string.Equals(((Object)i).name, d.Item, StringComparison.Ordinal))); } string full = (d.Item.StartsWith(d.ModId + "_", StringComparison.OrdinalIgnoreCase) ? d.Item : (d.ModId + "_" + d.Item)); return ((IEnumerable<Item>)Kit.Design.itemList).FirstOrDefault((Func<Item, bool>)((Item i) => (Object)(object)i != (Object)null && string.Equals(((Object)i).name, full, StringComparison.OrdinalIgnoreCase))); } private static bool IsInstanceOf(string instance, string prefab) { if (!instance.StartsWith(prefab, StringComparison.Ordinal)) { return false; } if (instance.Length == prefab.Length) { return true; } char c = instance[prefab.Length]; if (c != '(') { return c == ' '; } return true; } private static FieldInfo FindField(object target, string field) { FieldInfo fieldInfo = null; Type type = target.GetType(); while (fieldInfo == null && type != null) { fieldInfo = type.GetField(field, BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); type = type.BaseType; } return fieldInfo; } private static string KeyOf(object target, FieldInfo f) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) return ((Object)target).GetInstanceID() + "." + f.Name; } private static double OrigOf(object target, string field) { FieldInfo fieldInfo = FindField(target, field); if (!(fieldInfo != null) || !_captured.TryGetValue(KeyOf(target, fieldInfo), out var value)) { return double.NaN; } return Convert.ToDouble(value.Orig, CultureInfo.InvariantCulture); } private static string Set(object target, string field, object v, bool multiply, double baseValue) { FieldInfo fieldInfo = FindField(target, field); if (fieldInfo == null) { return "no field " + target.GetType().Name + "." + field; } object value = fieldInfo.GetValue(target); string key = KeyOf(target, fieldInfo); if (!_captured.ContainsKey(key)) { _captured[key] = new Captured { Target = target, Field = fieldInfo, Orig = value }; } if (multiply) { v = (double.IsNaN(baseValue) ? Convert.ToDouble(_captured[key].Orig, CultureInfo.InvariantCulture) : baseValue) * Convert.ToDouble(v, CultureInfo.InvariantCulture); } object value2 = ((fieldInfo.FieldType == typeof(bool)) ? ((object)Convert.ToBoolean(v)) : Convert.ChangeType(v, fieldInfo.FieldType, CultureInfo.InvariantCulture)); fieldInfo.SetValue(target, value2); return value?.ToString() + " -> " + fieldInfo.GetValue(target); } public static void RestoreAll() { foreach (Captured value in _captured.Values) { object target = value.Target; if (!((Object)((target is Object) ? target : null) == (Object)null)) { value.Field.SetValue(value.Target, value.Orig); } } _captured.Clear(); } } internal static class OptionsNet { private const string Msg = "options"; private const int MaxBytes = 16000; private static bool _client; private static bool _tooBig; private static bool _registered; private static NetworkManager _nm; private static string _sent; private static int _clients = -1; private static float _next; private static float _resend; public static void Register() { _registered = Kit.Context.Network.RegisterClientHandler("options", (Action<ModReader>)ClientGot); if (!_registered) { Kit.Warn("options: could not register the 'options' message"); } } public static void Poll() { NetworkManager networkManager = InstanceFinder.NetworkManager; if ((Object)(object)networkManager != (Object)(object)_nm) { bool num = (Object)(object)_nm != (Object)null; Forget(); _nm = networkManager; if (num) { Options.SetRemote(null); } } if ((Object)(object)networkManager == (Object)null) { return; } if (!networkManager.IsClientStarted || networkManager.IsServerStarted) { if (_client) { _client = false; Options.SetRemote(null); } } else if (!_client) { _client = true; Options.SetRemote(new Dictionary<string, string>()); } if (!networkManager.IsServerStarted || !_registered) { _sent = null; _clients = -1; return; } float unscaledTime = Time.unscaledTime; if (unscaledTime < _next) { return; } _next = unscaledTime + 0.5f; int count = networkManager.ServerManager.Clients.Count; if (count <= 1) { _sent = null; _clients = count; return; } string blob = Encode(Options.HostValues()); if (blob == _sent && count == _clients && unscaledTime < _resend) { return; } _resend = unscaledTime + ((count != _clients) ? 1f : 3f); _sent = blob; _clients = count; int byteCount = Encoding.UTF8.GetByteCount(blob); if (byteCount > 16000) { if (!_tooBig) { Kit.Warn("options: " + byteCount + " bytes of host values is over the " + 16000 + " byte message limit, not sent"); } _tooBig = true; } else { _tooBig = false; if (!Kit.Context.Network.SendToClients("options", (Action<ModWriter>)delegate(ModWriter w) { w.WriteString(blob); }, true, false)) { Kit.Warn("options: send failed"); } } } public static void Unregister() { Forget(); Options.SetRemote(null); } private static void Forget() { _client = false; _sent = null; _clients = -1; _resend = 0f; _tooBig = false; _nm = null; } private static void ClientGot(ModReader r) { string blob = r.ReadString(); NetworkManager networkManager = InstanceFinder.NetworkManager; if (!((Object)(object)networkManager == (Object)null) && !networkManager.IsServerStarted) { if ((Object)(object)networkManager != (Object)(object)_nm) { Forget(); _nm = networkManager; } _client = true; Options.SetRemote(Decode(blob)); } } private static string Encode(Dictionary<string, string> map) { StringBuilder stringBuilder = new StringBuilder(); foreach (KeyValuePair<string, string> item in map) { stringBuilder.Append(item.Key).Append('=').Append(item.Value) .Append('\n'); } return stringBuilder.ToString(); } private static Dictionary<string, string> Decode(string blob) { Dictionary<string, string> dictionary = new Dictionary<string, string>(StringComparer.Ordinal); string[] array = (blob ?? "").Split('\n'); foreach (string text in array) { int num = text.IndexOf('='); if (num > 0) { dictionary[text.Substring(0, num)] = text.Substring(num + 1); } } return dictionary; } } public class Plugin : IModPlugin { public void OnLoad(IModContext context) { Kit.Init(context); Kit.Try("net", OptionsNet.Register); Kit.Try("runner", delegate { Kit.Host.AddComponent<Runner>(); }); Kit.Log("loaded (SETTINGS in the game's Mods menu)"); } public void OnUnload() { Kit.Try("runner off", delegate { Runner component = Kit.Host.GetComponent<Runner>(); if ((Object)(object)component != (Object)null) { ((MonoBehaviour)component).StopAllCoroutines(); ((Behaviour)component).enabled = false; } }); Kit.Try("net", OptionsNet.Unregister); Kit.Try("menu", GameMenu.Uninstall); Kit.Try("options", Options.Unload); Kit.Shutdown(); } } internal enum RarityKind { None, Item } internal static class ModContent { public class PerkEntry { public Perk Perk; public string Id; public string Title; public Sprite Icon; } private static readonly HashSet<string> Acronyms = new HashSet<string> { "smg", "lmg", "rpg", "ak", "tnt", "hp", "npc" }; public static List<Item> ItemsOf(string modId) { List<Item> list = new List<Item>(); if ((Object)(object)Kit.Design == (Object)null) { return list; } string value = modId + "_"; foreach (Item item in Kit.Design.itemList) { if ((Object)(object)item != (Object)null && ((Object)item).name.StartsWith(value, StringComparison.Ordinal)) { list.Add(item); } } return list; } public static List<PerkEntry> PerksOf(string modId) { List<PerkEntry> list = new List<PerkEntry>(); RegisteredModPerk val = default(RegisteredModPerk); foreach (Perk modPerk in SessionContentRegistry.ModPerkList) { if (!((Object)(object)modPerk == (Object)null) && SessionContentRegistry.TryGetModRegistration(modPerk, ref val) && !(val.ModId != modId)) { PerkEntry perkEntry = new PerkEntry { Perk = modPerk, Id = val.PerkId }; perkEntry.Title = ((val.Metadata != null && !string.IsNullOrEmpty(val.Metadata.Title)) ? val.Metadata.Title : val.PerkId); try { perkEntry.Icon = PerkDisplay.GetIcon(modPerk); } catch (Exception) { perkEntry.Icon = modPerk.icon; } list.Add(perkEntry); } } return list; } public static List<Item> VanillaItems() { List<Item> list = new List<Item>(); if ((Object)(object)Kit.Design == (Object)null) { return list; } List<string> list2 = new List<string>(); foreach (DiscoveredMod item in LocalModProvider.Mods ?? new List<DiscoveredMod>()) { if (item != null && !string.IsNullOrEmpty(item.ModId)) { list2.Add(item.ModId + "_"); } } foreach (Item item2 in Kit.Design.itemList) { if ((Object)(object)item2 == (Object)null) { continue; } bool flag = false; for (int i = 0; i < list2.Count; i++) { if (flag) { break; } flag = ((Object)item2).name.StartsWith(list2[i], StringComparison.Ordinal); } if (!flag) { list.Add(item2); } } return list; } public static List<PerkEntry> VanillaPerks() { //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Invalid comparison between Unknown and I4 List<PerkEntry> list = new List<PerkEntry>(); if ((Object)(object)Kit.Design == (Object)null || Kit.Design.perks == null) { return list; } Perk[] perks = Kit.Design.perks; foreach (Perk val in perks) { if (!((Object)(object)val == (Object)null) && !val.dontIncludeInPool && !val.isCorrupted && (int)val.availability != 3) { PerkEntry perkEntry = new PerkEntry { Perk = val, Id = ((Object)val).name }; try { perkEntry.Title = PerkDisplay.GetTitle(val); } catch (Exception) { } if (string.IsNullOrEmpty(perkEntry.Title)) { perkEntry.Title = PrettyBase(((Object)val).name); } try { perkEntry.Icon = PerkDisplay.GetIcon(val); } catch (Exception) { perkEntry.Icon = val.icon; } list.Add(perkEntry); } } return list; } public static string PrettyBase(string name) { StringBuilder stringBuilder = new StringBuilder(); for (int i = 0; i < name.Length; i++) { char c = name[i]; if (c == '_' || c == '-') { stringBuilder.Append(' '); continue; } if (i > 0 && char.IsUpper(c) && char.IsLower(name[i - 1])) { stringBuilder.Append(' '); } stringBuilder.Append(c); } return stringBuilder.ToString(); } public static string Pretty(string id) { string[] source = id.Replace('-', '_').Split(new char[1] { '_' }, StringSplitOptions.RemoveEmptyEntries); return string.Join(" ", source.Select((string w) => (!Acronyms.Contains(w.ToLowerInvariant())) ? (char.ToUpperInvariant(w[0]) + w.Substring(1)) : w.ToUpperInvariant()).ToArray()); } } internal static class Rarity { public const string ItemGroup = "Weapon spawn rate"; public const string BaseId = "base-game"; public static void AddBase(List<OptionDef> defs) { int count = defs.Count; foreach (Item item in ModContent.VanillaItems()) { if (!(item.spawnChanceMultiplier <= 0f)) { StringBuilder id = new StringBuilder("rarity_item_"); string name = ((Object)item).name; foreach (char c in name) { id.Append(char.IsLetterOrDigit(c) ? c : '_'); } if (!defs.Any((OptionDef x) => x.ModId == "base-game" && x.Id == id.ToString())) { defs.Add(new OptionDef { ModId = "base-game", Id = id.ToString(), Label = ModContent.PrettyBase(((Object)item).name), Group = "Weapon spawn rate", GroupNote = "How often each of the game's own weapons shows up on the pedestals. x1 = as the game ships it, x0 = never.", Kind = OptKind.Number, Min = 0.0, Max = 3.0, Step = 0.1, Default = 1.0, Host = true, Item = ((Object)item).name, Field = "Item.spawnChanceMultiplier", Multiply = true, Rarity = RarityKind.Item, Icon = item.icon, Prefix = "x" }); } } } if (defs.Count > count) { Kit.Log("rarity: base game: " + (defs.Count - count) + " weapon(s)"); } } public static void AddFor(string modId, List<OptionDef> defs) { int count = defs.Count; foreach (Item item in ModContent.ItemsOf(modId)) { if (!(item.spawnChanceMultiplier <= 0f)) { string text = ((Object)item).name.Substring(modId.Length + 1); string id = "rarity_item_" + text; if (!defs.Any((OptionDef x) => x.ModId == modId && x.Id == id)) { defs.Add(new OptionDef { ModId = modId, Id = id, Label = ModContent.Pretty(text), Group = "Weapon spawn rate", GroupNote = "How often each weapon shows up on the pedestals. x1 = as the mod ships it, x0 = never.", Kind = OptKind.Number, Min = 0.0, Max = 3.0, Step = 0.1, Default = 1.0, Host = true, Item = text, Field = "Item.spawnChanceMultiplier", Multiply = true, Rarity = RarityKind.Item, Icon = item.icon, Prefix = "x" }); } } } if (defs.Count > count) { Kit.Log("rarity: " + modId + ": " + string.Join(", ", (from d in defs.Skip(count) select d.Id).ToArray())); } } } internal class Runner : MonoBehaviour { private float _started; private float _nextNet; private float _nextLoad; private bool _loaded; private bool _previewStarted; private bool _menuDead; private Action _netPoll; private void Start() { _started = Time.realtimeSinceStartup; _netPoll = OptionsNet.Poll; } private void Update() { float realtimeSinceStartup = Time.realtimeSinceStartup; Options.Tick(); if (!_loaded) { TryLoadOptions(realtimeSinceStartup); return; } if (realtimeSinceStartup >= _nextNet) { _nextNet = realtimeSinceStartup + 0.2f; Kit.Try("options net", _netPoll); } if (!_menuDead) { try { GameMenu.Tick(); } catch (Exception ex) { Kit.Error("mods menu: " + ex); _menuDead = true; } } if (!_previewStarted && (Object)(object)MenuManager.Instance != (Object)null && (Object)(object)WorkshopMenuUI.Instance != (Object)null && File.Exists(Path.Combine(Path.Combine(Application.persistentDataPath, "ModData"), "preview.flag"))) { _previewStarted = true; Options.Dry = true; ((MonoBehaviour)this).StartCoroutine(PreviewShots()); } } private void TryLoadOptions(float now) { if (now < _nextLoad) { return; } _nextLoad = now + 0.25f; if (!((Object)(object)Kit.Design == (Object)null) && LocalModProvider.Mods != null) { IReadOnlyList<LoadedModPlugin> loadedPlugins = ModAssemblyLoader.LoadedPlugins; int num = LocalModProvider.Mods.Count((DiscoveredMod m) => m != null && m.IsValid && m.IsEnabled); if ((loadedPlugins?.Count ?? 0) >= num || !(now - _started < 12f)) { _loaded = true; Kit.Try("options", Options.Load); } } } private void OnApplicationQuit() { Options.Save(); } private void OnDestroy() { OptionsNet.Unregister(); } private IEnumerator PreviewShots() { yield return (object)new WaitForSecondsRealtime(4f); string dir = Path.Combine(Kit.DataDir, "preview"); Directory.CreateDirectory(dir); string[] files = Directory.GetFiles(dir, "*.png"); for (int i = 0; i < files.Length; i++) { File.Delete(files[i]); } MenuManager instance = MenuManager.Instance; WorkshopMenuUI wm = WorkshopMenuUI.Instance; if ((Object)(object)instance == (Object)null || (Object)(object)wm == (Object)null) { Kit.Warn("preview: no menu"); yield break; } instance.SetPageToStart(); yield return Shot(Path.Combine(dir, "1_main_menu.png")); wm.Open(); yield return (object)new WaitForSecondsRealtime(1f); int num = 0; int num2 = 0; ModsMenuRow[] componentsInChildren = ((Component)wm).GetComponentsInChildren<ModsMenuRow>(false); foreach (ModsMenuRow obj in componentsInChildren) { num++; if ((Object)(object)((Component)obj).transform.Find("ModManager Settings") != (Object)null) { num2++; } } Kit.Log("preview: game Mods menu open, " + num2 + " of " + num + " rows have a settings button"); yield return Shot(Path.Combine(dir, "2_game_mods_menu.png")); ScrollRect list = ((Component)wm).GetComponentInChildren<ScrollRect>(); if ((Object)(object)list != (Object)null) { list.verticalNormalizedPosition = 0f; yield return Shot(Path.Combine(dir, "2b_game_mods_menu_bottom.png")); list.verticalNormalizedPosition = 1f; } SettingsPage page = GameMenu.Page; if ((Object)(object)page == (Object)null) { Kit.Warn("preview: no settings page"); wm.Close(); yield break; } List<DiscoveredMod> mods = LocalModProvider.Mods.Where((DiscoveredMod m) => m != null && m.ModId != Kit.ModId).OrderBy<DiscoveredMod, string>((DiscoveredMod m) => m.Name ?? m.ModId, StringComparer.OrdinalIgnoreCase).ToList(); GameMenu.Open("base-game"); if (PerkTiers.Available) { page.Show("base-game", 2); yield return Shot(Path.Combine(dir, "5_base_perk_rarity.png")); int before = (PerkTiers.Sorted("ClownNose") ? PerkTiers.Of("ClownNose") : (-1)); bool dragged = page.PreviewDrag("ClownNose", -1); yield return (object)new WaitForSecondsRealtime(0.3f); int num3 = (PerkTiers.Sorted("ClownNose") ? PerkTiers.Of("ClownNose") : (-1)); Kit.Log("preview drag ClownNose: ran=" + dragged + " tier " + before + " -> " + num3 + ((dragged && num3 == -1) ? " OK" : " FAILED")); yield return Shot(Path.Combine(dir, "5c_after_drag.png")); PerkTiers.Set("ClownNose", before); Kit.Log("preview drag undone: tier " + (PerkTiers.Sorted("ClownNose") ? PerkTiers.Of("ClownNose") : (-1))); } page.Show("base-game", 1); yield return Shot(Path.Combine(dir, "6_base_weapon_rarity.png")); DiscoveredMod val = ((IEnumerable<DiscoveredMod>)mods).FirstOrDefault((Func<DiscoveredMod, bool>)((DiscoveredMod m) => page.HasPerkTiers(m.ModId))); if (val != null) { GameMenu.Open(val.ModId); page.Show(val.ModId, 2); yield return Shot(Path.Combine(dir, "7_mod_perk_rarity.png")); } DiscoveredMod val2 = ((IEnumerable<DiscoveredMod>)mods).FirstOrDefault((Func<DiscoveredMod, bool>)((DiscoveredMod m) => Options.For(m.ModId).Any((OptionDef d) => d.Rarity == RarityKind.None))) ?? ((IEnumerable<DiscoveredMod>)mods).FirstOrDefault((Func<DiscoveredMod, bool>)((DiscoveredMod m) => Options.For(m.ModId).Any())); if (val2 != null) { GameMenu.Open(val2.ModId); page.Show(val2.ModId, 1); yield return Shot(Path.Combine(dir, "3_mods_options.png")); TMP_Text[] componentsInChildren2 = ((Component)page).GetComponentsInChildren<TMP_Text>(); foreach (TMP_Text val3 in componentsInChildren2) { if ((Object)(object)val3.transform.parent != (Object)null && ((Object)val3.transform.parent).name == "Row" && val3.text.Length > 0 && val3.GetParsedText().Length == 0) { Kit.Warn("preview: option label '" + val3.text + "' is not drawn (rect " + ((object)val3.rectTransform.rect/*cast due to .constrained prefix*/).ToString() + ")"); } } page.ScrollDetails(1f); yield return Shot(Path.Combine(dir, "3b_mods_options_bottom.png")); } DiscoveredMod val4 = ((IEnumerable<DiscoveredMod>)mods).FirstOrDefault((Func<DiscoveredMod, bool>)((DiscoveredMod m) => FriendPicker.Wanted(m.RootPath))); if (val4 != null) { GameMenu.Open(val4.ModId); yield return Shot(Path.Combine(dir, "4_friend_picker.png")); } GameMenu.Close(); yield return Shot(Path.Combine(dir, "9_back_to_mods_menu.png")); Kit.Log("preview: after BACK the game's menu is " + (wm.IsOpen ? "still open OK" : "CLOSED (FAILED)")); if (PerkTiers.Available) { yield return (object)new WaitForSecondsRealtime(4f); GameMenu.Open("base-game"); page.Show("base-game", 2); float[] array = new float[3] { 0.3f, 0.6f, 1f }; foreach (float num4 in array) { page.ScrollDetails(num4); yield return Shot(Path.Combine(dir, "8_base_perk_rarity_scroll_" + (int)(num4 * 100f) + ".png")); } GameMenu.Close(); } wm.Close(); Kit.Log("menu preview done " + dir); } private static IEnumerator Shot(string path) { yield return (object)new WaitForSecondsRealtime(0.45f); for (int i = 0; i < 20; i++) { yield return (object)new WaitForEndOfFrame(); Texture2D val = ScreenCapture.CaptureScreenshotAsTexture(); if (!((Object)(object)val == (Object)null)) { File.WriteAllBytes(path, ImageConversion.EncodeToPNG(val)); Object.Destroy((Object)(object)val); yield break; } } Kit.Warn("preview: no screenshot for " + Path.GetFileName(path)); } } internal class SettingsPage : MonoBehaviour { private const float WinW = 1320f; private const float WinH = 900f; private const float HeaderH = 104f; private const float FooterH = 112f; private static readonly Color GoodTxt = new Color(0.17f, 0.58f, 0.28f); private static readonly Color WarnTxt = new Color(0.78f, 0.52f, 0.1f); private static readonly Color PillBg = new Color(0.965f, 0.961f, 0.973f); private static readonly Color OnDark = new Color(0.8f, 0.79f, 0.8f); private bool _built; private bool _lockSeen; private bool _tierLockSeen; private string _selected; private int _tab; private readonly Dictionary<string, List<TierEditor.Entry>> _cards = new Dictionary<string, List<TierEditor.Entry>>(); private RectTransform _detailContent; private RectTransform _dragLayer; private TierEditor _editor; private ScrollRect _detailScroll; private TextMeshProUGUI _title; private TextMeshProUGUI _subtitle; private Button _tabOptions; private Button _tabRarity; private Button _back; private GameObject _tabsRow; public Action Closed; public Selectable DefaultSelectable => (Selectable)(object)_back; public string Selected => _selected; private void Update() { if (_lockSeen != Options.FromHost) { _lockSeen = Options.FromHost; if (_tab == 1) { RebuildDetails(); } } bool flag = PerkTiers.Available && PerkTiers.Locked; if (_tierLockSeen != flag) { _tierLockSeen = flag; if (_tab == 2) { RebuildDetails(); } } Keyboard current = Keyboard.current; Gamepad current2 = Gamepad.current; if ((current != null && ((ButtonControl)current.escapeKey).wasPressedThisFrame) || (current2 != null && current2.buttonEast.wasPressedThisFrame)) { Back(); } } private void Back() { if (Closed != null) { Closed(); } } public void Build() { //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Expected O, but got Unknown //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_018f: Unknown result type (might be due to invalid IL or missing references) //IL_019a: Expected O, but got Unknown //IL_01c2: Unknown result type (might be due to invalid IL or missing references) //IL_01c7: Unknown result type (might be due to invalid IL or missing references) //IL_01dd: Unknown result type (might be due to invalid IL or missing references) //IL_01ec: Expected O, but got Unknown //IL_01f9: Unknown result type (might be due to invalid IL or missing references) //IL_01fe: Unknown result type (might be due to invalid IL or missing references) //IL_0214: Unknown result type (might be due to invalid IL or missing references) //IL_0223: Expected O, but got Unknown //IL_023f: Unknown result type (might be due to invalid IL or missing references) //IL_0249: Expected O, but got Unknown //IL_00cc: Unknown result type (might be due to invalid IL or missing references) if (!_built) { _built = true; Ui.Init(); RectTransform parent = (RectTransform)((Component)this).transform; Ui.Stretch(((Graphic)Ui.Img((Transform)(object)parent, "Dim", new Color(0f, 0f, 0f, 0.45f), null, raycast: true)).rectTransform); RectTransform val = Ui.Node("Window", (Transform)(object)parent); Ui.Anchor(val, new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), Vector2.zero, new Vector2(1320f, 900f)); if ((Object)(object)Ui.Shadow != (Object)null) { Ui.Stretch(((Graphic)Ui.Img((Transform)(object)val, "Shadow", Color.white, Ui.Shadow)).rectTransform, -40f, -70f, -40f, -10f); } Image obj = Ui.Img((Transform)(object)val, "Mask", Ui.Body, Ui.Round, raycast: true); Ui.Stretch(((Graphic)obj).rectTransform); ((Component)obj).gameObject.AddComponent<Mask>(); RectTransform parent2 = (_dragLayer = ((Graphic)obj).rectTransform); BuildHeader(parent2); BuildFooter(parent2); RectTransform val2 = Ui.Node("Body", (Transform)(object)parent2); Ui.Stretch(val2, 0f, 112f, 0f, 104f); Ui.VGroup(((Component)val2).gameObject, 12f, new RectOffset(40, 40, 22, 22), (TextAnchor)0); RectTransform val3 = Row((Transform)(object)val2, 14f, 66f); _tabsRow = ((Component)val3).gameObject; _tabOptions = Ui.Pill((Transform)(object)val3, "OPTIONS", PillBg, Ui.Dark, 300f, 62f, (UnityAction)delegate { _tab = 1; RebuildDetails(); }, 28f); _tabRarity = Ui.Pill((Transform)(object)val3, "PERK RARITY", PillBg, Ui.Dark, 300f, 62f, (UnityAction)delegate { _tab = 2; RebuildDetails(); }, 28f); _detailContent = Ui.Scroll((Transform)(object)val2, "Details", out _detailScroll, 12f, new RectOffset(6, 6, 8, 28)); Ui.Size(((Component)_detailScroll).gameObject, -1f, -1f, 1f, 1f); } } private void BuildHeader(RectTransform parent) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_012d: Unknown result type (might be due to invalid IL or missing references) //IL_0157: Unknown result type (might be due to invalid IL or missing references) //IL_0166: Unknown result type (might be due to invalid IL or missing references) //IL_0175: Unknown result type (might be due to invalid IL or missing references) //IL_0184: Unknown result type (might be due to invalid IL or missing references) //IL_0193: Unknown result type (might be due to invalid IL or missing references) Image val = Ui.Img((Transform)(object)parent, "Header", Ui.Dark, null, raycast: true); Ui.Anchor(((Graphic)val).rectTransform, new Vector2(0f, 1f), new Vector2(1f, 1f), new Vector2(0.5f, 1f), Vector2.zero, new Vector2(0f, 104f)); _title = Ui.Text((Transform)(object)((Graphic)val).rectTransform, "", 56f, Ui.HeaderText, (TextAlignmentOptions)513); Ui.Anchor(((TMP_Text)_title).rectTransform, new Vector2(0f, 0f), new Vector2(0.6f, 1f), new Vector2(0f, 0.5f), new Vector2(40f, 0f), new Vector2(-40f, 0f)); ((TMP_Text)_title).alignment = (TextAlignmentOptions)513; ((TMP_Text)_title).enableAutoSizing = true; ((TMP_Text)_title).fontSizeMin = 30f; ((TMP_Text)_title).fontSizeMax = 56f; _subtitle = Ui.Text((Transform)(object)((Graphic)val).rectTransform, "", 28f, OnDark, (TextAlignmentOptions)516); Ui.Anchor(((TMP_Text)_subtitle).rectTransform, new Vector2(0.6f, 0f), new Vector2(1f, 1f), new Vector2(1f, 0.5f), new Vector2(-40f, 0f), new Vector2(-40f, 0f)); } private void BuildFooter(RectTransform parent) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Expected O, but got Unknown //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Expected O, but got Unknown //IL_00cc: Unknown result type (might be due to invalid IL or missing references) Image val = Ui.Img((Transform)(object)parent, "Footer", Ui.Dark, null, raycast: true); Ui.Anchor(((Graphic)val).rectTransform, new Vector2(0f, 0f), new Vector2(1f, 0f), new Vector2(0.5f, 0f), Vector2.zero, new Vector2(0f, 112f)); ((HorizontalOrVerticalLayoutGroup)Ui.HGroup(((Component)val).gameObject, 18f, new RectOffset(34, 34, 0, 0), (TextAnchor)3)).childForceExpandHeight = false; _back = Ui.Pill((Transform)(object)((Graphic)val).rectTransform, "BACK", PillBg, Ui.Dark, 220f, 74f, new UnityAction(Back), 34f); Ui.Size(((Component)Ui.Text((Transform)(object)((Graphic)val).rectTransform, "Changes save on their own. In a friend's lobby the host's GAME values and tiers are used.", 23f, OnDark, (TextAlignmentOptions)513, wrap: true)).gameObject, -1f, -1f, 1f, 0f); } private static RectTransform Row(Transform parent, float spacing, float h) { RectTransform val = Ui.Node("Row", parent); ((HorizontalOrVerticalLayoutGroup)Ui.HGroup(((Component)val).gameObject, spacing, null, (TextAnchor)3)).childForceExpandHeight = false; if (h > 0f) { Ui.Size(((Component)val).gameObject, -1f, h); } return val; } private static DiscoveredMod ModOf(string modId) { return LocalModProvider.Mods?.FirstOrDefault((Func<DiscoveredMod, bool>)((DiscoveredMod m) => m != null && m.ModId == modId)); } private static bool IsLoaded(string modId) { return ModAssemblyLoader.LoadedPlugins?.Any((LoadedModPlugin p) => p != null && p.Mod != null && p.Mod.ModId == modId) ?? false; } private List<TierEditor.Entry> CardsOf(string modId) { if (_cards.TryGetValue(modId, out var value)) { return value; } value = new List<TierEditor.Entry>(); try { foreach (ModContent.PerkEntry item in (modId == "base-game") ? ModContent.VanillaPerks() : ModContent.PerksOf(modId)) { if ((Object)(object)item.Perk != (Object)null) { value.Add(new TierEditor.Entry { Key = ((Object)item.Perk).name, Title = item.Title, Icon = item.Icon }); } } } catch (Exception ex) { Kit.Warn("content scan: " + ex.Message); } _cards[modId] = value; return value; } private bool HasTiers(string id) { if (!PerkTiers.Available) { return false; } if (id != "base-game" && !IsLoaded(id)) { return false; } return CardsOf(id).Count > 0; } private bool HasPicker(string id) { DiscoveredMod val = ((id == "base-game") ? null : ModOf(id)); if (val != null) { return FriendPicker.Wanted(val.RootPath); } return false; } public bool HasSettings(string id) { if (!Options.For(id).Any() && !HasTiers(id)) { return HasPicker(id); } return true; } public void Show(string modId, int tab) { _selected = modId; _tab = tab; _lockSeen = Options.FromHost; _tierLockSeen = PerkTiers.Available && PerkTiers.Locked; RebuildDetails(); } public bool HasPerkTiers(string id) { return HasTiers(id); } public bool PreviewDrag(string key, int tier) { Canvas.ForceUpdateCanvases(); if (_editor != null) { return _editor.PreviewDrag(key, tier); } return false; } public void ScrollDetails(float fromTop) { Canvas.ForceUpdateCanvases(); _detailScroll.verticalNormalizedPosition = 1f - Mathf.Clamp01(fromTop); } private static void ShowTab(Button b, bool on) { ((Component)((Component)b).transform.parent).gameObject.SetActive(on); } private void RebuildDetails() { //IL_01ef: Unknown result type (might be due to invalid IL or missing references) Ui.Clear((Transform)(object)_detailContent); _detailScroll.verticalNormalizedPosition = 1f; _editor = null; bool flag = _selected == "base-game"; DiscoveredMod val = (flag ? null : ModOf(_selected)); if (val == null && !flag) { ((TMP_Text)_title).text = ""; ((TMP_Text)_subtitle).text = ""; _tabsRow.SetActive(false); return; } string selected = _selected; int num = Options.For(selected).Count(); bool flag2 = num > 0 || HasPicker(selected); bool flag3 = HasTiers(selected); if (_tab != 1 && _tab != 2) { _tab = (flag2 ? 1 : 2); } if (_tab == 1 && !flag2) { _tab = 2; } if (_tab == 2 && !flag3) { _tab = 1; } _tabsRow.SetActive(flag2 && flag3); ShowTab(_tabOptions, flag2); ShowTab(_tabRarity, flag3); Tab(_tabOptions, _tab == 1); Tab(_tabRarity, _tab == 2); ((Component)_tabOptions).GetComponentInChildren<TMP_Text>().text = ((num == 0) ? "OPTIONS" : ((flag ? "WEAPONS (" : "OPTIONS (") + num + ")")); ((TMP_Text)_title).text = (flag ? "Base Game" : (val.Name ?? val.ModId)); ((TMP_Text)_subtitle).text = (flag ? "A Gentlemen's Dispute" : ("v" + val.Version)); if (_tab == 2 && flag3) { BuildTiers(selected); } else if (flag2) { BuildOptions(selected); } else { Line("Nothing to change here.", 25f, Ui.Muted); } } private static void Tab(Button b, bool on) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) ((Graphic)(Image)((Selectable)b).targetGraphic).color = (on ? Ui.Red : PillBg); ((Graphic)((Component)b).GetComponentInChildren<TMP_Text>()).color = (on ? Ui.RedText : Ui.Dark); } private void Section(string title) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) Ui.Size(((Component)Ui.Text((Transform)(object)_detailContent, title, 28f, Ui.Gold, (TextAlignmentOptions)513)).gameObject, -1f, 44f); } private TextMeshProUGUI Line(string s, float size, Color c) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) return Ui.Text((Transform)(object)_detailContent, s, size, c, (TextAlignmentOptions)513, wrap: true); } private void BuildTiers(string id) { //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Expected O, but got Unknown bool locked = PerkTiers.Locked; List<TierEditor.Entry> entries = CardsOf(id); RectTransform parent = Row((Transform)(object)_detailContent, 16f, 66f); Ui.Size(((Component)Ui.Text((Transform)(object)parent, locked ? "You are in someone else's lobby: the host's tiers decide the deal and can't be changed here." : "Drag a card onto a tier, or click a card and then a tier. Unsorted cards are dealt like Common. Your tiers apply when you host.", 21f, Ui.Muted, (TextAlignmentOptions)513, wrap: true)).gameObject, -1f, 66f, 1f, 0f); ((Selectable)Ui.Pill((Transform)(object)parent, "RESET", PillBg, Ui.Dark, 200f, 56f, (UnityAction)delegate { foreach (TierEditor.Entry item in entries) { PerkTiers.Reset(item.Key); } RebuildDetails(); })).interactable = !locked; _editor = new TierEditor((Transform)(object)_detailContent, entries, _dragLayer, _detailScroll); } private void BuildOptions(string id) { //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Expected O, but got Unknown //IL_0110: Unknown result type (might be due to invalid IL or missing references) if (HasPicker(id)) { FriendPicker.Build(_detailContent, id); } if (!Options.For(id).Any()) { return; } Line(Options.FromHost ? "You are in someone else's lobby: GAME options show the host's values and can't be changed here." : "GAME options are used when you host; in a friend's lobby their values win. LOCAL options only change your own game.", 22f, Ui.Muted); Ui.Pill((Transform)(object)Row((Transform)(object)_detailContent, 12f, 70f), "RESET ALL", PillBg, Ui.Dark, 260f, 62f, (UnityAction)delegate { Options.ResetMod(id); RebuildDetails(); }, 28f); string text = null; foreach (OptionDef item in Options.For(id)) { if (item.Group != text && !string.IsNullOrEmpty(item.Group)) { Section(item.Group.ToUpperInvariant()); if (!string.IsNullOrEmpty(item.GroupNote)) { Line(item.GroupNote, 21f, Ui.Muted); } } text = item.Group; if (item.Rarity != RarityKind.None) { AddRarity(item); } else { AddOption(item); } } } private static string ShowNum(OptionDef d, double v) { if (d.Rarity != RarityKind.None && v <= 0.0) { return "never"; } bool flag = d.Step >= 1.0 && Math.Abs(d.Step - Math.Round(d.Step)) < 1E-09; return d.Prefix + v.ToString(flag ? "0" : "0.##", CultureInfo.InvariantCulture) + d.Suffix; } private void AddRarity(OptionDef d) { //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Expected O, but got Unknown //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Unknown result type (might be due to invalid IL or missing references) bool locked = Options.FromHost && d.Host; Image val = Ui.Card((Transform)(object)_detailContent, "Rarity " + d.Id, Ui.RowBg); Ui.Size(((Component)(RectTransform)((Transform)((Graphic)val).rectTransform).parent).gameObject, -1f, 84f); ((HorizontalOrVerticalLayoutGroup)Ui.HGroup(((Component)val).gameObject, 18f, new RectOffset(20, 24, 8, 8), (TextAnchor)3)).childForceExpandHeight = false; Ui.SpriteIcon((Transform)(object)((Graphic)val).rectTransform, d.Icon, 60f); Ui.Size(((Component)Ui.Text((Transform)(object)((Graphic)val).rectTransform, d.Label, 29f, Ui.Dark, (TextAlignmentOptions)513)).gameObject, -1f, 44f, 1f, 0f); TextMeshProUGUI val2 = Ui.Text((Transform)(object)((Graphic)val).rectTransform, "", 29f, Ui.Dark, (TextAlignmentOptions)516); Action show = delegate { //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) ((TMP_Text)val2).text = ShowNum(d, Options.Num(d, locked)); ((Graphic)val2).color = ((locked ? (Options.Effective(d) == d.DefaultText) : Options.IsDefault(d)) ? Ui.Dark : WarnTxt); }; ((Selectable)Ui.MakeSlider((Transform)(object)((Graphic)val).rectTransform, (float)d.Min, (float)d.Max, (float)d.Step, (float)Options.Num(d, locked), delegate(float v) { Options.SetOwn(d, OptionDef.Fmt(v)); show(); }, 280f)).interactable = !locked; Ui.Size(((Component)val2).gameObject, 110f, 44f); show(); } private void AddOption(OptionDef d) { //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Expected O, but got Unknown //IL_0153: Unknown result type (might be due to invalid IL or missing references) //IL_01b4: Unknown result type (might be due to invalid IL or missing references) //IL_01ad: Unknown result type (might be due to invalid IL or missing references) //IL_0206: Unknown result type (might be due to invalid IL or missing references) //IL_0245: Unknown result type (might be due to invalid IL or missing references) //IL_02ae: Unknown result type (might be due to invalid IL or missing references) //IL_043d: Unknown result type (might be due to invalid IL or missing references) //IL_0442: Unknown result type (might be due to invalid IL or missing references) //IL_0459: Unknown result type (might be due to invalid IL or missing references) //IL_0468: Expected O, but got Unknown bool locked = Options.FromHost && d.Host; Image val = Ui.Card((Transform)(object)_detailContent, "Opt " + d.Id, Ui.RowBg); RectTransform val2 = (RectTransform)((Transform)((Graphic)val).rectTransform).parent; Ui.Size(h: Mathf.Max(96f, 72f + 27f * (float)(((!string.IsNullOrEmpty(d.Info)) ? ((d.Info.Length + 84) / 85) : 0) + (locked ? 1 : 0))), go: ((Component)val2).gameObject); ((HorizontalOrVerticalLayoutGroup)Ui.HGroup(((Component)val).gameObject, 22f, new RectOffset(24, 24, 12, 12), (TextAnchor)3)).childForceExpandHeight = false; RectTransform val3 = Ui.Node("Text", (Transform)(object)((Graphic)val).rectTransform); Ui.VGroup(((Component)val3).gameObject, 2f, null, (TextAnchor)3); Ui.Size(((Component)val3).gameObject, 0f, -1f, 1f, 0f); RectTransform parent = Row((Transform)(object)val3, 14f, 40f); Ui.Size(((Component)Ui.Text((Transform)(object)parent, d.Label, 31f, Ui.Dark, (TextAlignmentOptions)513)).gameObject, -1f, 40f); Ui.Size(((Component)Ui.Text((Transform)(object)parent, d.Host ? "GAME" : "LOCAL", 20f, d.Host ? WarnTxt : GoodTxt, (TextAlignmentOptions)513)).gameObject, -1f, 40f); if (!string.IsNullOrEmpty(d.Info)) { Ui.Text((Transform)(object)val3, d.Info, 21f, Ui.Muted, (TextAlignmentOptions)513, wrap: true); } if (locked) { Ui.Text((Transform)(object)val3, "Host's value: " + Pretty(d, Options.Effective(d)), 21f, WarnTxt, (TextAlignmentOptions)513, wrap: true); } RectTransform val4 = Ui.Node("Control", (Transform)(object)((Graphic)val).rectTransform); ((HorizontalOrVerticalLayoutGroup)Ui.HGroup(((Component)val4).gameObject, 16f, null, (TextAnchor)5)).childForceExpandHeight = false; if (d.Kind == OptKind.Number) { TextMeshProUGUI val5 = Ui.Text((Transform)(object)val4, "", 30f, Ui.Dark, (TextAlignmentOptions)516); Ui.Size(((Component)val5).gameObject, 100f, 44f); Action show = delegate { //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) double v = Options.Num(d, locked); ((TMP_Text)val5).text = ShowNum(d, v); ((Graphic)val5).color = ((locked ? (Options.Effective(d) == d.DefaultText) : Options.IsDefault(d)) ? Ui.Dark : WarnTxt); }; ((Selectable)Ui.MakeSlider((Transform)(object)val4, (float)d.Min, (float)d.Max, (float)d.Step, (float)Options.Num(d, locked), delegate(float v) { Options.SetOwn(d, OptionDef.Fmt(v)); show(); }, 240f)).interactable = !locked; ((TMP_Text)val5).transform.SetAsLastSibling(); show(); } else if (d.Kind == OptKind.Toggle) { ((Selectable)Ui.Checkbox((Transform)(object)val4, (locked ? Options.Effective(d) : Options.Own(d)) == "true", delegate(bool on) { Options.SetOwn(d, on ? "true" : "false"); }, out var _, 54f)).interactable = !locked; } else { Button pill = null; Func<string> cur = () => (!locked) ? Options.Own(d) : Options.Effective(d); pill = Ui.Pill((Transform)(object)val4, cur(), PillBg, Ui.Dark, 320f, 62f, (UnityAction)delegate { int num = Array.IndexOf(d.Choices, Options.Own(d)); Options.SetOwn(d, d.Choices[(num + 1) % d.Choices.Length]); ((Component)pill).GetComponentInChildren<TMP_Text>().text = cur(); }, 28f); ((Selectable)pill).interactable = !locked; } } private static string Pretty(OptionDef d, string v) { if (d.Kind == OptKind.Toggle) { if (!(v == "true")) { return "off"; } return "on"; } if (d.Kind == OptKind.Number) { if (!double.TryParse(v, NumberStyles.Float, CultureInfo.InvariantCulture, out var result)) { return v; } return ShowNum(d, result); } return v; } } internal static class PerkTiers { private const string Slot = "agd.perktiers"; private static object[] Data { get { if (!(AppDomain.CurrentDomain.GetData("agd.perktiers") is object[] array) || array.Length < 9) { return null; } return array; } } public static bool Available => Data != null; public static int Count { get { object[] data = Data; if (data != null) { return ((string[])data[0]).Length; } return 0; } } public static string[] Names => (string[])Data[0]; public static Color[] Colors => (Color[])Data[1]; public static double[] Weights => (double[])Data[2]; public static bool Locked => ((Func<bool>)Data[7])(); public static int Of(string key) { return ((Func<string, int>)Data[3])(key); } public static bool Sorted(string key) { return ((Func<string, bool>)Data[4])(key); } public static void Set(string key, int tier) { ((Action<string, int>)Data[5])(key, tier); } public static void Reset(string key) { ((Action<string>)Data[6])(key); } } internal class TierEditor { public class Entry { public string Key; public string Title; public Sprite Icon; } private class Lane { public int Tier; public RectTransform Root; public RectTransform Grid; public Image Edge; public TextMeshProUGUI Head; public LayoutElement Size; } private const int Cols = 3; private const float CellW = 268f; private const float CellH = 58f; private const float Gap = 8f; private const float EdgeBand = 80f; private const float ScrollSpeed = 1100f; private static readonly Color Hot = new Color(0.804f, 0.576f, 0.259f); private readonly List<Entry> _entries; private readonly RectTransform _dragLayer; private readonly ScrollRect _scroll; private readonly bool _locked; private readonly List<Lane> _lanes = new List<Lane>(); private string _picked; private int _hot = -2; public TierEditor(Transform parent, List<Entry> entries, RectTransform dragLayer, ScrollRect scroll) { _entries = entries.OrderBy<Entry, string>((Entry e) => e.Title, StringComparer.OrdinalIgnoreCase).ToList(); _dragLayer = dragLayer; _scroll = scroll; _locked = PerkTiers.Locked; AddLane(parent, -1); for (int num = 0; num < PerkTiers.Count; num++) { AddLane(parent, num); } Refresh(); } private static Color Blend(Color a, Color b, float k) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) return new Color(a.r + (b.r - a.r) * k, a.g + (b.g - a.g) * k, a.b + (b.b - a.b) * k, 1f); } private void AddLane(Transform parent, int tier) { //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Expected O, but got Unknown //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Unknown result type (might be due to invalid IL or missing references) //IL_011e: Unknown result type (might be due to invalid IL or missing references) //IL_012d: Unknown result type (might be due to invalid IL or missing references) //IL_013c: Unknown result type (might be due to invalid IL or missing references) //IL_014b: Unknown result type (might be due to invalid IL or missing references) //IL_0168: Unknown result type (might be due to invalid IL or missing references) //IL_0173: Expected O, but got Unknown //IL_0185: Unknown result type (might be due to invalid IL or missing references) //IL_01fc: Unknown result type (might be due to invalid IL or missing references) //IL_0211: Unknown result type (might be due to invalid IL or missing references) //IL_023b: Unknown result type (might be due to invalid IL or missing references) //IL_0240: Unknown result type (might be due to invalid IL or missing references) //IL_0253: Unknown result type (might be due to invalid IL or missing references) //IL_026e: Unknown result type (might be due to invalid IL or missing references) //IL_0279: Unknown result type (might be due to invalid IL or missing references) //IL_0293: Unknown result type (might be due to invalid IL or missing references) //IL_029d: Expected O, but got Unknown Lane lane = new Lane { Tier = tier }; Color val = ((tier < 0) ? Ui.Muted : PerkTiers.Colors[tier]); Image val2 = Ui.Card(parent, "Lane " + ((tier < 0) ? "unsorted" : PerkTiers.Names[tier]), Blend(Ui.RowBg, val, (tier < 0) ? 0f : 0.13f)); lane.Root = (RectTransform)((Transform)((Graphic)val2).rectTransform).parent; Transform val3 = ((Transform)lane.Root).Find("Edge"); lane.Edge = (((Object)(object)val3 != (Object)null) ? ((Component)val3).GetComponent<Image>() : null); lane.Size = Ui.Size(((Component)lane.Root).gameObject, -1f, 120f); Image obj = Ui.Img((Transform)(object)((Graphic)val2).rectTransform, "Stripe", val); ((Component)obj).gameObject.AddComponent<LayoutElement>().ignoreLayout = true; Ui.Anchor(((Graphic)obj).rectTransform, new Vector2(0f, 0f), new Vector2(0f, 1f), new Vector2(0f, 0.5f), new Vector2(14f, 0f), new Vector2(10f, -32f)); Ui.VGroup(((Component)val2).gameObject, 8f, new RectOffset(40, 20, 12, 14), (TextAnchor)0); lane.Head = Ui.Text((Transform)(object)((Graphic)val2).rectTransform, "", 27f, Ui.Dark, (TextAlignmentOptions)513); ((TMP_Text)lane.Head).richText = true; Ui.Size(((Component)lane.Head).gameObject, -1f, 36f); lane.Grid = Ui.Node("Cards", (Transform)(object)((Graphic)val2).rectTransform); GridLayoutGroup obj2 = ((Component)lane.Grid).gameObject.AddComponent<GridLayoutGroup>(); obj2.cellSize = new Vector2(268f, 58f); obj2.spacing = new Vector2(8f, 8f); obj2.constraint = (Constraint)1; obj2.constraintCount = 3; Button obj3 = ((Component)val2).gameObject.AddComponent<Button>(); ((Selectable)obj3).targetGraphic = (Graphic)(object)val2; ColorBlock colors = ((Selectable)obj3).colors; ((ColorBlock)(ref colors)).highlightedColor = new Color(1.03f, 1.03f, 1.03f); ((ColorBlock)(ref colors)).pressedColor = new Color(0.94f, 0.94f, 0.94f); ((Selectable)obj3).colors = colors; int target = tier; ((UnityEvent)obj3.onClick).AddListener((UnityAction)delegate { if (_picked != null && !_locked) { MoveTo(_picked, target); } }); _lanes.Add(lane); } private void AddChip(Lane lane, Entry e) { //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: Expected O, but got Unknown //IL_0121: Unknown result type (might be due to invalid IL or missing references) RectTransform val = Ui.Node("Card " + e.Title, (Transform)(object)lane.Grid); Color val2 = ((lane.Tier < 0) ? Ui.RowEdge : PerkTiers.Colors[lane.Tier]); bool flag = e.Key == _picked; Ui.Stretch(((Graphic)Ui.Img((Transform)(object)val, "Edge", flag ? Hot : val2, Ui.Round)).rectTransform); Image val3 = Ui.Img((Transform)(object)val, "Face", flag ? Blend(Ui.RowBg, Hot, 0.22f) : Ui.RowBg, Ui.Round, raycast: true); Ui.Stretch(((Graphic)val3).rectTransform, 3f, 3f, 3f, 3f); ((HorizontalOrVerticalLayoutGroup)Ui.HGroup(((Component)val3).gameObject, 10f, new RectOffset(10, 10, 4, 4), (TextAnchor)3)).childForceExpandHeight = false; Ui.SpriteIcon((Transform)(object)((Graphic)val3).rectTransform, e.Icon, 42f); TextMeshProUGUI obj = Ui.Text((Transform)(object)((Graphic)val3).rectTransform, e.Title, 24f, Ui.Dark, (TextAlignmentOptions)513); ((TMP_Text)obj).enableAutoSizing = true; ((TMP_Text)obj).fontSizeMin = 14f; ((TMP_Text)obj).fontSizeMax = 24f; Ui.Size(((Component)obj).gameObject, -1f, 46f, 1f, 0f); if (!_locked) { ((Component)val3).gameObject.AddComponent<ChipDrag>().Init(this, e, val, val3); } } public void Refresh() { foreach (Lane lane2 in _lanes) { Ui.Clear((Transform)(object)lane2.Grid); } int[] array = new int[_lanes.Count]; foreach (Entry entry in _entries) { int num = (PerkTiers.Sorted(entry.Key) ? PerkTiers.Of(entry.Key) : (-1)); if (num < -1 || num >= PerkTiers.Count) { num = -1; } AddChip(_lanes[num + 1], entry); array[num + 1]++; } double num2 = 0.0; double[] weights = PerkTiers.Weights; foreach (double num3 in weights) { num2 += num3; } for (int j = 0; j < _lanes.Count; j++) { Lane lane = _lanes[j]; string text = ((lane.Tier < 0) ? "UNSORTED" : PerkTiers.Names[lane.Tier].ToUpperInvariant()); string text2 = ((lane.Tier < 0) ? "dealt like Common" : ((num2 > 0.0) ? (Math.Round(PerkTiers.Weights[lane.Tier] / num2 * 100.0, 1).ToString("0.#", CultureInfo.InvariantCulture) + "% of deals") : "")); ((TMP_Text)lane.Head).text = text + " <size=75%><color=#756F75>" + text2 + " - " + array[j] + ((array[j] == 1) ? " card" : " cards") + "</color></size>"; int num4 = Math.Max(1, (array[j] + 3 - 1) / 3); lane.Size.preferredHeight = 56f + (float)num4 * 58f + (float)(num4 - 1) * 8f + 14f; } SetHot(-2); } public void Pick(string key) { if (!_locked) { _picked = ((_picked == key) ? null : key); Refresh(); } } private void MoveTo(string key, int tier) { int num = (PerkTiers.Sorted(key) ? PerkTiers.Of(key) : (-1)); _picked = null; if (num != tier) { PerkTiers.Set(key, tier); } Refresh(); } public bool PreviewDrag(string key, int tier) { //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Expected O, but got Unknown //IL_0111: Unknown result type (might be due to invalid IL or missing references) ChipDrag chipDrag = null; ChipDrag[] componentsInChildren = ((Component)((Transform)_lanes[0].Root).parent).GetComponentsInChildren<ChipDrag>(); foreach (ChipDrag chipDrag2 in componentsInChildren) { if (chipDrag2.Key == key) { chipDrag = chipDrag2; } } if ((Object)(object)chipDrag == (Object)null || (Object)(object)EventSystem.current == (Object)null || tier < -1 || tier + 1 >= _lanes.Count) { return false; } Canvas componentInParent = ((Component)chipDrag).GetComponentInParent<Canvas>(); Camera obj = (((Object)(object)componentInParent != (Object)null && (int)componentInParent.rootCanvas.renderMode != 0) ? componentInParent.rootCanvas.worldCamera : null); RectTransform root = _lanes[tier + 1].Root; Vector2 position = RectTransformUtility.WorldToScreenPoint(obj, ((Component)chipDrag).transform.position); Rect rect = root.rect; Vector2 position2 = RectTransformUtility.WorldToScreenPoint(obj, ((Transform)root).TransformPoint(Vector2.op_Implicit(((Rect)(ref rect)).center))); PointerEventData val = new PointerEventData(EventSystem.current) { position = position }; ExecuteEvents.Execute<IBeginDragHandler>(((Component)chipDrag).gameObject, (BaseEventData)(object)val, ExecuteEvents.beginDragHandler); val.position = position2; ExecuteEvents.Execute<IDragHandler>(((Component)chipDrag).gameObject, (BaseEventData)(object)val, ExecuteEvents.dragHandler); ExecuteEvents.Execute<IEndDragHandler>(((Component)chipDrag).gameObject, (BaseEventData)(object)val, ExecuteEvents.endDragHandler); return true; } public GameObject MakeGhost(RectTransform chip) { //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) GameObject val = Object.Instantiate<GameObject>(((Component)chip).gameObject, (Transform)(object)_dragLayer, false); ChipDrag[] componentsInChildren = val.GetComponentsInChildren<ChipDrag>(); for (int i = 0; i < componentsInChildren.Length; i++) { Object.Destroy((Object)(object)componentsInChildren[i]); } CanvasGroup obj = val.AddComponent<CanvasGroup>(); obj.blocksRaycasts = false; obj.alpha = 0.93f; RectTransform val2 = (RectTransform)val.transform; Vector2 val3 = default(Vector2); ((Vector2)(ref val3))..ctor(0.5f, 0.5f); val2.pivot = val3; Vector2 anchorMin = (val2.anchorMax = val3); val2.anchorMin = anchorMin; val2.sizeDelta = new Vector2(268f, 58f); ((Transform)val2).localScale = Vector3.one * 1.07f; ((Transform)val2).SetAsLastSibling(); return val; } public void MoveGhost(GameObject ghost, Vector2 screen, Camera cam) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) Vector3 position = default(Vector3); if (RectTransformUtility.ScreenPointToWorldPointInRectangle(_dragLayer, screen, cam, ref position)) { ghost.transform.position = position; } } private int LaneAt(Vector2 screen, Camera cam) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) if (!RectTransformUtility.RectangleContainsScreenPoint(_scroll.viewport, screen, cam)) { return -2; } for (int i = 0; i < _lanes.Count; i++) { if (RectTransformUtility.RectangleContainsScreenPoint(_lanes[i].Root, screen, cam)) { return _lanes[i].Tier; } } return -2; } private void SetHot(int tier) { //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) _hot = tier; foreach (Lane lane in _lanes) { if ((Object)(object)lane.Edge != (Object)null) { ((Graphic)lane.Edge).color = ((lane.Tier == tier) ? Hot : Ui.RowEdge); } } } public void Hover(Vector2 screen, Camera cam) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) int num = LaneAt(screen, cam); if (num != _hot) { SetHot(num); } } public void Drop(Entry e, Vector2 screen, Camera cam) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) int num = LaneAt(screen, cam); SetHot(-2); if (num != -2) { MoveTo(e.Key, num); } } public void AutoScroll(Vector2 screen, Camera cam) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) RectTransform viewport = _scroll.viewport; Vector2 val = default(Vector2); if ((Object)(object)viewport == (Object)null || !RectTransformUtility.ScreenPointToLocalPointInRectangle(viewport, screen, cam, ref val)) { return; } Rect rect = _scroll.content.rect; float height = ((Rect)(ref rect)).height; rect = viewport.rect; float num = height - ((Rect)(ref rect)).height; if (!(num <= 1f)) { float num2 = 0f; rect = viewport.rect; float num3 = ((Rect)(ref rect)).yMax - val.y; float y = val.y; rect = viewport.rect; float num4 = y - ((Rect)(ref rect)).yMin; if (num3 < 80f) { num2 = Mathf.Clamp01((80f - num3) / 80f); } else if (num4 < 80f) { num2 = 0f - Mathf.Clamp01((80f - nu