Decompiled source of ShimejimePortals v1.0.0

ShimejimePortals/ShimejimePortals.dll

Decompiled 3 days 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 BepInEx.Configuration;
using BepInEx.Logging;
using HG.Reflection;
using Microsoft.CodeAnalysis;
using On.RoR2;
using RiskOfOptions;
using RiskOfOptions.Options;
using RoR2;
using UnityEngine;
using UnityEngine.SceneManagement;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: OptIn]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: IgnoresAccessChecksTo("")]
[assembly: AssemblyCompany("ShimejimePortals")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+aae3e36ed953227c6b1502b7d26552d89ae2ceae")]
[assembly: AssemblyProduct("ShimejimePortals")]
[assembly: AssemblyTitle("ShimejimePortals")]
[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 ShimejimePortals
{
	public static class Log
	{
		private static ManualLogSource _logSource;

		internal static void Init(ManualLogSource logSource)
		{
			_logSource = logSource;
		}

		internal static void Debug(object data)
		{
			_logSource.LogDebug(data);
		}

		internal static void Error(object data)
		{
			_logSource.LogError(data);
		}

		internal static void Fatal(object data)
		{
			_logSource.LogFatal(data);
		}

		internal static void Info(object data)
		{
			_logSource.LogInfo(data);
		}

		internal static void Message(object data)
		{
			_logSource.LogMessage(data);
		}

		internal static void Warning(object data)
		{
			_logSource.LogWarning(data);
		}
	}
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInPlugin("burboni4.ShimejimePortals", "ShimejimePortals", "1.0.0")]
	public class ShimejimePortals : BaseUnityPlugin
	{
		public const string PluginGUID = "burboni4.ShimejimePortals";

		public const string PluginAuthor = "burboni4";

		public const string PluginName = "ShimejimePortals";

		public const string PluginVersion = "1.0.0";

		public static AssetBundle bundle;

		public static Texture2D majimeb;

		public static Texture2D shijimab;

		public static ConfigEntry<bool> disableSeerStationEdges;

		public void Awake()
		{
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Expected O, but got Unknown
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Expected O, but got Unknown
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: Expected O, but got Unknown
			Log.Init(((BaseUnityPlugin)this).Logger);
			disableSeerStationEdges = ((BaseUnityPlugin)this).Config.Bind<bool>("Tweaks", "Disable seer edges", true, "Disables edges of seer station");
			ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(disableSeerStationEdges));
			if ((Object)(object)bundle == (Object)null)
			{
				bundle = AssetBundle.LoadFromFile(Path.Combine(Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location), "shimejime"));
			}
			if (Object.op_Implicit((Object)(object)bundle))
			{
				majimeb = bundle.LoadAsset<Texture2D>("majimeb");
				shijimab = bundle.LoadAsset<Texture2D>("shijimab");
			}
			SceneDirector.Start += new hook_Start(SceneDirector_Start);
			DirectorCore.TrySpawnObject += new hook_TrySpawnObject(OnVanillaPortalSpawn);
		}

		public void OnDestroy()
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Expected O, but got Unknown
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Expected O, but got Unknown
			SceneDirector.Start -= new hook_Start(SceneDirector_Start);
			DirectorCore.TrySpawnObject -= new hook_TrySpawnObject(OnVanillaPortalSpawn);
			if ((Object)(object)bundle != (Object)null)
			{
				bundle.Unload(false);
				bundle = null;
			}
		}

		private GameObject OnVanillaPortalSpawn(orig_TrySpawnObject orig, DirectorCore self, DirectorSpawnRequest directorSpawnRequest)
		{
			GameObject val = orig.Invoke(self, directorSpawnRequest);
			if (Object.op_Implicit((Object)(object)val))
			{
				ModifyPortal(val);
			}
			return val;
		}

		private static void ModifyPortal(GameObject obj)
		{
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)obj).name.Contains("Portal"))
			{
				return;
			}
			Log.Info("Director spawned portal");
			Renderer[] componentsInChildren = obj.GetComponentsInChildren<Renderer>(true);
			foreach (Renderer val in componentsInChildren)
			{
				Log.Info(((Object)val).name);
				if (((Object)val).name.Contains("Quad"))
				{
					Material material = val.material;
					((Component)val).transform.localScale = new Vector3(6f, 6f, 6f);
					if (Object.op_Implicit((Object)(object)majimeb) && Object.op_Implicit((Object)(object)shijimab))
					{
						material.SetTexture("_MainTex", (Texture)(object)Run.instance.runRNG.NextElementUniform<Texture2D>((Texture2D[])(object)new Texture2D[2] { majimeb, shijimab }));
					}
				}
			}
		}

		private void SceneDirector_Start(orig_Start orig, SceneDirector self)
		{
			//IL_0020: 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)
			orig.Invoke(self);
			if (!Object.op_Implicit((Object)(object)shijimab) || !Object.op_Implicit((Object)(object)majimeb))
			{
				return;
			}
			Scene activeScene = SceneManager.GetActiveScene();
			if (((Scene)(ref activeScene)).name == "bazaar")
			{
				GameObject val = GameObject.Find("SeerStation");
				if (!Object.op_Implicit((Object)(object)val))
				{
					Log.Error("Could not find");
				}
				else
				{
					Renderer[] componentsInChildren = val.GetComponentsInChildren<Renderer>();
					foreach (Renderer val2 in componentsInChildren)
					{
						if (((Object)val2).name == "Portal")
						{
							Material material = val2.material;
							material.SetTexture("_Cloud1Tex", (Texture)(object)shijimab);
							val2.materials = (Material[])(object)new Material[2] { material, material };
						}
						if (((Object)val2).name == "PortalEdges")
						{
							if (disableSeerStationEdges.Value)
							{
								((Component)val2).gameObject.SetActive(false);
							}
							else
							{
								((Component)val2).gameObject.SetActive(true);
							}
						}
						if (((Object)val2).name == "Donut")
						{
							if (disableSeerStationEdges.Value)
							{
								((Component)val2).gameObject.SetActive(false);
							}
							else
							{
								((Component)val2).gameObject.SetActive(true);
							}
						}
					}
				}
				GameObject val3 = GameObject.Find("SeerStation (1)");
				if (!Object.op_Implicit((Object)(object)val3))
				{
					Log.Error("Could not find seer station");
				}
				else
				{
					Renderer[] componentsInChildren = val3.GetComponentsInChildren<Renderer>();
					foreach (Renderer val4 in componentsInChildren)
					{
						if (((Object)val4).name == "Portal")
						{
							Material material2 = val4.material;
							material2.SetTexture("_Cloud1Tex", (Texture)(object)majimeb);
							val4.materials = (Material[])(object)new Material[2] { material2, material2 };
						}
						if (((Object)val4).name == "PortalEdges")
						{
							if (disableSeerStationEdges.Value)
							{
								((Component)val4).gameObject.SetActive(false);
							}
							else
							{
								((Component)val4).gameObject.SetActive(true);
							}
						}
						if (((Object)val4).name == "Donut")
						{
							if (disableSeerStationEdges.Value)
							{
								((Component)val4).gameObject.SetActive(false);
							}
							else
							{
								((Component)val4).gameObject.SetActive(true);
							}
						}
					}
				}
			}
			GenericInteraction[] array = Object.FindObjectsOfType<GenericInteraction>();
			foreach (GenericInteraction val5 in array)
			{
				if (((Object)val5).name.Contains("Portal"))
				{
					ModifyPortal(((Component)val5).gameObject);
				}
			}
		}
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}