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 Loading Tales v1.0.0
LoadingTales.dll
Decompiled 17 hours agousing System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using BepInEx; using HarmonyLib; using TMPro; using UnityEngine; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: AssemblyTitle("ValheimCustomLoadingScreens")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("ValheimCustomLoadingScreens")] [assembly: AssemblyCopyright("Copyright © 2026")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("e78a7eb2-f23c-4e57-bc75-562dac3774fd")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: AssemblyVersion("1.0.0.0")] [BepInPlugin("agonit.valheimcustomloadingscreens", "Loading Tales", "1.0.0")] public class Plugin : BaseUnityPlugin { private void Awake() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Expected O, but got Unknown Harmony val = new Harmony("agonit.valheimcustomloadingscreens"); val.PatchAll(); Debug.Log((object)"Loading Tales загружен."); } } [HarmonyPatch(typeof(Hud), "UpdateShownTip")] public static class LoadingScreenPatch { private static bool imageChanged = false; private static bool tipChanged = false; private static Transform currentLoadingScreen = null; private static Hud currentHud = null; private static Random Random = new Random(); private static void Postfix(Hud __instance) { //IL_0457: Unknown result type (might be due to invalid IL or missing references) //IL_0466: Unknown result type (might be due to invalid IL or missing references) //IL_0499: Unknown result type (might be due to invalid IL or missing references) //IL_04cd: Unknown result type (might be due to invalid IL or missing references) //IL_04e4: Unknown result type (might be due to invalid IL or missing references) //IL_04f1: Unknown result type (might be due to invalid IL or missing references) //IL_04fe: Unknown result type (might be due to invalid IL or missing references) //IL_050b: Unknown result type (might be due to invalid IL or missing references) //IL_0518: Unknown result type (might be due to invalid IL or missing references) //IL_02a6: Unknown result type (might be due to invalid IL or missing references) //IL_02ad: Expected O, but got Unknown if ((Object)(object)__instance == (Object)null) { return; } Transform val = null; Transform[] componentsInChildren = ((Component)((Component)__instance).transform.root).GetComponentsInChildren<Transform>(true); Transform[] array = componentsInChildren; foreach (Transform val2 in array) { if (((Object)val2).name == "LoadingBlack") { val = val2; break; } } if ((Object)(object)val == (Object)null) { return; } if ((Object)(object)currentHud != (Object)(object)__instance || (Object)(object)currentLoadingScreen != (Object)(object)val) { currentHud = __instance; currentLoadingScreen = val; imageChanged = false; tipChanged = false; Debug.Log((object)"Loading Tales: новая загрузка обнаружена."); } if (!tipChanged) { string randomTip = GetRandomTip(); if (!string.IsNullOrEmpty(randomTip)) { Transform[] componentsInChildren2 = ((Component)__instance).GetComponentsInChildren<Transform>(true); Transform[] array2 = componentsInChildren2; foreach (Transform val3 in array2) { if (!(((Object)val3).name != "Tip")) { TMP_Text component = ((Component)val3).GetComponent<TMP_Text>(); if (!((Object)(object)component == (Object)null)) { component.text = randomTip; tipChanged = true; break; } } } } } if (imageChanged) { return; } Image val4 = null; Image[] componentsInChildren3 = ((Component)val).GetComponentsInChildren<Image>(true); Image[] array3 = componentsInChildren3; foreach (Image val5 in array3) { if (!((Object)(object)val5 == (Object)null) && !((Object)(object)val5.sprite == (Object)null) && !(((Object)val5.sprite).name != "load_bkg")) { val4 = val5; break; } } if ((Object)(object)val4 == (Object)null) { return; } string directoryName = Path.GetDirectoryName(typeof(Plugin).Assembly.Location); string path = Path.Combine(directoryName, "Images"); if (!Directory.Exists(path)) { return; } List<string> list = new List<string>(); list.AddRange(Directory.GetFiles(path, "*.png")); list.AddRange(Directory.GetFiles(path, "*.jpg")); list.AddRange(Directory.GetFiles(path, "*.jpeg")); if (list.Count == 0) { return; } string path2 = list[Random.Next(list.Count)]; try { byte[] array4 = File.ReadAllBytes(path2); Texture2D val6 = new Texture2D(2, 2, (TextureFormat)4, false); Type type = null; Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies(); Assembly[] array5 = assemblies; foreach (Assembly assembly in array5) { try { Type type2 = assembly.GetType("UnityEngine.ImageConversion"); if (type2 != null) { type = type2; break; } } catch { } } if (type == null) { return; } MethodInfo methodInfo = null; MethodInfo[] methods = type.GetMethods(BindingFlags.Static | BindingFlags.Public); MethodInfo[] array6 = methods; foreach (MethodInfo methodInfo2 in array6) { if (!(methodInfo2.Name != "LoadImage")) { ParameterInfo[] parameters = methodInfo2.GetParameters(); if (parameters.Length >= 2 && parameters.Length <= 3 && !(parameters[0].ParameterType != typeof(Texture2D)) && !(parameters[1].ParameterType != typeof(byte[]))) { methodInfo = methodInfo2; break; } } } if (methodInfo == null) { return; } ParameterInfo[] parameters2 = methodInfo.GetParameters(); if (parameters2.Length == 3) { methodInfo.Invoke(null, new object[3] { val6, array4, false }); } else { methodInfo.Invoke(null, new object[2] { val6, array4 }); } Sprite val7 = Sprite.Create(val6, new Rect(0f, 0f, (float)((Texture)val6).width, (float)((Texture)val6).height), new Vector2(0.5f, 0.5f)); ((Object)val7).name = "CustomLoadingScreen"; val4.sprite = val7; val4.type = (Type)0; val4.preserveAspect = false; ((Graphic)val4).color = Color.white; ((Behaviour)val4).enabled = true; ((Component)val4).gameObject.SetActive(true); RectTransform rectTransform = ((Graphic)val4).rectTransform; rectTransform.anchorMin = new Vector2(0f, 0f); rectTransform.anchorMax = new Vector2(1f, 1f); rectTransform.offsetMin = Vector2.zero; rectTransform.offsetMax = Vector2.zero; rectTransform.anchoredPosition = Vector2.zero; ((Transform)rectTransform).localScale = Vector3.one; Transform val8 = val.Find("Bkg"); if ((Object)(object)val8 != (Object)null) { Image component2 = ((Component)val8).GetComponent<Image>(); if ((Object)(object)component2 != (Object)null) { ((Behaviour)component2).enabled = false; } } ((Component)val4).transform.SetAsFirstSibling(); LoadingScreenZoom loadingScreenZoom = ((Component)val4).gameObject.GetComponent<LoadingScreenZoom>(); if ((Object)(object)loadingScreenZoom == (Object)null) { loadingScreenZoom = ((Component)val4).gameObject.AddComponent<LoadingScreenZoom>(); } loadingScreenZoom.StartZoom(); imageChanged = true; Debug.Log((object)("Custom loading screen: " + Path.GetFileName(path2))); } catch (Exception ex) { Debug.LogError((object)("Custom loading screen error: " + ex.Message)); } } private static string GetRandomTip() { string directoryName = Path.GetDirectoryName(typeof(Plugin).Assembly.Location); string valheimLanguage = GetValheimLanguage(); string path = ((!(valheimLanguage == "English")) ? "tips_ru.txt" : "tips_en.txt"); string path2 = Path.Combine(directoryName, path); if (!File.Exists(path2)) { path2 = Path.Combine(directoryName, "tips_ru.txt"); } if (!File.Exists(path2)) { return ""; } try { string[] array = File.ReadAllLines(path2); List<string> list = new List<string>(); string[] array2 = array; foreach (string text in array2) { if (!string.IsNullOrWhiteSpace(text)) { list.Add(text.Trim()); } } if (list.Count == 0) { return ""; } return list[Random.Next(list.Count)]; } catch { return ""; } } private static string GetValheimLanguage() { try { Type[] types = typeof(Hud).Assembly.GetTypes(); Type[] array = types; foreach (Type type in array) { if (type.Name != "Localization") { continue; } FieldInfo field = type.GetField("instance", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); if (field == null) { continue; } object value = field.GetValue(null); if (value == null) { continue; } FieldInfo field2 = type.GetField("m_language", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (field2 != null) { object value2 = field2.GetValue(value); if (value2 != null) { string text = value2.ToString(); if (!string.IsNullOrEmpty(text)) { return text; } } } PropertyInfo property = type.GetProperty("Language", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (!(property != null)) { continue; } object value3 = property.GetValue(value, null); if (value3 != null) { string text2 = value3.ToString(); if (!string.IsNullOrEmpty(text2)) { return text2; } } } } catch { } return "Russian"; } } public class LoadingScreenZoom : MonoBehaviour { private RectTransform rectTransform; private float startTime; private const float Duration = 12f; private const float StartScale = 1f; private const float EndScale = 1.05f; private bool waitingForStart = false; private bool zooming = false; private int waitFrames = 0; public void StartZoom() { //IL_0031: Unknown result type (might be due to invalid IL or missing references) rectTransform = ((Component)this).GetComponent<RectTransform>(); if ((Object)(object)rectTransform == (Object)null) { Debug.LogWarning((object)"Loading Tales: ZOOM — RectTransform not found."); return; } ((Transform)rectTransform).localScale = Vector3.one; waitFrames = 1; waitingForStart = true; zooming = false; Debug.Log((object)"Loading Tales: ZOOM подготовлен."); } private void Update() { //IL_00d0: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)rectTransform == (Object)null) { return; } if (waitingForStart) { waitFrames--; if (waitFrames <= 0) { waitingForStart = false; StartActualZoom(); } } else if (zooming) { float num = Time.realtimeSinceStartup - startTime; float num2 = num / 12f; if (num2 >= 1f) { num2 = 1f; zooming = false; } float num3 = num2 * num2 * (3f - 2f * num2); float num4 = Mathf.Lerp(1f, 1.05f, num3); ((Transform)rectTransform).localScale = new Vector3(num4, num4, 1f); } } private void StartActualZoom() { //IL_0019: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)rectTransform == (Object)null)) { ((Transform)rectTransform).localScale = Vector3.one; startTime = Time.realtimeSinceStartup; zooming = true; Debug.Log((object)"Loading Tales: ZOOM START"); Debug.Log((object)("Loading Tales: ZOOM Duration = " + 12f + " seconds")); } } }