Decompiled source of Krumpac Reforge Scenery v7.0.1

plugins/Krumpac_Core_Scene.dll

Decompiled 3 weeks ago
using System;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using HarmonyLib;
using JetBrains.Annotations;
using Microsoft.CodeAnalysis;
using UnityEngine;
using UnityEngine.SceneManagement;
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("SceneChanger")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("SceneChanger")]
[assembly: AssemblyCopyright("Copyright ©  2023")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("4F179F85-99CE-4510-9C87-C184941DEFBA")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.6.2", FrameworkDisplayName = ".NET Framework 4.6.2")]
[assembly: AssemblyVersion("1.0.0.0")]
[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 SceneChanger
{
	[BepInPlugin("kg.SceneChanger", "kg.SceneChanger", "1.0.0")]
	public class SceneChanger : BaseUnityPlugin
	{
		[HarmonyPatch(typeof(FejdStartup), "Awake")]
		private static class FejdStartup__Patch
		{
			[UsedImplicitly]
			private static void Postfix(FejdStartup __instance)
			{
				//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_0194: Unknown result type (might be due to invalid IL or missing references)
				//IL_01ba: Unknown result type (might be due to invalid IL or missing references)
				Scene scene = ((Component)__instance).gameObject.scene;
				GameObject gameObject = ((Scene)(ref scene)).GetRootGameObjects().First((GameObject x) => ((Object)x).name == "Static").gameObject;
				gameObject.SetActive(false);
				Sprite val = asset.LoadAsset<Sprite>("LOGO");
				if (val != null)
				{
					((Component)((Component)__instance).transform.Find("Menu/Logo/LOGO")).gameObject.GetComponent<Image>().sprite = val;
				}
				((Component)((Component)__instance).transform.Find("Menu/Logo/Ashlands")).gameObject.SetActive(false);
				((Component)((Component)__instance).transform.Find("Menu/Canvas Changelog")).gameObject.SetActive(false);
				GameObject val2 = asset.LoadAsset<GameObject>("START_SCENE");
				Transform val3 = val2.transform.Find("CREDITSPOSITION");
				if (val3 != null)
				{
					__instance.m_cameraMarkerCredits = val3;
				}
				Transform val4 = val2.transform.Find("MAINPOSITION");
				if (val4 != null)
				{
					__instance.m_cameraMarkerMain = val4;
				}
				Transform val5 = val2.transform.Find("STARTPOSITION");
				if (val5 != null)
				{
					__instance.m_cameraMarkerMain = val5;
				}
				RenderSettings.skybox = asset.LoadAsset<Material>("SKYBOX");
				Button component = ((Component)((Component)__instance).transform.Find("Menu/TopRight/StartGui_MerchButton/merchstore")).GetComponent<Button>();
				((Component)component).GetComponent<Image>().sprite = asset.LoadAsset<Sprite>("PATREON");
				((Graphic)((Component)component).GetComponent<Image>()).rectTransform.sizeDelta = new Vector2(400f, 100f);
				((Transform)((Graphic)((Component)component).GetComponent<Image>()).rectTransform).localScale = new Vector3(1f, 1f, 1f);
				Object.Instantiate<GameObject>(val2, gameObject.transform.parent);
			}
		}

		[HarmonyPatch(typeof(FejdStartup), "OnMerchStoreButton")]
		private static class FejdStartup_OnMerchStoreButton_Patch
		{
			[UsedImplicitly]
			private static bool Prefix(FejdStartup __instance)
			{
				Application.OpenURL("https://www.patreon.com/KrumpacModding");
				return false;
			}
		}

		[HarmonyPatch(typeof(FejdStartup), "Start")]
		private static class FejdStartup_Start_Patch
		{
			private static void Postfix(FejdStartup __instance)
			{
				((Component)((Component)__instance).transform.Find("Menu/modded_text")).gameObject.SetActive(false);
			}
		}

		private const string GUID = "kg.SceneChanger";

		private const string VERSION = "1.0.0";

		private static AssetBundle asset;

		private void Awake()
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			asset = GetAssetBundle_Memory("start_scene");
			new Harmony("kg.SceneChanger").PatchAll();
		}

		private static AssetBundle GetAssetBundle_Memory(string filename)
		{
			Assembly executingAssembly = Assembly.GetExecutingAssembly();
			string name = executingAssembly.GetManifestResourceNames().Single((string str) => str.EndsWith(filename));
			using Stream stream = executingAssembly.GetManifestResourceStream(name);
			return AssetBundle.LoadFromStream(stream);
		}

		private static AssetBundle GetAssetBundle_File(string name)
		{
			string text = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), name);
			return AssetBundle.LoadFromFile(text);
		}
	}
}