Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of ICanSeeClearlyNow v1.1.6
ICanSeeClearlyNow.dll
Decompiled 5 months agousing System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Text.RegularExpressions; using BepInEx; using BepInEx.Configuration; using ComfyLib; using HarmonyLib; using Microsoft.CodeAnalysis; using TMPro; using UnityEngine; using UnityEngine.EventSystems; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyTitle("ICanSeeClearlyNow")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("ICanSeeClearlyNow")] [assembly: AssemblyCopyright("Copyright © 2023")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("21625aa5-8c9a-4a27-8e03-027e4e3767ea")] [assembly: AssemblyFileVersion("1.1.6")] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.1.6.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace ICanSeeClearlyNow { [BepInPlugin("EardwulfC.valheim.ICanSeeClearlyNow", "ICanSeeClearlyNow", "1.1.6")] public sealed class ICanSeeClearlyNow : BaseUnityPlugin { public const string PluginGuid = "EardwulfC.valheim.ICanSeeClearlyNow"; public const string PluginName = "ICanSeeClearlyNow"; public const string PluginVersion = "1.1.6"; private Harmony _harmony; private void Awake() { PluginConfig.BindConfig(((BaseUnityPlugin)this).Config); _harmony = Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), "EardwulfC.valheim.ICanSeeClearlyNow"); } private void OnDestroy() { Harmony harmony = _harmony; if (harmony != null) { harmony.UnpatchSelf(); } } } public class PluginConfig { public static ConfigEntry<bool> IsModEnabled { get; private set; } public static ConfigEntry<float> GammaValue { get; private set; } public static ConfigEntry<bool> IsAshlandsAlwaysOn { get; private set; } public static ConfigEntry<bool> IsDeepNorthAlwaysOn { get; private set; } public static ConfigEntry<bool> IsCustomTimer { get; private set; } public static ConfigEntry<float> IsCustomNight { get; private set; } public static ConfigEntry<float> IsCustomDay { get; private set; } public static void BindConfig(ConfigFile Config) { IsModEnabled = Config.BindInOrder("_Global", "isModEnabled", defaultValue: true, "Globally enable or disable the mode."); GammaValue = Config.BindInOrder("Gamma Setting", "GammaValue", 0.6f, "Set your Gamma Value between 0.3 and 1.299", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.3f, 1.299f)); IsAshlandsAlwaysOn = Config.BindInOrder("Always On Options", "IsAshlandsAlwaysOn", defaultValue: false, "Always have Gamma Adjustment in the Ashlands."); IsDeepNorthAlwaysOn = Config.BindInOrder("Always On Options", "IsDeepNorthAlwaysOn", defaultValue: false, "Always have Gamma Adjustment in the Deep North."); IsCustomTimer = Config.BindInOrder("Custom Time", "IsCustomTimer", defaultValue: false, "Enable or Disable custom Night/Day Values"); IsCustomDay = Config.BindInOrder("Custom Time", "IsCustomDay", 6f, "Set a custom Start of Day value."); IsCustomNight = Config.BindInOrder("Custom Time", "IsCustomNight", 18f, "Set a custom Start of Night value."); } } [HarmonyPatch] public class AmbientLightPatch { private static Color originalColor; [HarmonyPrefix] [HarmonyPatch(typeof(RenderSettings), "set_ambientLight")] private static void SetLightPrefix(ref Color value) { //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0027: 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_0031: Unknown result type (might be due to invalid IL or missing references) if (PluginConfig.IsModEnabled.Value && !((Object)(object)EnvMan.instance == (Object)null)) { originalColor = value; value = LightenColor(value); } } [HarmonyPostfix] [HarmonyPatch(typeof(RenderSettings), "get_ambientLight")] private static void GetLight(ref Color __result) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) if (PluginConfig.IsModEnabled.Value) { __result = originalColor; } } private static Color LightenColor(Color sourceColor) { //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_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Invalid comparison between Unknown and I4 //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Invalid comparison between Unknown and I4 //IL_0125: 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) //IL_011e: Unknown result type (might be due to invalid IL or missing references) //IL_0123: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) float num = (sourceColor.r + sourceColor.g + sourceColor.b) / 3f; bool flag = (int)EnvMan.instance.GetBiome() == 32 && PluginConfig.IsAshlandsAlwaysOn.Value; bool flag2 = (int)EnvMan.instance.GetBiome() == 64 && PluginConfig.IsDeepNorthAlwaysOn.Value; if (PluginConfig.IsCustomTimer.Value) { float dayFraction = EnvMan.instance.GetDayFraction(); float num2 = PluginConfig.IsCustomNight.Value / 24f; float num3 = PluginConfig.IsCustomDay.Value / 24f; if ((dayFraction >= num2 && PluginConfig.IsCustomTimer.Value) || (dayFraction <= num3 && PluginConfig.IsCustomTimer.Value) || EnvMan.instance.GetCurrentEnvironment().m_alwaysDark || EnvMan.IsNight() || flag || flag2) { sourceColor *= PluginConfig.GammaValue.Value / num; } } if (!PluginConfig.IsCustomTimer.Value && (EnvMan.IsNight() || EnvMan.instance.GetCurrentEnvironment().m_alwaysDark || flag || flag2)) { sourceColor *= PluginConfig.GammaValue.Value / num; } return sourceColor; } } } namespace ComfyLib { public sealed class ComfyArgs { public static readonly Regex CommandRegex = new Regex("^(?<command>\\w[\\w-]*)(?:\\s+--(?:(?<arg>\\w[\\w-]*)=(?:\"(?<value>[^\"]*?)\"|(?<value>\\S+))|no(?<argfalse>\\w[\\w-]*)|(?<argtrue>\\w[\\w-]*)))*"); public static readonly char[] CommaSeparator = new char[1] { ',' }; public readonly Dictionary<string, string> ArgsValueByName = new Dictionary<string, string>(); public ConsoleEventArgs Args { get; } public string Command { get; private set; } public ComfyArgs(ConsoleEventArgs args) { Args = args; ParseArgs(Args); } private void ParseArgs(ConsoleEventArgs args) { Match match = CommandRegex.Match(args.FullLine); Command = match.Groups["command"].Value; foreach (Capture capture3 in match.Groups["argtrue"].Captures) { ArgsValueByName[capture3.Value] = "true"; } foreach (Capture capture4 in match.Groups["argfalse"].Captures) { ArgsValueByName[capture4.Value] = "false"; } CaptureCollection captures = match.Groups["arg"].Captures; CaptureCollection captures2 = match.Groups["value"].Captures; for (int i = 0; i < captures.Count; i++) { ArgsValueByName[captures[i].Value] = ((i < captures2.Count) ? captures2[i].Value : string.Empty); } } public bool TryGetValue(string argName, out string argValue) { return ArgsValueByName.TryGetValue(argName, out argValue); } public bool TryGetValue(string argName, string argShortName, out string argValue) { if (!ArgsValueByName.TryGetValue(argName, out argValue)) { return ArgsValueByName.TryGetValue(argShortName, out argValue); } return true; } public bool TryGetValue<T>(string argName, out T argValue) { argValue = default(T); if (TryGetValue(argName, out var argValue2)) { return TryConvertValue<T>(argValue2, out argValue); } return false; } public bool TryGetValue<T>(string argName, string argShortName, out T argValue) { argValue = default(T); if (TryGetValue(argName, argShortName, out var argValue2)) { return TryConvertValue<T>(argValue2, out argValue); } return false; } public bool TryGetListValue<T>(string argName, string argShortName, out List<T> argListValue) { if (!TryGetValue(argName, argShortName, out var argValue)) { argListValue = null; return false; } string[] array = argValue.Split(CommaSeparator, StringSplitOptions.RemoveEmptyEntries); argListValue = new List<T>(array.Length); for (int i = 0; i < array.Length; i++) { if (!TryConvertValue<T>(array[i], out var argValue2)) { return false; } argListValue.Add(argValue2); } return true; } public static bool TryConvertValue<T>(string argStringValue, out T argValue) { //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) try { Vector2 value; Vector3 value2; ZDOID value3; if (typeof(T) == typeof(string)) { argValue = (T)(object)argStringValue; } else if (typeof(T) == typeof(Vector2) && argStringValue.TryParseVector2(out value)) { argValue = (T)(object)value; } else if (typeof(T) == typeof(Vector3) && argStringValue.TryParseVector3(out value2)) { argValue = (T)(object)value2; } else if (typeof(T) == typeof(ZDOID) && argStringValue.TryParseZDOID(out value3)) { argValue = (T)(object)value3; } else { argValue = (T)Convert.ChangeType(argStringValue, typeof(T)); } return true; } catch (Exception arg) { Debug.LogError((object)$"Failed to convert value '{argStringValue}' to type {typeof(T)}: {arg}"); } argValue = default(T); return false; } } [AttributeUsage(AttributeTargets.Method)] public sealed class ComfyCommand : Attribute { } public static class ComfyCommandUtils { [CompilerGenerated] private sealed class <RegisterCommands>d__5 : IEnumerable<ConsoleCommand>, IEnumerable, IEnumerator<ConsoleCommand>, IDisposable, IEnumerator { private int <>1__state; private ConsoleCommand <>2__current; private int <>l__initialThreadId; private MethodInfo method; public MethodInfo <>3__method; private IEnumerator<ConsoleCommand> <>7__wrap1; ConsoleCommand IEnumerator<ConsoleCommand>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <RegisterCommands>d__5(int <>1__state) { this.<>1__state = <>1__state; <>l__initialThreadId = Environment.CurrentManagedThreadId; } [DebuggerHidden] void IDisposable.Dispose() { int num = <>1__state; if (num == -3 || num == 2) { try { } finally { <>m__Finally1(); } } <>7__wrap1 = null; <>1__state = -2; } private bool MoveNext() { //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Expected O, but got Unknown try { switch (<>1__state) { default: return false; case 0: <>1__state = -1; if (IsRegisterCommandMethod(method)) { <>2__current = (ConsoleCommand)method.Invoke(null, null); <>1__state = 1; return true; } if (!IsRegisterCommandsMethod(method)) { break; } <>7__wrap1 = ((IEnumerable<ConsoleCommand>)method.Invoke(null, null)).GetEnumerator(); <>1__state = -3; goto IL_00bd; case 1: <>1__state = -1; break; case 2: { <>1__state = -3; goto IL_00bd; } IL_00bd: if (<>7__wrap1.MoveNext()) { ConsoleCommand current = <>7__wrap1.Current; <>2__current = current; <>1__state = 2; return true; } <>m__Finally1(); <>7__wrap1 = null; break; } return false; } catch { //try-fault ((IDisposable)this).Dispose(); throw; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } private void <>m__Finally1() { <>1__state = -1; if (<>7__wrap1 != null) { <>7__wrap1.Dispose(); } } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } [DebuggerHidden] IEnumerator<ConsoleCommand> IEnumerable<ConsoleCommand>.GetEnumerator() { <RegisterCommands>d__5 <RegisterCommands>d__; if (<>1__state == -2 && <>l__initialThreadId == Environment.CurrentManagedThreadId) { <>1__state = 0; <RegisterCommands>d__ = this; } else { <RegisterCommands>d__ = new <RegisterCommands>d__5(0); } <RegisterCommands>d__.method = <>3__method; return <RegisterCommands>d__; } [DebuggerHidden] IEnumerator IEnumerable.GetEnumerator() { return ((IEnumerable<ConsoleCommand>)this).GetEnumerator(); } } private static readonly List<ConsoleCommand> _commands = new List<ConsoleCommand>(); public static void ToggleCommands(bool toggleOn) { DeregisterCommands(_commands); _commands.Clear(); if (toggleOn) { _commands.AddRange(RegisterCommands(Assembly.GetExecutingAssembly())); } UpdateCommandLists(); } private static void UpdateCommandLists() { Terminal[] array = Object.FindObjectsOfType<Terminal>(true); for (int i = 0; i < array.Length; i++) { array[i].updateCommandList(); } } private static void DeregisterCommands(List<ConsoleCommand> commands) { foreach (ConsoleCommand command in commands) { if (Terminal.commands[command.Command] == command) { Terminal.commands.Remove(command.Command); } } } private static IEnumerable<ConsoleCommand> RegisterCommands(Assembly assembly) { return (from method in assembly.GetTypes().SelectMany((Type type) => type.GetMethods(BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic)) where method.GetCustomAttributes(typeof(ComfyCommand), inherit: false).Length != 0 select method).SelectMany(RegisterCommands); } [IteratorStateMachine(typeof(<RegisterCommands>d__5))] private static IEnumerable<ConsoleCommand> RegisterCommands(MethodInfo method) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <RegisterCommands>d__5(-2) { <>3__method = method }; } private static bool IsRegisterCommandMethod(MethodInfo method) { if (method.GetParameters().Length == 0) { return typeof(ConsoleCommand).IsAssignableFrom(method.ReturnType); } return false; } private static bool IsRegisterCommandsMethod(MethodInfo method) { if (method.GetParameters().Length == 0) { return typeof(IEnumerable<ConsoleCommand>).IsAssignableFrom(method.ReturnType); } return false; } } public static class ConfigFileExtensions { internal sealed class ConfigurationManagerAttributes { public Action<ConfigEntryBase> CustomDrawer; public bool? Browsable; public bool? HideDefaultButton; public int? Order; } private static readonly Dictionary<string, int> _sectionToSettingOrder = new Dictionary<string, int>(); public static readonly char[] CommaSeparator = new char[1] { ',' }; private static int GetSettingOrder(string section) { if (!_sectionToSettingOrder.TryGetValue(section, out var value)) { value = 0; } _sectionToSettingOrder[section] = value - 1; return value; } public static ConfigEntry<T> BindInOrder<T>(this ConfigFile config, string section, string key, T defaultValue, string description, AcceptableValueBase acceptableValues) { //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Expected O, but got Unknown return config.Bind<T>(section, key, defaultValue, new ConfigDescription(description, acceptableValues, new object[1] { new ConfigurationManagerAttributes { Order = GetSettingOrder(section) } })); } public static ConfigEntry<T> BindInOrder<T>(this ConfigFile config, string section, string key, T defaultValue, string description, Action<ConfigEntryBase> customDrawer = null, bool browsable = true, bool hideDefaultButton = false, bool hideSettingName = false) { //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Expected O, but got Unknown return config.Bind<T>(section, key, defaultValue, new ConfigDescription(description, (AcceptableValueBase)null, new object[1] { new ConfigurationManagerAttributes { Browsable = browsable, CustomDrawer = customDrawer, HideDefaultButton = hideDefaultButton, Order = GetSettingOrder(section) } })); } public static void OnSettingChanged<T>(this ConfigEntry<T> configEntry, Action settingChangedHandler) { configEntry.SettingChanged += delegate { settingChangedHandler(); }; } public static void OnSettingChanged<T>(this ConfigEntry<T> configEntry, Action<T> settingChangedHandler) { configEntry.SettingChanged += delegate(object _, EventArgs eventArgs) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) settingChangedHandler((T)((SettingChangedEventArgs)eventArgs).ChangedSetting.BoxedValue); }; } public static void OnSettingChanged<T>(this ConfigEntry<T> configEntry, Action<ConfigEntry<T>> settingChangedHandler) { configEntry.SettingChanged += delegate(object _, EventArgs eventArgs) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) settingChangedHandler((ConfigEntry<T>)((SettingChangedEventArgs)eventArgs).ChangedSetting.BoxedValue); }; } public static string[] StringValues(this ConfigEntry<string> configEntry) { return configEntry.Value.Split(CommaSeparator, StringSplitOptions.RemoveEmptyEntries); } } public static class StringExtensions { public static readonly char[] CommaSeparator = new char[1] { ',' }; public static readonly char[] ColonSeparator = new char[1] { ':' }; public static bool TryParseVector2(this string text, out Vector2 value) { //IL_0050: 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_0048: Unknown result type (might be due to invalid IL or missing references) string[] array = text.Split(CommaSeparator, 2, StringSplitOptions.RemoveEmptyEntries); if (array.Length == 2 && float.TryParse(array[0], NumberStyles.Float, CultureInfo.InvariantCulture, out var result) && float.TryParse(array[1], NumberStyles.Float, CultureInfo.InvariantCulture, out var result2)) { value = new Vector2(result, result2); return true; } value = default(Vector2); return false; } public static bool TryParseVector3(this string text, out Vector3 value) { //IL_0067: 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_005f: Unknown result type (might be due to invalid IL or missing references) string[] array = text.Split(CommaSeparator, 3, StringSplitOptions.RemoveEmptyEntries); if (array.Length == 3 && float.TryParse(array[0], NumberStyles.Float, CultureInfo.InvariantCulture, out var result) && float.TryParse(array[1], NumberStyles.Float, CultureInfo.InvariantCulture, out var result2) && float.TryParse(array[2], NumberStyles.Float, CultureInfo.InvariantCulture, out var result3)) { value = new Vector3(result, result2, result3); return true; } value = default(Vector3); return false; } public static bool TryParseZDOID(this string text, out ZDOID value) { //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) string[] array = text.Split(ColonSeparator, 2, StringSplitOptions.RemoveEmptyEntries); if (array.Length == 2 && long.TryParse(array[0], NumberStyles.Integer, CultureInfo.InvariantCulture, out var result) && uint.TryParse(array[1], NumberStyles.Integer, CultureInfo.InvariantCulture, out var result2)) { value = new ZDOID(result, result2); return true; } value = default(ZDOID); return false; } } public static class ChatExtensions { public static void AddMessage(this Chat chat, object obj) { if (Object.op_Implicit((Object)(object)chat)) { ((Terminal)chat).AddString($"{obj}"); chat.m_hideTimer = 0f; } } } public static class ComponentExtensions { public static T GetOrAddComponent<T>(this Component component) where T : Component { T result = default(T); if (!component.TryGetComponent<T>(ref result)) { return component.gameObject.AddComponent<T>(); } return result; } public static T GetOrAddComponent<T>(this Component component, out T otherComponent) where T : Component { if (!component.TryGetComponent<T>(ref otherComponent)) { otherComponent = component.gameObject.AddComponent<T>(); } return otherComponent; } } public static class UnityExtensions { public static T Ref<T>(this T unityObject) where T : Object { if (!Object.op_Implicit((Object)(object)unityObject)) { return default(T); } return unityObject; } public static T SetName<T>(this T component, string name) where T : Component { ((Object)(object)component).name = name; return component; } } public sealed class PanelDragger : MonoBehaviour, IBeginDragHandler, IEventSystemHandler, IDragHandler, IEndDragHandler { private RectTransform _rectTransform; private Vector2 _lastMousePosition; public EventHandler<Vector2> OnEndDragEvent; private void Awake() { _rectTransform = ((Component)this).GetComponent<RectTransform>(); } public void OnBeginDrag(PointerEventData eventData) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) _lastMousePosition = eventData.position; } public void OnDrag(PointerEventData eventData) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: 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_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001e: 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_002f: 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) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) Vector2 val = eventData.position - _lastMousePosition; RectTransform rectTransform = _rectTransform; ((Transform)rectTransform).position = ((Transform)rectTransform).position + new Vector3(val.x, val.y, 0f); _lastMousePosition = eventData.position; } public void OnEndDrag(PointerEventData eventData) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) OnEndDragEvent?.Invoke(this, _rectTransform.anchoredPosition); } } public static class UIBuilder { public static readonly ColorBlock ScrollbarColors; public static TextMeshProUGUI CreateTMPLabel(Transform parentTransform) { //IL_002f: Unknown result type (might be due to invalid IL or missing references) TextMeshProUGUI obj = Object.Instantiate<TextMeshProUGUI>(UnifiedPopup.instance.bodyText, parentTransform, false); ((Object)obj).name = "Label"; ((TMP_Text)obj).fontSize = 16f; ((TMP_Text)obj).richText = true; ((Graphic)obj).color = Color.white; ((TMP_Text)obj).enableAutoSizing = false; ((TMP_Text)obj).textWrappingMode = (TextWrappingModes)0; ((TMP_Text)obj).overflowMode = (TextOverflowModes)0; ((TMP_Text)obj).text = string.Empty; return obj; } public static TextMeshProUGUI CreateTMPHeaderLabel(Transform parentTransform) { TextMeshProUGUI obj = Object.Instantiate<TextMeshProUGUI>(UnifiedPopup.instance.headerText, parentTransform, false); ((Object)obj).name = "Label"; ((TMP_Text)obj).fontSize = 32f; ((TMP_Text)obj).richText = true; ((TMP_Text)obj).enableAutoSizing = false; ((TMP_Text)obj).textWrappingMode = (TextWrappingModes)0; ((TMP_Text)obj).overflowMode = (TextOverflowModes)0; ((TMP_Text)obj).text = string.Empty; return obj; } public static GameObject CreatePanel(Transform parentTransform) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_002a: 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) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Expected O, but got Unknown GameObject val = new GameObject("Panel", new Type[1] { typeof(RectTransform) }); val.transform.SetParent(parentTransform, false); val.GetComponent<RectTransform>().SetAnchorMin(new Vector2(0.5f, 0.5f)).SetAnchorMax(new Vector2(0.5f, 0.5f)) .SetPivot(new Vector2(0.5f, 0.5f)) .SetPosition(Vector2.zero) .SetSizeDelta(new Vector2(275f, 350f)); val.AddComponent<Image>().SetType((Type)1).SetSprite(UIResources.GetSprite("woodpanel_trophys")) .SetColor(Color.white); return val; } public static Scrollbar CreateScrollbar(Transform parentTransform) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Expected O, but got Unknown //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0063: 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_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Expected O, but got Unknown //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00da: 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_00f8: 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_0125: Unknown result type (might be due to invalid IL or missing references) //IL_012a: 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_014c: Unknown result type (might be due to invalid IL or missing references) //IL_0160: Unknown result type (might be due to invalid IL or missing references) //IL_0174: Unknown result type (might be due to invalid IL or missing references) //IL_017e: Unknown result type (might be due to invalid IL or missing references) //IL_0188: 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_01d4: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("Scrollbar", new Type[1] { typeof(RectTransform) }); val.transform.SetParent(parentTransform, false); val.GetComponent<RectTransform>().SetAnchorMin(Vector2.right).SetAnchorMax(Vector2.one) .SetPivot(Vector2.one) .SetPosition(Vector2.zero) .SetSizeDelta(new Vector2(10f, 0f)); val.AddComponent<Image>().SetType((Type)1).SetSprite(UIResources.GetSprite("Background")) .SetColor(Color.black) .SetRaycastTarget(raycastTarget: true); GameObject val2 = new GameObject("SlidingArea", new Type[1] { typeof(RectTransform) }); val2.transform.SetParent(val.transform, false); val2.GetComponent<RectTransform>().SetAnchorMin(Vector2.zero).SetAnchorMax(Vector2.one) .SetPivot(new Vector2(0.5f, 0.5f)) .SetPosition(Vector2.zero) .SetSizeDelta(Vector2.zero); GameObject val3 = new GameObject("Handle", new Type[1] { typeof(RectTransform) }); val3.transform.SetParent(val2.transform, false); RectTransform handleRect = val3.GetComponent<RectTransform>().SetAnchorMin(new Vector2(0.5f, 0.5f)).SetAnchorMax(new Vector2(0.5f, 0.5f)) .SetPivot(new Vector2(0.5f, 0.5f)) .SetPosition(Vector2.zero) .SetSizeDelta(Vector2.zero); Image graphic = val3.AddComponent<Image>().SetType((Type)1).SetSprite(UIResources.GetSprite("UISprite")) .SetColor(Color.white) .SetPixelsPerUnitMultiplier(0.7f); return val.AddComponent<Scrollbar>().SetTargetGraphic<Scrollbar>((Graphic)(object)graphic).SetTransition<Scrollbar>((Transition)1) .SetColors<Scrollbar>(ScrollbarColors) .SetDirection<Scrollbar>((Direction)3) .SetHandleRect<Scrollbar>(handleRect); } static UIBuilder() { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0040: 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_0067: 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_008a: Unknown result type (might be due to invalid IL or missing references) ColorBlock scrollbarColors = default(ColorBlock); ((ColorBlock)(ref scrollbarColors)).normalColor = Color.white; ((ColorBlock)(ref scrollbarColors)).highlightedColor = new Color(1f, 0.75f, 0f); ((ColorBlock)(ref scrollbarColors)).selectedColor = new Color(1f, 0.75f, 0f); ((ColorBlock)(ref scrollbarColors)).pressedColor = new Color(1f, 0.67f, 0.11f); ((ColorBlock)(ref scrollbarColors)).disabledColor = Color.gray; ((ColorBlock)(ref scrollbarColors)).colorMultiplier = 1f; ((ColorBlock)(ref scrollbarColors)).fadeDuration = 0.15f; ScrollbarColors = scrollbarColors; } } public static class CanvasGroupExtensions { public static CanvasGroup SetAlpha(this CanvasGroup canvasGroup, float alpha) { canvasGroup.alpha = alpha; return canvasGroup; } public static CanvasGroup SetBlocksRaycasts(this CanvasGroup canvasGroup, bool blocksRaycasts) { canvasGroup.blocksRaycasts = blocksRaycasts; return canvasGroup; } } public static class ColorExtensions { public static Color SetAlpha(this Color color, float alpha) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) color.a = alpha; return color; } } public static class ContentSizeFitterExtensions { public static ContentSizeFitter SetHorizontalFit(this ContentSizeFitter fitter, FitMode fitMode) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) fitter.horizontalFit = fitMode; return fitter; } public static ContentSizeFitter SetVerticalFit(this ContentSizeFitter fitter, FitMode fitMode) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) fitter.verticalFit = fitMode; return fitter; } } public static class LayoutGroupExtensions { public static T SetChildControl<T>(this T layoutGroup, bool? width = null, bool? height = null) where T : HorizontalOrVerticalLayoutGroup { if (!width.HasValue && !height.HasValue) { throw new ArgumentException("Value for width or height must be provided."); } if (width.HasValue) { ((HorizontalOrVerticalLayoutGroup)layoutGroup).childControlWidth = width.Value; } if (height.HasValue) { ((HorizontalOrVerticalLayoutGroup)layoutGroup).childControlHeight = height.Value; } return layoutGroup; } public static T SetChildForceExpand<T>(this T layoutGroup, bool? width = null, bool? height = null) where T : HorizontalOrVerticalLayoutGroup { if (!width.HasValue && !height.HasValue) { throw new ArgumentException("Value for width or height must be provided."); } if (width.HasValue) { ((HorizontalOrVerticalLayoutGroup)layoutGroup).childForceExpandWidth = width.Value; } if (height.HasValue) { ((HorizontalOrVerticalLayoutGroup)layoutGroup).childForceExpandHeight = height.Value; } return layoutGroup; } public static T SetChildAlignment<T>(this T layoutGroup, TextAnchor alignment) where T : HorizontalOrVerticalLayoutGroup { //IL_0006: Unknown result type (might be due to invalid IL or missing references) ((LayoutGroup)(object)layoutGroup).childAlignment = alignment; return layoutGroup; } public static T SetPadding<T>(this T layoutGroup, int? left = null, int? right = null, int? top = null, int? bottom = null) where T : HorizontalOrVerticalLayoutGroup { if (!left.HasValue && !right.HasValue && !top.HasValue && !bottom.HasValue) { throw new ArgumentException("Value for left, right, top or bottom must be provided."); } if (left.HasValue) { ((LayoutGroup)(object)layoutGroup).padding.left = left.Value; } if (right.HasValue) { ((LayoutGroup)(object)layoutGroup).padding.right = right.Value; } if (top.HasValue) { ((LayoutGroup)(object)layoutGroup).padding.top = top.Value; } if (bottom.HasValue) { ((LayoutGroup)(object)layoutGroup).padding.bottom = bottom.Value; } return layoutGroup; } public static T SetSpacing<T>(this T layoutGroup, float spacing) where T : HorizontalOrVerticalLayoutGroup { ((HorizontalOrVerticalLayoutGroup)layoutGroup).spacing = spacing; return layoutGroup; } } public static class ImageExtensions { public static Image SetColor(this Image image, Color color) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) ((Graphic)image).color = color; return image; } public static Image SetFillAmount(this Image image, float amount) { image.fillAmount = amount; return image; } public static Image SetFillCenter(this Image image, bool fillCenter) { image.fillCenter = fillCenter; return image; } public static Image SetFillMethod(this Image image, FillMethod fillMethod) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) image.fillMethod = fillMethod; return image; } public static Image SetFillOrigin(this Image image, OriginHorizontal origin) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected I4, but got Unknown image.fillOrigin = (int)origin; return image; } public static Image SetFillOrigin(this Image image, OriginVertical origin) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected I4, but got Unknown image.fillOrigin = (int)origin; return image; } public static Image SetMaskable(this Image image, bool maskable) { ((MaskableGraphic)image).maskable = maskable; return image; } public static Image SetMaterial(this Image image, Material material) { ((Graphic)image).material = material; return image; } public static Image SetPixelsPerUnitMultiplier(this Image image, float pixelsPerUnitMultiplier) { image.pixelsPerUnitMultiplier = pixelsPerUnitMultiplier; return image; } public static Image SetPreserveAspect(this Image image, bool preserveAspect) { image.preserveAspect = preserveAspect; return image; } public static Image SetRaycastTarget(this Image image, bool raycastTarget) { ((Graphic)image).raycastTarget = raycastTarget; return image; } public static Image SetSprite(this Image image, Sprite sprite) { image.sprite = sprite; return image; } public static Image SetType(this Image image, Type type) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) image.type = type; return image; } } public static class LayoutElementExtensions { public static LayoutElement SetPreferred(this LayoutElement layoutElement, float? width = null, float? height = null) { if (!width.HasValue && !height.HasValue) { throw new ArgumentException("Value for width or height must be provided."); } if (width.HasValue) { layoutElement.preferredWidth = width.Value; } if (height.HasValue) { layoutElement.preferredHeight = height.Value; } return layoutElement; } public static LayoutElement SetFlexible(this LayoutElement layoutElement, float? width = null, float? height = null) { if (!width.HasValue && !height.HasValue) { throw new ArgumentException("Value for width or height must be provided."); } if (width.HasValue) { layoutElement.flexibleWidth = width.Value; } if (height.HasValue) { layoutElement.flexibleHeight = height.Value; } return layoutElement; } public static LayoutElement SetMinimum(this LayoutElement layoutElement, float? width = null, float? height = null) { if (!width.HasValue && !height.HasValue) { throw new ArgumentException("Value for width or height must be provided."); } if (width.HasValue) { layoutElement.minWidth = width.Value; } if (height.HasValue) { layoutElement.minHeight = height.Value; } return layoutElement; } public static LayoutElement SetIgnoreLayout(this LayoutElement layoutElement, bool ignoreLayout) { layoutElement.ignoreLayout = ignoreLayout; return layoutElement; } } public static class MaskExtensions { public static Mask SetShowMaskGraphic(this Mask mask, bool showMaskGraphic) { mask.showMaskGraphic = showMaskGraphic; return mask; } } public static class RectMask2DExtensions { public static RectMask2D SetSoftness(this RectMask2D rectMask2d, Vector2Int softness) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) rectMask2d.softness = softness; return rectMask2d; } } public static class RectTransformExtensions { public static RectTransform SetAnchorMin(this RectTransform rectTransform, Vector2 anchorMin) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) rectTransform.anchorMin = anchorMin; return rectTransform; } public static RectTransform SetAnchorMax(this RectTransform rectTransform, Vector2 anchorMax) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) rectTransform.anchorMax = anchorMax; return rectTransform; } public static RectTransform SetPivot(this RectTransform rectTransform, Vector2 pivot) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) rectTransform.pivot = pivot; return rectTransform; } public static RectTransform SetPosition(this RectTransform rectTransform, Vector2 position) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) rectTransform.anchoredPosition = position; return rectTransform; } public static RectTransform SetSizeDelta(this RectTransform rectTransform, Vector2 sizeDelta) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) rectTransform.sizeDelta = sizeDelta; return rectTransform; } } public static class ScrollbarExtensions { public static T SetDirection<T>(this T scrollbar, Direction direction) where T : Scrollbar { //IL_0006: Unknown result type (might be due to invalid IL or missing references) ((Scrollbar)scrollbar).direction = direction; return scrollbar; } public static T SetHandleRect<T>(this T scrollbar, RectTransform handleRect) where T : Scrollbar { ((Scrollbar)scrollbar).handleRect = handleRect; return scrollbar; } } public static class SelectableExtensions { public static T SetColors<T>(this T selectable, ColorBlock colors) where T : Selectable { //IL_0006: Unknown result type (might be due to invalid IL or missing references) ((Selectable)selectable).colors = colors; return selectable; } public static T SetImage<T>(this T selectable, Image image) where T : Selectable { ((Selectable)selectable).image = image; return selectable; } public static T SetInteractable<T>(this T selectable, bool interactable) where T : Selectable { ((Selectable)selectable).interactable = interactable; return selectable; } public static T SetSpriteState<T>(this T selectable, SpriteState spriteState) where T : Selectable { //IL_0006: Unknown result type (might be due to invalid IL or missing references) ((Selectable)selectable).spriteState = spriteState; return selectable; } public static T SetTargetGraphic<T>(this T selectable, Graphic graphic) where T : Selectable { ((Selectable)selectable).targetGraphic = graphic; return selectable; } public static T SetTransition<T>(this T selectable, Transition transition) where T : Selectable { //IL_0006: Unknown result type (might be due to invalid IL or missing references) ((Selectable)selectable).transition = transition; return selectable; } public static T SetNavigationMode<T>(this T selectable, Mode mode) where T : Selectable { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: 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_001a: Unknown result type (might be due to invalid IL or missing references) Navigation navigation = ((Selectable)selectable).navigation; ((Navigation)(ref navigation)).mode = mode; ((Selectable)selectable).navigation = navigation; return selectable; } } public static class ScrollRectExtensions { public static T SetScrollSensitivity<T>(this T scrollRect, float sensitivity) where T : ScrollRect { ((ScrollRect)scrollRect).scrollSensitivity = sensitivity; return scrollRect; } public static T SetVerticalScrollbar<T>(this T scrollRect, Scrollbar verticalScrollbar) where T : ScrollRect { ((ScrollRect)scrollRect).verticalScrollbar = verticalScrollbar; return scrollRect; } public static T SetVerticalScrollPosition<T>(this T scrollRect, float position) where T : ScrollRect { ((ScrollRect)scrollRect).verticalNormalizedPosition = position; return scrollRect; } public static T SetViewport<T>(this T scrollRect, RectTransform viewport) where T : ScrollRect { ((ScrollRect)scrollRect).viewport = viewport; return scrollRect; } public static T SetContent<T>(this T scrollRect, RectTransform content) where T : ScrollRect { ((ScrollRect)scrollRect).content = content; return scrollRect; } public static T SetHorizontal<T>(this T scrollRect, bool horizontal) where T : ScrollRect { ((ScrollRect)scrollRect).horizontal = horizontal; return scrollRect; } public static T SetVertical<T>(this T scrollRect, bool vertical) where T : ScrollRect { ((ScrollRect)scrollRect).vertical = vertical; return scrollRect; } public static T SetMovementType<T>(this T scrollRect, MovementType movementType) where T : ScrollRect { //IL_0006: Unknown result type (might be due to invalid IL or missing references) ((ScrollRect)scrollRect).movementType = movementType; return scrollRect; } } public static class TextMeshProExtensions { public static T SetAlignment<T>(this T tmpText, TextAlignmentOptions alignment) where T : TMP_Text { //IL_0006: Unknown result type (might be due to invalid IL or missing references) ((TMP_Text)tmpText).alignment = alignment; return tmpText; } public static T SetColor<T>(this T tmpText, Color color) where T : TMP_Text { //IL_0006: Unknown result type (might be due to invalid IL or missing references) ((Graphic)(object)tmpText).color = color; return tmpText; } public static T SetEnableAutoSizing<T>(this T tmpText, bool enableAutoSizing) where T : TMP_Text { ((TMP_Text)tmpText).enableAutoSizing = enableAutoSizing; return tmpText; } public static T SetFont<T>(this T tmpText, TMP_FontAsset font) where T : TMP_Text { ((TMP_Text)tmpText).font = font; return tmpText; } public static T SetFontSize<T>(this T tmpText, float fontSize) where T : TMP_Text { ((TMP_Text)tmpText).fontSize = fontSize; return tmpText; } public static T SetFontMaterial<T>(this T tmpText, Material fontMaterial) where T : TMP_Text { ((TMP_Text)tmpText).fontMaterial = fontMaterial; return tmpText; } public static T SetMargin<T>(this T tmpText, Vector4 margin) where T : TMP_Text { //IL_0006: Unknown result type (might be due to invalid IL or missing references) ((TMP_Text)tmpText).margin = margin; return tmpText; } public static T SetOutlineColorProperty<T>(this T tmpText, Color color) where T : TMP_Text { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) ((TMP_Text)tmpText).outlineColor = Color32.op_Implicit(color); return tmpText; } public static T SetOutlineWidth<T>(this T tmpText, float outlineWidth) where T : TMP_Text { ((TMP_Text)tmpText).outlineWidth = outlineWidth; return tmpText; } public static T SetOverflowMode<T>(this T tmpText, TextOverflowModes overflowMode) where T : TMP_Text { //IL_0006: Unknown result type (might be due to invalid IL or missing references) ((TMP_Text)tmpText).overflowMode = overflowMode; return tmpText; } public static T SetRichText<T>(this T tmpText, bool richText) where T : TMP_Text { ((TMP_Text)tmpText).richText = richText; return tmpText; } public static T SetTextWrappingMode<T>(this T tmpText, TextWrappingModes textWrappingMode) where T : TMP_Text { //IL_0006: Unknown result type (might be due to invalid IL or missing references) ((TMP_Text)tmpText).textWrappingMode = textWrappingMode; return tmpText; } } public static class Texture2DExtensions { public static Texture2D SetName(this Texture2D texture, string name) { ((Object)texture).name = name; return texture; } public static Texture2D SetWrapMode(this Texture2D texture, TextureWrapMode wrapMode) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) ((Texture)texture).wrapMode = wrapMode; return texture; } public static Texture2D SetFilterMode(this Texture2D texture, FilterMode filterMode) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) ((Texture)texture).filterMode = filterMode; return texture; } } public static class ToggleExtensions { public static T SetGraphic<T>(this T toggle, Graphic graphic) where T : Toggle { ((Toggle)toggle).graphic = graphic; return toggle; } public static T SetToggleTransition<T>(this T toggle, ToggleTransition toggleTransition) where T : Toggle { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) ((Toggle)toggle).toggleTransition = toggleTransition; return toggle; } } public static class UIResources { public static readonly Dictionary<string, Sprite> SpriteCache = new Dictionary<string, Sprite>(); public static readonly Dictionary<string, Material> MaterialCache = new Dictionary<string, Material>(); public static readonly Resources DefaultControlResources = new Resources { standard = GetSprite("UISprite"), background = GetSprite("Background"), inputField = GetSprite("InputFieldBackground"), knob = GetSprite("Knob"), checkmark = GetSprite("Checkmark"), dropdown = GetSprite("DropdownArrow"), mask = GetSprite("UIMask") }; public static readonly Resources TMPDefaultControlResources = new Resources { standard = GetSprite("UISprite"), background = GetSprite("Background"), inputField = GetSprite("InputFieldBackground"), knob = GetSprite("Knob"), checkmark = GetSprite("Checkmark"), dropdown = GetSprite("DropdownArrow"), mask = GetSprite("UIMask") }; public static Sprite GetSprite(string spriteName) { if (!SpriteCache.TryGetValue(spriteName, out var value)) { value = ((IEnumerable<Sprite>)Resources.FindObjectsOfTypeAll<Sprite>()).FirstOrDefault((Func<Sprite, bool>)((Sprite s) => ((Object)s).name == spriteName)); SpriteCache[spriteName] = value; } return value; } public static Material GetMaterial(string materialName) { if (!MaterialCache.TryGetValue(materialName, out var value)) { value = ((IEnumerable<Material>)Resources.FindObjectsOfTypeAll<Material>()).FirstOrDefault((Func<Material, bool>)((Material m) => ((Object)m).name == materialName)); MaterialCache[materialName] = value; } return value; } } }