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 TilesEdition v1.1.0
TilesEdition.dll
Decompiled 2 years agousing System; using System.Diagnostics; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using TMPro; using TilesEdition.Utils; 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: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("TilesEdition")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyDescription("Tile's Edition Custom Tweaks")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("TilesEdition")] [assembly: AssemblyTitle("TilesEdition")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.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 TilesEdition { public static class PluginInformation { public const string PLUGIN_NAME = "TilesEdition"; public const string PLUGIN_VERSION = "1.0.0"; public const string PLUGIN_GUID = "io.github.nelertile.TilesEdition"; } [BepInPlugin("io.github.nelertile.TilesEdition", "TilesEdition", "1.0.0")] public class Plugin : BaseUnityPlugin { private readonly Harmony harmony = new Harmony("io.github.nelertile.TilesEdition"); private static Plugin Instance; public static ConfigEntry<bool> configDisplayCustomMainMenuLogo; public static ConfigEntry<bool> configReformatWeight; public static ConfigEntry<bool> configReformatTime; public static AssetBundle assets; public static ManualLogSource Log; public static Texture2D mainLogo; private void Awake() { if ((Object)(object)Instance == (Object)null) { Instance = this; } Log = ((BaseUnityPlugin)this).Logger; InitConfig(); try { harmony.PatchAll(); } catch (Exception ex) { Log.LogError((object)("Failed to patch: " + ex)); } Log.LogInfo((object)"Loading TilesEdition..."); AssetBundle bundle = BundleUtilities.LoadBundleFromInternalAssembly("tilesedition.assets", Assembly.GetExecutingAssembly()); mainLogo = bundle.LoadPersistentAsset<Texture2D>("lethaltilesedition.png"); Log.LogInfo((object)"Plugin io.github.nelertile.TilesEdition is loaded!"); } private void InitConfig() { configDisplayCustomMainMenuLogo = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "DisplayCustomMainMenuLogo", true, "Toggle main menu logo changes"); configReformatWeight = ((BaseUnityPlugin)this).Config.Bind<bool>("General.Reformat", "ReformatWeight", true, "Toggle weight reformatting"); configReformatTime = ((BaseUnityPlugin)this).Config.Bind<bool>("General.Reformat", "ReformatTime", true, "Toggle time reformatting"); } } [HarmonyPatch(typeof(MenuManager), "Awake")] public static class MenuManagerLogoOverridePatch { public static void Postfix(MenuManager __instance) { //IL_004a: 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) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) if (!Plugin.configDisplayCustomMainMenuLogo.Value) { return; } try { GameObject gameObject = ((Component)((Component)__instance).transform.parent).gameObject; Sprite sprite = Sprite.Create(Plugin.mainLogo, new Rect(0f, 0f, (float)((Texture)Plugin.mainLogo).width, (float)((Texture)Plugin.mainLogo).height), new Vector2(0.5f, 0.5f)); Transform val = gameObject.transform.Find("MenuContainer/MainButtons/HeaderImage"); if ((Object)(object)val != (Object)null) { ((Component)val).gameObject.GetComponent<Image>().sprite = sprite; } Transform val2 = gameObject.transform.Find("MenuContainer/LoadingScreen"); if ((Object)(object)val2 != (Object)null) { val2.localScale = new Vector3(1.02f, 1.06f, 1.02f); Transform val3 = val2.Find("Image"); if ((Object)(object)val3 != (Object)null) { ((Component)val3).GetComponent<Image>().sprite = sprite; } } } catch (Exception ex) { Plugin.Log.LogError((object)ex); } } } [HarmonyPatch(typeof(HUDManager), "Update")] public static class HUDManagerWeightFormatPatch { [HarmonyPostfix] private static void SetClock(ref TextMeshProUGUI ___weightCounter, ref Animator ___weightCounterAnimator) { if (Plugin.configReformatWeight.Value) { float num = Mathf.RoundToInt(Mathf.Clamp((GameNetworkManager.Instance.localPlayerController.carryWeight - 1f) * 0.4535f, 0f, 100f) * 105f); float num2 = Mathf.RoundToInt(Mathf.Clamp(GameNetworkManager.Instance.localPlayerController.carryWeight - 1f, 0f, 100f) * 105f); ((TMP_Text)___weightCounter).text = $"{num} kg"; ___weightCounterAnimator.SetFloat("weight", num2 / 130f); } } } [HarmonyPatch(typeof(HUDManager), "SetClock")] public static class HUDManagerClockFormatPatch { [HarmonyPrefix] private static bool SetClock(ref TextMeshProUGUI ___clockNumber, ref float timeNormalized, ref float numberOfHours) { if (Plugin.configReformatTime.Value) { int num = (int)(timeNormalized * (60f * numberOfHours)) + 360; int num2 = (int)Mathf.Floor((float)(num / 60)); int num3 = num % 60; ((TMP_Text)___clockNumber).text = $"{num2:00}:{num3:00}".TrimStart(new char[1] { '0' }); return false; } return true; } } } namespace TilesEdition.Utils { public class BundleUtilities { public static byte[] GetResourceBytes(string filename, Assembly assembly) { string[] manifestResourceNames = assembly.GetManifestResourceNames(); foreach (string text in manifestResourceNames) { if (!text.Contains(filename)) { continue; } using Stream stream = assembly.GetManifestResourceStream(text); if (stream == null) { return null; } byte[] array = new byte[stream.Length]; stream.Read(array, 0, array.Length); return array; } return null; } public static AssetBundle LoadBundleFromInternalAssembly(string filename, Assembly assembly) { return AssetBundle.LoadFromMemory(GetResourceBytes(filename, assembly)); } } public static class AssetBundleExtension { public static T LoadPersistentAsset<T>(this AssetBundle bundle, string name) where T : Object { Object val = bundle.LoadAsset(name); if (val != (Object)null) { val.hideFlags = (HideFlags)32; return (T)(object)val; } return default(T); } } }