Decompiled source of RubiksPrisons v1.0.0

plugins\RubiksPrisons.dll

Decompiled 6 hours ago
using System;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
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("RubiksPrisons")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+e1e0be21173f91f26fce133e5afa6275e58c5c56")]
[assembly: AssemblyProduct("RubiksPrisons")]
[assembly: AssemblyTitle("RubiksPrisons")]
[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.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 RubiksPrisons
{
	[BepInPlugin("com.github.end-4.rubiksPrisons", "RubiksPrisons", "1.0.0")]
	public class Plugin : BaseUnityPlugin
	{
		internal static ManualLogSource? Log;

		public static string workingPath = Assembly.GetExecutingAssembly().Location;

		public static string workingDir = Path.GetDirectoryName(workingPath);

		public const string PluginGUID = "com.github.end-4.rubiksPrisons";

		public const string PluginName = "RubiksPrisons";

		public const string PluginVersion = "1.0.0";

		public static Texture2D LoadTexture(string FilePath)
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Expected O, but got Unknown
			if (File.Exists(FilePath))
			{
				byte[] array = File.ReadAllBytes(FilePath);
				Texture2D val = new Texture2D(2, 2);
				if (ImageConversion.LoadImage(val, array))
				{
					return val;
				}
			}
			return null;
		}

		internal static GameObject FindNestedObject(GameObject baseObject, string path)
		{
			Transform val = baseObject.transform;
			string[] array = path.Split("/");
			foreach (string text in array)
			{
				val = ((Component)val).transform.Find(text);
				if ((Object)(object)val == (Object)null)
				{
					Log.LogWarning((object)(text + " not found for object path " + ((Object)baseObject).name + "/" + path));
					return null;
				}
			}
			return ((Component)val).gameObject;
		}

		private void Awake()
		{
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			Log = ((BaseUnityPlugin)this).Logger;
			SceneManager.sceneLoaded += delegate
			{
				Material[] array = Resources.FindObjectsOfTypeAll<Material>();
				Texture2D mainTexture = LoadTexture(Path.Combine(workingDir, "assets/T_FleshPrison.png"));
				Texture2D mainTexture2 = LoadTexture(Path.Combine(workingDir, "assets/T_FleshPrison2.png"));
				Material[] array2 = array;
				foreach (Material val in array2)
				{
					if (((Object)val).name == "FleshPrison" || ((Object)val).name == "FleshPrisonUnlit")
					{
						val.mainTexture = (Texture)(object)mainTexture;
					}
					else if (((Object)val).name == "FleshPanopticon" || ((Object)val).name == "FleshPanopticon Unlit")
					{
						val.mainTexture = (Texture)(object)mainTexture2;
					}
				}
			};
			new Harmony("RubiksPrisons").PatchAll();
			Log.LogInfo((object)"RubiksPrisons loaded!");
		}
	}
	[HarmonyPatch(typeof(FleshPrison), "ChangeTexture")]
	public class NoTextureChangePatch
	{
		private static bool Prefix(FleshPrison __instance, Texture tex)
		{
			return false;
		}
	}
}