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 REPONativeUltrawide v1.1.0
plugins/com.github.NEDOSTUPN0.REPONativeUltrawide.dll
Decompiled 2 hours agousing System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Text; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using UnityEngine; using UnityEngine.Rendering; using UnityEngine.Rendering.PostProcessing; using UnityEngine.SceneManagement; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("NEDOSTUPN0")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.1.0")] [assembly: AssemblyInformationalVersion("1.1.0+910b12b1d7f0778dad3996455f04b0b12da877ab")] [assembly: AssemblyProduct("REPONativeUltrawide")] [assembly: AssemblyTitle("com.github.NEDOSTUPN0.REPONativeUltrawide")] [assembly: AssemblyVersion("1.1.0.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } [CompilerGenerated] [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 RepoNativeUltrawide { [HarmonyPatch(typeof(GraphicsManager), "Update")] internal static class GameTickPatch { private static void Postfix() { //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) bool value = Plugin.Enabled.Value; UltrawideHud.Tick(value); MenuAdjust.Tick(value); PostProcessAdjust.Tick(value && Plugin.LensDistortionFix.Value, value && Plugin.DisableHudLensEffects.Value); if ((int)Plugin.DumpKey.Value != 0 && Input.GetKeyDown(Plugin.DumpKey.Value)) { Plugin.DumpHierarchy(); } } } internal static class MenuAdjust { private const float BaseAspect = 1.7777778f; private static readonly Dictionary<RectTransform, Vector2> _originalSizes = new Dictionary<RectTransform, Vector2>(); private static readonly Dictionary<Transform, float> _originalLocalX = new Dictionary<Transform, float>(); private static readonly List<Transform> _elements = new List<Transform>(); internal static void Tick(bool enabled) { //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_007b: 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) //IL_0084: 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_0094: 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) float num = (float)Screen.width / (float)Screen.height; bool active = enabled && num > 1.7787778f; float targetWidth = 400f * num + 40f; float shift = 200f * (num - 1.7777778f); MenuPage[] array = Object.FindObjectsByType<MenuPage>((FindObjectsSortMode)0); foreach (MenuPage val in array) { Transform transform = ((Component)val).transform; RectTransform val2 = (RectTransform)(object)((transform is RectTransform) ? transform : null); if (!((Object)(object)val2 == (Object)null)) { RectTransform val3 = LayoutRect(val2); Rect rect = val3.rect; Vector2 size = ((Rect)(ref rect)).size; CollectElements(((Component)val).transform, size); WidenBackdrops(size, active, targetWidth); if ((Object)(object)((Component)val).GetComponent<MenuPageMain>() != (Object)null || (Object)(object)((Component)val).GetComponent<MenuPageLobby>() != (Object)null || (Object)(object)((Component)val).GetComponent<MenuPageEsc>() != (Object)null || (Object)(object)((Component)val).GetComponent<MenuPageSettings>() != (Object)null || (Object)(object)((Component)val).GetComponent<MenuPageSettingsPage>() != (Object)null) { ShiftElements(val3, size, active, shift); } } } } private static RectTransform LayoutRect(RectTransform pageRt) { //IL_0001: 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_0009: 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_000f: 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) Rect rect = pageRt.rect; Vector2 size = ((Rect)(ref rect)).size; if (size.x < 1f || size.y < 1f) { Transform parent = ((Transform)pageRt).parent; RectTransform val = (RectTransform)(object)((parent is RectTransform) ? parent : null); if (val != null) { return val; } } return pageRt; } private static void CollectElements(Transform parent, Vector2 pageSize) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) _elements.Clear(); CollectInto(parent, pageSize); } private static void CollectInto(Transform parent, Vector2 pageSize) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Expected O, but got Unknown //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) foreach (Transform item in parent) { Transform val = item; if (IsPageContainer(val, pageSize)) { CollectInto(val, pageSize); } else { _elements.Add(val); } } } private static bool IsPageContainer(Transform t, Vector2 pageSize) { //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_003d: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) RectTransform val = (RectTransform)(object)((t is RectTransform) ? t : null); if (val != null && t.childCount > 0 && (Object)(object)((Component)val).GetComponent<Graphic>() == (Object)null && (Object)(object)((Component)val).GetComponent<Selectable>() == (Object)null) { Rect rect = val.rect; if (((Rect)(ref rect)).width >= pageSize.x * 0.9f) { rect = val.rect; return ((Rect)(ref rect)).height >= pageSize.y * 0.9f; } } return false; } private static bool IsBackdrop(Transform t, Vector2 pageSize) { //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_0026: 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_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) RectTransform val = (RectTransform)(object)((t is RectTransform) ? t : null); if (val != null && (Object)(object)((Component)val).GetComponent<Graphic>() != (Object)null) { Rect rect = val.rect; if (((Rect)(ref rect)).width >= pageSize.x * 0.9f) { rect = val.rect; return ((Rect)(ref rect)).height >= pageSize.y * 0.9f; } } return false; } private static void WidenBackdrops(Vector2 pageSize, bool active, float targetWidth) { //IL_0019: 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_002b: Expected O, but got Unknown //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_0036: 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_0067: 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_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0078: 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_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: 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) foreach (Transform element in _elements) { if (!IsBackdrop(element, pageSize)) { continue; } RectTransform val = (RectTransform)element; Vector2 val2 = OriginalSize(val); if (!active) { if (val.sizeDelta != val2) { val.sizeDelta = val2; } continue; } Transform parent = ((Transform)val).parent; RectTransform val3 = (RectTransform)(object)((parent is RectTransform) ? parent : null); float num; if (val3 == null) { num = pageSize.x; } else { Rect rect = val3.rect; num = ((Rect)(ref rect)).width; } float num2 = num; float num3 = val.anchorMax.x - val.anchorMin.x; float num4 = targetWidth - num3 * num2; if (!Mathf.Approximately(val.sizeDelta.x, num4)) { val.sizeDelta = new Vector2(num4, val2.y); } } } private static void ShiftElements(RectTransform layoutRt, Vector2 pageSize, bool active, float shift) { //IL_0067: 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_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: 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_00fb: Unknown result type (might be due to invalid IL or missing references) int num = 0; foreach (Transform element in _elements) { if (((Object)element).name == "Panel") { num = ClassifyDirection(element, layoutRt); break; } } foreach (Transform element2 in _elements) { if (IsBackdrop(element2, pageSize) || (Object)(object)((Component)element2).GetComponent<MenuSelectionBox>() != (Object)null) { continue; } int num2 = ClassifyDirection(element2, layoutRt); if (num2 == 0 && (Object)(object)((Component)element2).GetComponent<MenuScrollBox>() != (Object)null) { num2 = num; } if (num2 != 0 || _originalLocalX.ContainsKey(element2)) { float num3 = OriginalLocalX(element2); float num4 = (active ? (num3 + (float)num2 * shift) : num3); Vector3 localPosition = element2.localPosition; if (!Mathf.Approximately(localPosition.x, num4)) { element2.localPosition = new Vector3(num4, localPosition.y, localPosition.z); } } } } private static int ClassifyDirection(Transform c, RectTransform layoutRt) { //IL_0028: 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_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0036: 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_001f: 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_0042: 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_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) if (((Object)c).name == "Menu Element Player Avatar") { return 1; } RectTransform val = (RectTransform)(object)((c is RectTransform) ? c : null); Vector3 val2; if (val == null) { val2 = c.position; } else { Rect rect = val.rect; val2 = ((Transform)val).TransformPoint(Vector2.op_Implicit(((Rect)(ref rect)).center)); } Vector3 val3 = val2; Rect rect2 = layoutRt.rect; float num = ((Transform)layoutRt).InverseTransformPoint(val3).x - ((Rect)(ref rect2)).xMin; float width = ((Rect)(ref rect2)).width; float num2 = width * 0.5f; float num3 = width * 0.12f; if (num < num2 - num3) { return -1; } if (num > num2 + num3) { return 1; } return 0; } private static float OriginalLocalX(Transform t) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) if (!_originalLocalX.TryGetValue(t, out var value)) { value = t.localPosition.x; _originalLocalX[t] = value; } return value; } private static Vector2 OriginalSize(RectTransform rt) { //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0010: 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_001c: Unknown result type (might be due to invalid IL or missing references) if (!_originalSizes.TryGetValue(rt, out var value)) { value = rt.sizeDelta; _originalSizes[rt] = value; } return value; } } [BepInPlugin("com.github.NEDOSTUPN0.REPONativeUltrawide", "REPONativeUltrawide", "1.1.0")] public class Plugin : BaseUnityPlugin { public const string Guid = "com.github.NEDOSTUPN0.REPONativeUltrawide"; public const string Name = "REPONativeUltrawide"; public const string Version = "1.1.0"; internal static ManualLogSource Log; internal static ConfigEntry<KeyCode> DumpKey; internal static ConfigEntry<bool> Enabled; internal static ConfigEntry<bool> LensDistortionFix; internal static ConfigEntry<bool> DisableHudLensEffects; private void Awake() { //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Expected O, but got Unknown Log = ((BaseUnityPlugin)this).Logger; Enabled = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Enabled", true, "Adapt the game and UI to ultrawide instead of stretching them. Spreads HUD/menu elements to the real screen edges."); LensDistortionFix = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Lens Distortion Fix", true, "Reduce the 'old TV' lens distortion and chromatic aberration on ultrawide so the edges/corners stay as moderate and readable as they are at 16:9."); DisableHudLensEffects = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Disable HUD Lens Effects", false, "Turn the 'old TV' lens distortion and chromatic aberration off completely on the HUD. For the world, use the game's own Lens Effect / Chromatic Aberration graphics settings (they don't affect the HUD)."); DumpKey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("Debug", "Dump UI Hierarchy Key", (KeyCode)0, "Bind a key to dump the full UI (Canvas/RectTransform) hierarchy + cameras to a file. Unbound by default."); ApplyPatches(new Harmony("com.github.NEDOSTUPN0.REPONativeUltrawide")); Log.LogInfo((object)string.Format("{0} {1} loaded (enabled={2}).", "REPONativeUltrawide", "1.1.0", Enabled.Value)); } private static void ApplyPatches(Harmony harmony) { Type[] typesFromAssembly = AccessTools.GetTypesFromAssembly(typeof(Plugin).Assembly); foreach (Type type in typesFromAssembly) { try { harmony.CreateClassProcessor(type).Patch(); } catch (Exception ex) { Log.LogError((object)("Failed to apply patch " + type.Name + ": " + ex.Message)); } } } internal static void DumpHierarchy() { //IL_006a: 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) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_0126: Unknown result type (might be due to invalid IL or missing references) StringBuilder stringBuilder = new StringBuilder(); stringBuilder.AppendLine("=== REPONativeUltrawide UI dump ==="); stringBuilder.AppendLine($"Time: {DateTime.Now:yyyy-MM-dd HH:mm:ss}"); stringBuilder.AppendLine($"Screen: {Screen.width}x{Screen.height} aspect={(float)Screen.width / (float)Screen.height:0.0000}"); stringBuilder.AppendLine($"Fullscreen: {Screen.fullScreenMode}"); stringBuilder.AppendLine(); Canvas[] array = Resources.FindObjectsOfTypeAll<Canvas>(); int num = 0; Canvas[] array2 = array; foreach (Canvas val in array2) { if (!((Object)(object)val == (Object)null)) { Scene scene = ((Component)val).gameObject.scene; if (((Scene)(ref scene)).IsValid() && (!((Object)(object)((Component)val).transform.parent != (Object)null) || !((Object)(object)((Component)((Component)val).transform.parent).GetComponentInParent<Canvas>() != (Object)null))) { object[] obj = new object[4] { ((Object)val).name, null, null, null }; scene = ((Component)val).gameObject.scene; obj[1] = ((Scene)(ref scene)).name; obj[2] = val.renderMode; obj[3] = val.sortingOrder; stringBuilder.AppendLine(string.Format("########## CANVAS '{0}' scene='{1}' renderMode={2} sortingOrder={3}", obj)); DumpNode(((Component)val).transform, 0, stringBuilder); stringBuilder.AppendLine(); num++; } } } DumpCameras(stringBuilder); DumpPostProcessing(stringBuilder); string bepInExRootPath = Paths.BepInExRootPath; string text = Path.Combine(bepInExRootPath, $"ultrawide-ui-dump-{DateTime.Now:yyyyMMdd-HHmmss}.txt"); try { File.WriteAllText(text, stringBuilder.ToString()); Log.LogMessage((object)$"Dumped {num} root canvas/canvases → {text}"); } catch (Exception arg) { Log.LogError((object)$"Failed to write dump file: {arg}"); Log.LogInfo((object)stringBuilder.ToString()); } } private static void DumpCameras(StringBuilder sb) { //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_0255: Unknown result type (might be due to invalid IL or missing references) //IL_025a: Unknown result type (might be due to invalid IL or missing references) //IL_03a6: Unknown result type (might be due to invalid IL or missing references) //IL_014a: Unknown result type (might be due to invalid IL or missing references) //IL_0155: Unknown result type (might be due to invalid IL or missing references) sb.AppendLine(); sb.AppendLine("########## CAMERAS"); Camera[] array = Resources.FindObjectsOfTypeAll<Camera>(); Camera[] array2 = array; Scene scene; foreach (Camera val in array2) { if ((Object)(object)val == (Object)null) { continue; } scene = ((Component)val).gameObject.scene; if (!((Scene)(ref scene)).IsValid()) { continue; } RenderTexture targetTexture = val.targetTexture; string text = (((Object)(object)targetTexture == (Object)null) ? "targetTexture=NULL (renders to screen)" : $"targetTexture='{((Object)targetTexture).name}' {((Texture)targetTexture).width}x{((Texture)targetTexture).height} fmt={targetTexture.format}"); sb.AppendLine("[" + (((Behaviour)val).enabled ? "+" : "-") + "] CAM '" + FullPath(((Component)val).transform) + "'" + $" depth={val.depth} ortho={val.orthographic} orthoSize={val.orthographicSize:0.##}" + $" aspect={val.aspect:0.0000} fov={val.fieldOfView:0.#}" + $" rect={R(val.rect)} clear={val.clearFlags} cullMask=0x{val.cullingMask:X8}"); sb.AppendLine(" " + text); StringBuilder stringBuilder = new StringBuilder(); Component[] components = ((Component)val).GetComponents<Component>(); foreach (Component val2 in components) { if (!((Object)(object)val2 == (Object)null) && !(val2 is Transform) && !(val2 is Camera)) { stringBuilder.Append(((object)val2).GetType().Name).Append(' '); } } if (stringBuilder.Length > 0) { sb.AppendLine($" components: {stringBuilder}"); } } sb.AppendLine(); sb.AppendLine("########## DISPLAY QUAD MATERIALS"); RawImage[] array3 = Resources.FindObjectsOfTypeAll<RawImage>(); foreach (RawImage val3 in array3) { if ((Object)(object)val3 == (Object)null) { continue; } scene = ((Component)val3).gameObject.scene; if (!((Scene)(ref scene)).IsValid()) { continue; } string name = ((Object)val3).name; if (name.Contains("Render Texture")) { Material material = ((Graphic)val3).material; sb.AppendLine(" RawImage '" + name + "' material='" + (((Object)(object)material != (Object)null) ? ((Object)material).name : "null") + "' shader='" + (((Object)(object)material != (Object)null && (Object)(object)material.shader != (Object)null) ? ((Object)material.shader).name : "null") + "'"); if ((Object)(object)material != (Object)null && (Object)(object)material.shader != (Object)null) { DumpMaterialProps(material, sb); } } } sb.AppendLine(); sb.AppendLine("########## RENDER TEXTURES (loaded)"); RenderTexture[] array4 = Resources.FindObjectsOfTypeAll<RenderTexture>(); foreach (RenderTexture val4 in array4) { if (!((Object)(object)val4 == (Object)null)) { sb.AppendLine($" RT '{((Object)val4).name}' {((Texture)val4).width}x{((Texture)val4).height} fmt={val4.format} created={val4.IsCreated()}"); } } } private static void DumpPostProcessing(StringBuilder sb) { //IL_0296: Unknown result type (might be due to invalid IL or missing references) //IL_029b: Unknown result type (might be due to invalid IL or missing references) //IL_0406: Unknown result type (might be due to invalid IL or missing references) //IL_040b: Unknown result type (might be due to invalid IL or missing references) sb.AppendLine(); sb.AppendLine("########## POST-PROCESS EFFECTS (all loaded instances)"); ChromaticAberration[] array = Resources.FindObjectsOfTypeAll<ChromaticAberration>(); foreach (ChromaticAberration val in array) { if ((Object)(object)val != (Object)null) { sb.AppendLine($" ChromaticAberration active={((PostProcessEffectSettings)val).active} enabled={((PostProcessEffectSettings)val).enabled} intensity={((ParameterOverride<float>)(object)val.intensity).value:0.###} (override={((ParameterOverride)val.intensity).overrideState})"); } } Grain[] array2 = Resources.FindObjectsOfTypeAll<Grain>(); foreach (Grain val2 in array2) { if ((Object)(object)val2 != (Object)null) { sb.AppendLine($" Grain active={((PostProcessEffectSettings)val2).active} intensity={((ParameterOverride<float>)(object)val2.intensity).value:0.###} size={((ParameterOverride<float>)(object)val2.size).value:0.###}"); } } Vignette[] array3 = Resources.FindObjectsOfTypeAll<Vignette>(); foreach (Vignette val3 in array3) { if ((Object)(object)val3 != (Object)null) { sb.AppendLine($" Vignette active={((PostProcessEffectSettings)val3).active} intensity={((ParameterOverride<float>)(object)val3.intensity).value:0.###} smoothness={((ParameterOverride<float>)(object)val3.smoothness).value:0.###}"); } } Bloom[] array4 = Resources.FindObjectsOfTypeAll<Bloom>(); foreach (Bloom val4 in array4) { if ((Object)(object)val4 != (Object)null) { sb.AppendLine($" Bloom active={((PostProcessEffectSettings)val4).active} intensity={((ParameterOverride<float>)(object)val4.intensity).value:0.###}"); } } LensDistortion[] array5 = Resources.FindObjectsOfTypeAll<LensDistortion>(); foreach (LensDistortion val5 in array5) { if ((Object)(object)val5 != (Object)null) { sb.AppendLine($" LensDistortion active={((PostProcessEffectSettings)val5).active} intensity={((ParameterOverride<float>)(object)val5.intensity).value:0.###} X={((ParameterOverride<float>)(object)val5.intensityX).value:0.###} Y={((ParameterOverride<float>)(object)val5.intensityY).value:0.###} scale={((ParameterOverride<float>)(object)val5.scale).value:0.###}"); } } sb.AppendLine(); sb.AppendLine("########## POST-PROCESS VOLUMES + LAYERS"); PostProcessVolume[] array6 = Resources.FindObjectsOfTypeAll<PostProcessVolume>(); Scene scene; ChromaticAberration val8 = default(ChromaticAberration); LensDistortion val9 = default(LensDistortion); foreach (PostProcessVolume val6 in array6) { if ((Object)(object)val6 == (Object)null) { continue; } scene = ((Component)val6).gameObject.scene; if (!((Scene)(ref scene)).IsValid()) { continue; } PostProcessProfile val7 = (((Object)(object)val6.sharedProfile != (Object)null) ? val6.sharedProfile : val6.profile); string text = "-"; string text2 = "-"; if ((Object)(object)val7 != (Object)null) { if (val7.TryGetSettings<ChromaticAberration>(ref val8)) { text = $"{((ParameterOverride<float>)(object)val8.intensity).value:0.##}(ov={((ParameterOverride)val8.intensity).overrideState})"; } if (val7.TryGetSettings<LensDistortion>(ref val9)) { text2 = $"int={((ParameterOverride<float>)(object)val9.intensity).value:0.#},X={((ParameterOverride<float>)(object)val9.intensityX).value:0.##}"; } } sb.AppendLine(string.Format(" VOL '{0}' global={1} prio={2:0.#} layer={3} profile='{4}' CA={5} LD={6}", FullPath(((Component)val6).transform), val6.isGlobal, val6.priority, ((Component)val6).gameObject.layer, ((Object)(object)val7 != (Object)null) ? ((Object)val7).name : "null", text, text2)); } PostProcessLayer[] array7 = Resources.FindObjectsOfTypeAll<PostProcessLayer>(); foreach (PostProcessLayer val10 in array7) { if (!((Object)(object)val10 == (Object)null)) { scene = ((Component)val10).gameObject.scene; if (((Scene)(ref scene)).IsValid()) { sb.AppendLine($" LAYER on '{FullPath(((Component)val10).transform)}' volumeLayer.mask=0x{((LayerMask)(ref val10.volumeLayer)).value:X8}"); } } } } private static void DumpMaterialProps(Material mat, StringBuilder sb) { //IL_001f: 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_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Expected I4, but got Unknown //IL_0077: 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_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) Shader shader = mat.shader; int propertyCount = shader.GetPropertyCount(); for (int i = 0; i < propertyCount; i++) { string propertyName = shader.GetPropertyName(i); ShaderPropertyType propertyType = shader.GetPropertyType(i); string arg = (int)propertyType switch { 2 => mat.GetFloat(propertyName).ToString("0.###"), 3 => mat.GetFloat(propertyName).ToString("0.###"), 0 => ((object)mat.GetColor(propertyName)/*cast due to .constrained prefix*/).ToString(), 1 => ((object)mat.GetVector(propertyName)/*cast due to .constrained prefix*/).ToString(), 4 => "<tex>", _ => "?", }; sb.AppendLine($" {propertyType} {propertyName} = {arg}"); } } private static string FullPath(Transform t) { string text = ((Object)t).name; while ((Object)(object)t.parent != (Object)null) { t = t.parent; text = ((Object)t).name + "/" + text; } return text; } private static string R(Rect r) { return $"({((Rect)(ref r)).x:0.##},{((Rect)(ref r)).y:0.##},{((Rect)(ref r)).width:0.##},{((Rect)(ref r)).height:0.##})"; } private static void DumpNode(Transform t, int depth, StringBuilder sb) { //IL_0066: 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_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_00bf: 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_013c: Unknown result type (might be due to invalid IL or missing references) //IL_0148: 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) string value = new string(' ', depth * 2); RectTransform val = (RectTransform)(object)((t is RectTransform) ? t : null); sb.Append(value); sb.Append(((Component)t).gameObject.activeSelf ? "[+] " : "[-] "); sb.Append(((Object)t).name); if ((Object)(object)val != (Object)null) { sb.Append(" aMin=" + V2(val.anchorMin) + " aMax=" + V2(val.anchorMax) + " pivot=" + V2(val.pivot) + " pos=" + V2(val.anchoredPosition) + " size=" + V2(val.sizeDelta) + " scale=" + V3(((Transform)val).localScale)); } Component[] components = ((Component)t).GetComponents<Component>(); foreach (Component val2 in components) { if ((Object)(object)val2 == (Object)null || val2 is Transform) { continue; } string name = ((object)val2).GetType().Name; CanvasScaler val3 = (CanvasScaler)(object)((val2 is CanvasScaler) ? val2 : null); if (val3 != null) { sb.Append($" {{CanvasScaler mode={val3.uiScaleMode} ref={V2(val3.referenceResolution)}" + $" match={val3.matchWidthOrHeight:0.##} scaleFactor={val3.scaleFactor:0.##}}}"); continue; } Canvas val4 = (Canvas)(object)((val2 is Canvas) ? val2 : null); if (val4 != null && (Object)(object)((Component)val4).transform != (Object)(object)t) { sb.Append($" {{Canvas {val4.renderMode}}}"); } else if (val2 is Image || val2 is RawImage || val2 is Canvas || val2 is CanvasGroup) { sb.Append(" <" + name + ">"); } else { sb.Append(" <" + name + ">"); } } sb.AppendLine(); for (int j = 0; j < t.childCount; j++) { DumpNode(t.GetChild(j), depth + 1, sb); } } private static string V2(Vector2 v) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) return $"({v.x:0.#},{v.y:0.#})"; } private static string V3(Vector3 v) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) return $"({v.x:0.##},{v.y:0.##},{v.z:0.##})"; } } internal static class PostProcessAdjust { private const float BaseAspect = 1.7777778f; private static readonly Dictionary<LensDistortion, float> _baseLensX = new Dictionary<LensDistortion, float>(); private static readonly Dictionary<ChromaticAberration, float> _baseCa = new Dictionary<ChromaticAberration, float>(); private static LensDistortion[]? _lenses; private static ChromaticAberration[]? _aberrations; private static PostProcessVolume? _hudVolume; private static readonly HashSet<PostProcessEffectSettings> _disabledByUs = new HashSet<PostProcessEffectSettings>(); internal static void Tick(bool enabled, bool disableHudEffects) { if (_lenses == null || HasNull<LensDistortion>(_lenses)) { _lenses = Resources.FindObjectsOfTypeAll<LensDistortion>(); } if (_aberrations == null || HasNull<ChromaticAberration>(_aberrations)) { _aberrations = Resources.FindObjectsOfTypeAll<ChromaticAberration>(); } UpdateHudEffects(disableHudEffects); float num = (float)Screen.width / (float)Screen.height; bool flag = enabled && num > 1.7787778f; float num2 = 1.7777778f / num; LensDistortion[] lenses = _lenses; foreach (LensDistortion val in lenses) { if (!((Object)(object)val == (Object)null)) { if (!_baseLensX.TryGetValue(val, out var value)) { value = ((ParameterOverride<float>)(object)val.intensityX).value; _baseLensX[val] = value; } float num3 = (flag ? (value * num2) : value); if (!Mathf.Approximately(((ParameterOverride<float>)(object)val.intensityX).value, num3)) { ((ParameterOverride<float>)(object)val.intensityX).value = num3; ((ParameterOverride)val.intensityX).overrideState = true; } } } ChromaticAberration[] aberrations = _aberrations; foreach (ChromaticAberration val2 in aberrations) { if (!((Object)(object)val2 == (Object)null)) { if (!_baseCa.TryGetValue(val2, out var value2)) { value2 = ((ParameterOverride<float>)(object)val2.intensity).value; _baseCa[val2] = value2; } float num4 = (flag ? (value2 * num2) : value2); if (!Mathf.Approximately(((ParameterOverride<float>)(object)val2.intensity).value, num4)) { ((ParameterOverride<float>)(object)val2.intensity).value = num4; ((ParameterOverride)val2.intensity).overrideState = true; } } } } private static void UpdateHudEffects(bool disable) { if (disable) { PostProcessProfile val = HudProfile(); if (!((Object)(object)val == (Object)null)) { Deactivate((PostProcessEffectSettings?)(object)val.GetSetting<LensDistortion>()); Deactivate((PostProcessEffectSettings?)(object)val.GetSetting<ChromaticAberration>()); } } else { if (_disabledByUs.Count == 0) { return; } foreach (PostProcessEffectSettings disabledByU in _disabledByUs) { if ((Object)(object)disabledByU != (Object)null) { disabledByU.active = true; } } _disabledByUs.Clear(); } } private static void Deactivate(PostProcessEffectSettings? effect) { if (!((Object)(object)effect == (Object)null) && effect.active) { effect.active = false; _disabledByUs.Add(effect); } } private static PostProcessProfile? HudProfile() { //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_hudVolume == (Object)null) { PostProcessVolume val = (((Object)(object)PostProcessing.Instance != (Object)null) ? PostProcessing.Instance.volume : null); if ((Object)(object)val == (Object)null) { return null; } PostProcessVolume[] array = Resources.FindObjectsOfTypeAll<PostProcessVolume>(); foreach (PostProcessVolume val2 in array) { if ((Object)(object)val2 != (Object)null && (Object)(object)val2 != (Object)(object)val && val2.isGlobal) { Scene scene = ((Component)val2).gameObject.scene; if (((Scene)(ref scene)).IsValid() && ((Component)val2).gameObject.layer != ((Component)val).gameObject.layer) { _hudVolume = val2; break; } } } if ((Object)(object)_hudVolume == (Object)null) { return null; } } if (!_hudVolume.HasInstantiatedProfile()) { return _hudVolume.sharedProfile; } return _hudVolume.profile; } private static bool HasNull<T>(T[] arr) where T : Object { foreach (T val in arr) { if ((Object)(object)val == (Object)null) { return true; } } return false; } } [HarmonyPatch(typeof(SemiUI), "Start")] internal static class SemiUiStartPatch { private static void Postfix(SemiUI __instance) { UltrawideHud.OffsetHudElement(__instance); } } internal static class UltrawideHud { private sealed class HudElementShift { public SemiUI Ui; public float ShowFactor; public float HideFactor; public float AppliedExtra; } private const float BaseAspect = 1.7777778f; private const float EdgeThreshold = 200f; private static RectTransform? _mainDisplay; private static RawImage? _overlayDisplay; private static RenderTexture? _overlayRt; private static Camera? _hudCamera; private static RectTransform? _gameHud; private static RectTransform? _fade; private static RectTransform? _vignette; private static RectTransform? _video; private static RectTransform? _loading; private static RectTransform? _splash; private static Transform? _tutorial; private static readonly Dictionary<RectTransform, Vector2> _originalSizes = new Dictionary<RectTransform, Vector2>(); private static int _overlayRtBaseHeight; private static int _overlayRtBaseWidth; private static FieldInfo? _texWidthField; private static FieldInfo? _texHeightField; private static RenderTextureMain? _presetOwner; private static float[]? _presetBaseWidths; private const float TextureWidthTolerance = 2f; private static bool _wasModified; private static readonly List<HudElementShift> _hudElements = new List<HudElementShift>(); private static FieldRef<SemiUI, Vector2>? _hidePositionCurrent; private static bool _hidePositionCurrentResolved; internal static bool EnabledForPatch; private static FieldRef<SemiUI, Vector2>? HidePositionCurrent { get { if (!_hidePositionCurrentResolved) { _hidePositionCurrentResolved = true; try { _hidePositionCurrent = AccessTools.FieldRefAccess<SemiUI, Vector2>("hidePositionCurrent"); } catch (Exception ex) { Plugin.Log.LogWarning((object)("SemiUI.hidePositionCurrent not found; HUD widgets may animate on resize. " + ex.Message)); } } return _hidePositionCurrent; } } internal static void Tick(bool enabled) { EnabledForPatch = enabled; AcquireReferences(); SyncHudElements(); float num = (float)Screen.width / (float)Screen.height; if (!enabled || num <= 1.7787778f) { if (_wasModified) { Restore(); _wasModified = false; } } else { Apply(num); _wasModified = true; } } private static void AcquireReferences() { if ((Object)(object)_mainDisplay == (Object)null && (Object)(object)RenderTextureMain.instance != (Object)null) { _mainDisplay = ((Component)RenderTextureMain.instance).GetComponent<RectTransform>(); } if ((Object)(object)_overlayDisplay == (Object)null && (Object)(object)RenderTextureMain.instance != (Object)null) { _overlayDisplay = RenderTextureMain.instance.overlayRawImage; } if ((Object)(object)_overlayRt == (Object)null && (Object)(object)_overlayDisplay != (Object)null) { Texture texture = _overlayDisplay.texture; _overlayRt = (RenderTexture?)(object)((texture is RenderTexture) ? texture : null); } if ((Object)(object)_overlayRt != (Object)null && ((Object)(object)_hudCamera == (Object)null || (Object)(object)_hudCamera.targetTexture != (Object)(object)_overlayRt)) { _hudCamera = FindCameraTargeting(_overlayRt); } if ((Object)(object)_gameHud == (Object)null && (Object)(object)HUDCanvas.instance != (Object)null) { Transform obj = ((Component)HUDCanvas.instance).transform.Find("HUD/Game Hud"); _gameHud = (RectTransform?)(object)((obj is RectTransform) ? obj : null); } if ((Object)(object)_fade == (Object)null) { _fade = GetRect((Component?)(object)FindComponent<FadeOverlay>()); } if ((Object)(object)_vignette == (Object)null) { _vignette = GetRect((Component?)(object)FindComponent<HurtVignette>()); } if ((Object)(object)_video == (Object)null) { _video = GetRect((Component?)(object)FindComponent<VideoOverlay>()); } if ((Object)(object)_loading == (Object)null && (Object)(object)LoadingUI.instance != (Object)null) { _loading = ((Component)LoadingUI.instance).GetComponent<RectTransform>(); } if ((Object)(object)_splash == (Object)null) { _splash = GetRect((Component?)(object)FindComponent<SplashScreenUI>()); } if ((Object)(object)_tutorial == (Object)null) { TutorialUI? obj2 = FindComponent<TutorialUI>(); _tutorial = ((obj2 != null) ? ((Component)obj2).transform : null); } } private static void Apply(float aspect) { float factor = aspect / 1.7777778f; if ((Object)(object)_overlayRt != (Object)null) { if (_overlayRtBaseHeight == 0) { _overlayRtBaseHeight = ((Texture)_overlayRt).height; _overlayRtBaseWidth = ((Texture)_overlayRt).width; } int num = Mathf.RoundToInt((float)_overlayRtBaseHeight * aspect); if (((Texture)_overlayRt).width != num || ((Texture)_overlayRt).height != _overlayRtBaseHeight) { ResizeRenderTexture(_overlayRt, num, _overlayRtBaseHeight, _hudCamera); } if ((Object)(object)_hudCamera != (Object)null) { _hudCamera.aspect = (float)((Texture)_overlayRt).width / (float)((Texture)_overlayRt).height; } } FixMainTextureAspect(aspect); if ((Object)(object)_mainDisplay != (Object)null) { SetWidthFill(_mainDisplay, aspect); } if ((Object)(object)_overlayDisplay != (Object)null) { SetWidthFill(((Graphic)_overlayDisplay).rectTransform, aspect); } SetWidthScaled(_gameHud, factor); SetWidthScaled(_fade, factor); SetWidthScaled(_vignette, factor); SetWidthScaled(_video, factor); SetWidthScaled(_loading, factor); SetWidthScaled(_splash, factor); if ((Object)(object)_tutorial != (Object)null) { Transform obj = _tutorial.Find("Tutorial Text Container"); SetWidthScaled((RectTransform?)(object)((obj is RectTransform) ? obj : null), factor); Transform obj2 = _tutorial.Find("Dummy Text Transform"); SetWidthScaled((RectTransform?)(object)((obj2 is RectTransform) ? obj2 : null), factor); } } private static void Restore() { //IL_002d: Unknown result type (might be due to invalid IL or missing references) foreach (KeyValuePair<RectTransform, Vector2> originalSize in _originalSizes) { if ((Object)(object)originalSize.Key != (Object)null) { originalSize.Key.sizeDelta = originalSize.Value; } } RestoreMainTextureAspect(); if ((Object)(object)_overlayRt != (Object)null && _overlayRtBaseHeight != 0 && (((Texture)_overlayRt).width != _overlayRtBaseWidth || ((Texture)_overlayRt).height != _overlayRtBaseHeight)) { ResizeRenderTexture(_overlayRt, _overlayRtBaseWidth, _overlayRtBaseHeight, _hudCamera); if ((Object)(object)_hudCamera != (Object)null) { _hudCamera.aspect = (float)((Texture)_overlayRt).width / (float)((Texture)_overlayRt).height; } } } private static void SetWidthScaled(RectTransform? rt, float factor) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0010: 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) //IL_001b: 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_0035: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)rt == (Object)null)) { Vector2 val = OriginalSize(rt); Vector2 val2 = default(Vector2); ((Vector2)(ref val2))..ctor(val.x * factor, val.y); if (rt.sizeDelta != val2) { rt.sizeDelta = val2; } } } private static void SetWidthFill(RectTransform rt, float aspect) { //IL_0001: 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_0009: 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_001d: 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_002b: Unknown result type (might be due to invalid IL or missing references) Vector2 val = OriginalSize(rt); Vector2 val2 = default(Vector2); ((Vector2)(ref val2))..ctor(val.y * aspect, val.y); if (rt.sizeDelta != val2) { rt.sizeDelta = val2; } } private static Vector2 OriginalSize(RectTransform rt) { //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0010: 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_001c: Unknown result type (might be due to invalid IL or missing references) if (!_originalSizes.TryGetValue(rt, out var value)) { value = rt.sizeDelta; _originalSizes[rt] = value; } return value; } private static void FixMainTextureAspect(float aspect) { RenderTextureMain instance = RenderTextureMain.instance; if ((Object)(object)instance == (Object)null) { return; } WidenSizePresets(instance, aspect); if (_texWidthField == null) { Type typeFromHandle = typeof(RenderTextureMain); _texWidthField = typeFromHandle.GetField("textureWidthOriginal", BindingFlags.Instance | BindingFlags.NonPublic); _texHeightField = typeFromHandle.GetField("textureHeightOriginal", BindingFlags.Instance | BindingFlags.NonPublic); } if (_texWidthField == null || _texHeightField == null) { return; } float num = (float)_texHeightField.GetValue(instance); float num2 = (float)_texWidthField.GetValue(instance); if (!(num <= 0f)) { float num3 = Mathf.Round(num * aspect); if (Mathf.Abs(num2 - num3) > 2f) { _texWidthField.SetValue(instance, num3); } } } private static void WidenSizePresets(RenderTextureMain rtm, float aspect) { if ((Object)(object)_presetOwner != (Object)(object)rtm) { _presetOwner = rtm; _presetBaseWidths = new float[3] { rtm.textureWidthSmall, rtm.textureWidthMedium, rtm.textureWidthLarge }; } rtm.textureWidthSmall = PresetWidth(_presetBaseWidths[0], rtm.textureHeightSmall, aspect); rtm.textureWidthMedium = PresetWidth(_presetBaseWidths[1], rtm.textureHeightMedium, aspect); rtm.textureWidthLarge = PresetWidth(_presetBaseWidths[2], rtm.textureHeightLarge, aspect); } private static float PresetWidth(float baseWidth, float height, float aspect) { if (!(height > 0f)) { return baseWidth; } return Mathf.Round(height * aspect); } private static void RestoreSizePresets() { RenderTextureMain instance = RenderTextureMain.instance; if (!((Object)(object)instance == (Object)null) && !((Object)(object)instance != (Object)(object)_presetOwner) && _presetBaseWidths != null) { instance.textureWidthSmall = _presetBaseWidths[0]; instance.textureWidthMedium = _presetBaseWidths[1]; instance.textureWidthLarge = _presetBaseWidths[2]; } } private static void RestoreMainTextureAspect() { RestoreSizePresets(); if (!((Object)(object)RenderTextureMain.instance == (Object)null) && !((Object)(object)GraphicsManager.instance == (Object)null)) { GraphicsManager.instance.UpdateRenderSize(); } } private static void ResizeRenderTexture(RenderTexture rt, int width, int height, Camera? cam) { bool flag = (Object)(object)cam != (Object)null && (Object)(object)cam.targetTexture == (Object)(object)rt; if (flag) { cam.targetTexture = null; } rt.Release(); ((Texture)rt).width = width; ((Texture)rt).height = height; rt.Create(); if (flag) { cam.targetTexture = rt; ((Behaviour)cam).enabled = false; ((Behaviour)cam).enabled = true; } } private static Camera? FindCameraTargeting(RenderTexture rt) { //IL_002b: 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) Camera[] array = Resources.FindObjectsOfTypeAll<Camera>(); foreach (Camera val in array) { if ((Object)(object)val != (Object)null && (Object)(object)val.targetTexture == (Object)(object)rt) { Scene scene = ((Component)val).gameObject.scene; if (((Scene)(ref scene)).IsValid()) { return val; } } } return null; } private static T? FindComponent<T>() where T : Component { //IL_002b: 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) T[] array = Resources.FindObjectsOfTypeAll<T>(); foreach (T val in array) { if ((Object)(object)val != (Object)null) { Scene scene = ((Component)val).gameObject.scene; if (((Scene)(ref scene)).IsValid()) { return val; } } } return default(T); } private static RectTransform? GetRect(Component? c) { if (!((Object)(object)c != (Object)null)) { return null; } return c.GetComponent<RectTransform>(); } internal static void OffsetHudElement(SemiUI ui) { //IL_0066: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)ui == (Object)null || (Object)(object)HUDCanvas.instance == (Object)null) { return; } Transform val = ((Component)HUDCanvas.instance).transform.Find("HUD/Game Hud"); if (!((Object)(object)val == (Object)null)) { Transform obj = (ui.animateTheEntireObject ? ((Component)ui).transform : ui.textRectTransform); RectTransform val2 = (RectTransform)(object)((obj is RectTransform) ? obj : null); if (!((Object)(object)val2 == (Object)null) && ((Transform)val2).IsChildOf(val)) { float anchorFactor = (val2.anchorMin.x - 0.5f) * 2f; HudElementShift hudElementShift = new HudElementShift { Ui = ui, ShowFactor = ShiftFactor(ui.showPosition.x, anchorFactor), HideFactor = ShiftFactor(ui.hidePosition.x, anchorFactor) }; _hudElements.Add(hudElementShift); ApplyShift(hudElementShift, CurrentHudExtra()); } } } private static float ShiftFactor(float posX, float anchorFactor) { if (!Mathf.Approximately(anchorFactor, 0f)) { return anchorFactor; } if (Mathf.Abs(posX) < 200f) { return 0f; } return Mathf.Sign(posX); } private static float CurrentHudExtra() { if (!EnabledForPatch) { return 0f; } float num = (float)Screen.width / (float)Screen.height; if (!(num > 1.7787778f)) { return 0f; } return 200f * (num - 1.7777778f); } private static void SyncHudElements() { float extra = CurrentHudExtra(); for (int num = _hudElements.Count - 1; num >= 0; num--) { HudElementShift hudElementShift = _hudElements[num]; if ((Object)(object)hudElementShift.Ui == (Object)null) { _hudElements.RemoveAt(num); } else { ApplyShift(hudElementShift, extra); } } } private static void ApplyShift(HudElementShift shift, float extra) { //IL_001f: 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_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_002e: 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) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0051: 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_0068: 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_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: 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_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) float num = extra - shift.AppliedExtra; if (Mathf.Abs(num) < 0.001f) { return; } SemiUI ui = shift.Ui; Vector2 showPosition = ui.showPosition; Vector2 hidePosition = ui.hidePosition; ui.showPosition += new Vector2(shift.ShowFactor * num, 0f); ui.hidePosition += new Vector2(shift.HideFactor * num, 0f); shift.AppliedExtra = extra; FieldRef<SemiUI, Vector2> hidePositionCurrent = HidePositionCurrent; if (hidePositionCurrent != null) { ref Vector2 reference = ref hidePositionCurrent.Invoke(ui); if (reference == hidePosition) { reference = ui.hidePosition; } else if (reference == showPosition) { reference = ui.showPosition; } } } } internal static class ValuableDiscoverPatch { private const float BaseAspect = 1.7777778f; internal static float WidthScale() { //IL_0059: 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) //IL_005e: 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) //IL_006c: 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) //IL_0087: Unknown result type (might be due to invalid IL or missing references) if (!UltrawideHud.EnabledForPatch || (Object)(object)ValuableDiscover.instance == (Object)null) { return 1f; } float num = (float)Screen.width / (float)Screen.height; if (num <= 1.7787778f) { return 1f; } Vector2 val = (((Object)(object)ValuableDiscover.instance.canvasRect != (Object)null) ? ValuableDiscover.instance.canvasRect.sizeDelta : Vector2.zero); if (val.x <= 0f || val.y <= 0f) { return 1f; } return val.y * num / val.x; } } [HarmonyPatch(typeof(ValuableDiscoverGraphic), "GetScreenPosition")] internal static class ValuableDiscoverGetScreenPositionPatch { private static void Postfix(ref Vector3 __result) { __result.x *= ValuableDiscoverPatch.WidthScale(); } } [HarmonyPatch(typeof(ValuableDiscoverGraphic), "Update")] internal static class ValuableDiscoverUpdatePatch { private static readonly FieldRef<ValuableDiscoverGraphic, Vector2> MiddleTargetSizeNew = AccessTools.FieldRefAccess<ValuableDiscoverGraphic, Vector2>("middleTargetSizeNew"); private static readonly ConditionalWeakTable<ValuableDiscoverGraphic, StrongBox<Vector2>> _lastScaled = new ConditionalWeakTable<ValuableDiscoverGraphic, StrongBox<Vector2>>(); private static void Postfix(ValuableDiscoverGraphic __instance) { //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //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) float num = ValuableDiscoverPatch.WidthScale(); if (!Mathf.Approximately(num, 1f)) { ref Vector2 reference = ref MiddleTargetSizeNew.Invoke(__instance); StrongBox<Vector2> orCreateValue = _lastScaled.GetOrCreateValue(__instance); if (!(reference == orCreateValue.Value)) { reference.x *= num; orCreateValue.Value = reference; } } } } }