Decompiled source of GlassCybergrindStartRoom v1.0.1

plugins\GlassCybergrindStartRoom.dll

Decompiled 3 hours ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
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("GlassCybergrindStartRoom")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+af679c3a47d1d7af1cd1c0a942ca2332eea6378c")]
[assembly: AssemblyProduct("GlassCybergrindStartRoom")]
[assembly: AssemblyTitle("GlassCybergrindStartRoom")]
[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 GlassCybergrindStartRoom
{
	[BepInPlugin("com.github.end-4.glassCybergrindStartRoom", "GlassCybergrindStartRoom", "1.0.1")]
	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.glassCybergrindStartRoom";

		public const string PluginName = "GlassCybergrindStartRoom";

		public const string PluginVersion = "1.0.1";

		internal static GameObject RoomCeilingPrefab;

		internal static GameObject RoomWallsPrefab;

		internal static GameObject RoomFloorPrefab;

		internal static GameObject HallwayPrefab;

		internal static GameObject HallwayWallsPrefab;

		private static readonly string BundlePath = Path.Combine(workingDir, "assets", "stained_glass_cybergrind_start_room.bundle");

		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 LoadObjects()
		{
			AssetBundle val = AssetBundle.LoadFromFile(BundlePath);
			if ((Object)(object)val == (Object)null)
			{
				Log.LogError((object)"Couldn't load asset bundle. Aborting.");
				return;
			}
			RoomCeilingPrefab = val.LoadAsset<GameObject>("Ceiling");
			RoomWallsPrefab = val.LoadAsset<GameObject>("Walls");
			RoomFloorPrefab = val.LoadAsset<GameObject>("Floor");
			HallwayWallsPrefab = val.LoadAsset<GameObject>("HallwayWalls");
			val.Unload(false);
		}

		private void Awake()
		{
			Log = ((BaseUnityPlugin)this).Logger;
			LoadObjects();
			SceneManager.sceneLoaded += delegate
			{
				//IL_0012: Unknown result type (might be due to invalid IL or missing references)
				//IL_0017: Unknown result type (might be due to invalid IL or missing references)
				//IL_011d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0135: Unknown result type (might be due to invalid IL or missing references)
				//IL_014d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0163: Unknown result type (might be due to invalid IL or missing references)
				if (!(SceneHelper.CurrentScene != "Endless"))
				{
					Scene activeScene = SceneManager.GetActiveScene();
					GameObject val = ((IEnumerable<GameObject>)((Scene)(ref activeScene)).GetRootGameObjects()).FirstOrDefault((Func<GameObject, bool>)((GameObject obj) => ((Object)obj).name == "FirstRoom"));
					if (Object.op_Implicit((Object)(object)val))
					{
						Transform transform = FindNestedObject(val, "Room/Room").transform;
						Transform transform2 = FindNestedObject(val, "Room/Hallway").transform;
						GameObject val2 = FindNestedObject(((Component)transform).gameObject, "Floor");
						GameObject val3 = FindNestedObject(((Component)transform).gameObject, "Ceiling");
						GameObject val4 = FindNestedObject(((Component)transform).gameObject, "Walls");
						GameObject val5 = FindNestedObject(((Component)transform2).gameObject, "Walls");
						val2.SetActive(false);
						val3.SetActive(false);
						val4.SetActive(false);
						val5.SetActive(false);
						GameObject val6 = Object.Instantiate<GameObject>(RoomFloorPrefab, transform, true);
						GameObject val7 = Object.Instantiate<GameObject>(RoomCeilingPrefab, transform, true);
						GameObject val8 = Object.Instantiate<GameObject>(RoomWallsPrefab, transform, true);
						GameObject obj2 = Object.Instantiate<GameObject>(HallwayWallsPrefab, transform2, true);
						val6.transform.localPosition = val2.transform.localPosition;
						val7.transform.localPosition = val3.transform.localPosition;
						val8.transform.localPosition = val4.transform.localPosition;
						obj2.transform.localPosition = val5.transform.localPosition;
					}
				}
			};
			Log.LogInfo((object)"GlassCybergrindStartRoom loaded!");
		}
	}
}