Decompiled source of SwapLogo v0.1.2

SwapLogo.dll

Decompiled 16 hours ago
using 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 Microsoft.CodeAnalysis;
using UnityEngine;
using UnityEngine.SceneManagement;

[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("SwapLogo")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("0.1.2.0")]
[assembly: AssemblyInformationalVersion("0.1.2+51d7a0d20b3906998303940767d3e9ed101af254")]
[assembly: AssemblyProduct("SwapLogo")]
[assembly: AssemblyTitle("SwapLogo")]
[assembly: AssemblyMetadata("RepositoryUrl", "https://github.com/CarrieForle/SwapLogoSilksong")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.1.2.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.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]
	[Microsoft.CodeAnalysis.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]
	[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 BepInEx
{
	[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
	[Conditional("CodeGeneration")]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class BepInAutoPluginAttribute : Attribute
	{
		public BepInAutoPluginAttribute(string? id = null, string? name = null, string? version = null)
		{
		}
	}
}
namespace BepInEx.Preloader.Core.Patching
{
	[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
	[Conditional("CodeGeneration")]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class PatcherAutoPluginAttribute : Attribute
	{
		public PatcherAutoPluginAttribute(string? id = null, string? name = null, string? version = null)
		{
		}
	}
}
namespace Microsoft.CodeAnalysis
{
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace SwapLogo
{
	[BepInPlugin("io.github.carrieforle.swaplogo", "SwapLogo", "0.1.2")]
	public class SwapLogoPlugin : BaseUnityPlugin
	{
		public const string Id = "io.github.carrieforle.swaplogo";

		public static string Name => "SwapLogo";

		public static string Version => "0.1.2";

		private void Awake()
		{
			SceneManager.activeSceneChanged += delegate(Scene fromScene, Scene toScene)
			{
				if (!(((Scene)(ref toScene)).name != "Pre_Menu_Intro"))
				{
					GameObject val = GameObject.Find("StartManager/1 - Team Cherry Logo");
					SpriteRenderer val2 = default(SpriteRenderer);
					if (!((Object)(object)val == (Object)null) && val.TryGetComponent<SpriteRenderer>(ref val2))
					{
						(Sprite, string)? tuple = LoadSpriteFromFile("logo.png", "logo.jpg", "logo.jpeg");
						if (tuple.HasValue)
						{
							val2.sprite = tuple.Value.Item1;
							((BaseUnityPlugin)this).Logger.LogInfo((object)("Successfully swapped logo with \"" + tuple.Value.Item2 + "\""));
						}
					}
				}
			};
		}

		private (Sprite, string)? LoadSpriteFromFile(params string[] filePaths)
		{
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Expected O, but got Unknown
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			Rect val3 = default(Rect);
			Vector2 val4 = default(Vector2);
			foreach (string text in filePaths)
			{
				string text2 = Path.Combine(Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location), text);
				Sprite val = null;
				try
				{
					byte[] array = File.ReadAllBytes(text2);
					Texture2D val2 = new Texture2D(0, 0);
					if (ImageConversion.LoadImage(val2, array))
					{
						((Rect)(ref val3))..ctor(0f, 0f, (float)((Texture)val2).width, (float)((Texture)val2).height);
						((Vector2)(ref val4))..ctor(0.5f, 0.5f);
						val = Sprite.Create(val2, val3, val4);
					}
				}
				catch
				{
				}
				if ((Object)(object)val == (Object)null)
				{
					((BaseUnityPlugin)this).Logger.LogInfo((object)("Failed to load sprite frorm \"" + text2 + "\""));
					continue;
				}
				return (val, text);
			}
			return null;
		}
	}
}