Decompiled source of Void Mind Levels v1.1.1

Mods/Void mind levels.dll

Decompiled 2 months ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Text;
using Il2CppInterop.Runtime.InteropTypes;
using Il2CppInterop.Runtime.InteropTypes.Fields;
using Il2CppSLZ.Marrow.Data;
using Il2CppSLZ.Marrow.Pool;
using Il2CppSLZ.Marrow.SceneStreaming;
using Il2CppSLZ.Marrow.Warehouse;
using Il2CppSLZ.Marrow.Zones;
using Il2CppSystem;
using Il2CppSystem.Collections.Generic;
using Il2CppTMPro;
using MelonLoader;
using MelonLoader.Lemons.Cryptography;
using Microsoft.CodeAnalysis;
using UnityEngine;
using Void_mind_levels;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: MelonInfo(typeof(Mod), "Void mind levels", "1.1.1", "Void Vapor Inc (Everythingonarm)", null)]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("Void mind levels")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("Void mind levels")]
[assembly: AssemblyTitle("Void mind levels")]
[assembly: AssemblyVersion("1.0.0.0")]
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;
		}
	}
}
namespace Void_mind_levels
{
	[RegisterTypeInIl2Cpp]
	internal class Generator : MonoBehaviour
	{
		public Il2CppReferenceField<GameObject> holder;

		public Il2CppReferenceField<GameObject> boxBase;

		public Il2CppReferenceField<GameObject> blackBox;

		public Il2CppValueField<Vector3> levelSize;

		public Il2CppValueField<Vector3> minBlockSize;

		public Il2CppValueField<Vector3> maxBlockSize;

		public Il2CppValueField<int> blocksQuantity;

		public Il2CppValueField<int> lightQuantity;

		public Il2CppValueField<int> ItemQuantity;

		public Il2CppValueField<Vector2> skyboxResolution;

		public Il2CppReferenceField<TextMeshPro> textField;

		public Il2CppReferenceField<MeshRenderer> skybox;

		public Il2CppReferenceField<ZoneMusic> musicZone;

		private byte[] seed;

		private Pallet[] neededPallets;

		private SpawnableCrate[] spawnableCrates;

		private Vector3 minPosition;

		private Vector3 maxPosition;

		private Texture2D genSkybox;

		private Stopwatch stopwatch;

		private bool isSlow;

		private Nullable<int> group;

		private Nullable<Vector3> scale;

		private MonoDisc[] songs;

		public Generator(IntPtr ptr)
			: base(ptr)
		{
		}

		public void Generate()
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Expected O, but got Unknown
			//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0102: Expected O, but got Unknown
			//IL_02ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_02fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0301: Unknown result type (might be due to invalid IL or missing references)
			//IL_030d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0317: Unknown result type (might be due to invalid IL or missing references)
			//IL_031c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0337: Unknown result type (might be due to invalid IL or missing references)
			LemonSHA256 val = new LemonSHA256();
			string s = " ";
			if (((TMP_Text)textField.Value).text != "")
			{
				s = ((TMP_Text)textField.Value).text;
			}
			Randomashaner.Initialize();
			seed = val.ComputeHash(Encoding.ASCII.GetBytes(s));
			Randomashaner.currsha = seed;
			byte[] array = new byte[32]
			{
				225, 7, 92, 208, 78, 38, 211, 184, 233, 227,
				130, 5, 224, 132, 131, 27, 169, 52, 47, 129,
				126, 24, 236, 57, 93, 225, 200, 43, 11, 175,
				11, 73
			};
			byte[] array2 = val.ComputeHash(seed);
			bool flag = true;
			for (int i = 0; i < 32; i++)
			{
				if (array2[i] != array[i])
				{
					flag = false;
					break;
				}
			}
			if (flag)
			{
				string text = "gb534d5b868247138g50d62f424d4144.Mfwfm.WpjeH114";
				string text2 = "";
				for (int j = 0; j < text.Length; j++)
				{
					if (text[j] != '.')
					{
						text2 += text[j] + 1;
					}
				}
				SceneStreamer.Load(new Barcode(text2), (Barcode)null);
				return;
			}
			array = new byte[32]
			{
				254, 113, 37, 196, 82, 72, 120, 107, 31, 183,
				102, 244, 73, 206, 141, 147, 1, 116, 155, 48,
				89, 39, 242, 54, 17, 95, 124, 43, 121, 88,
				143, 98
			};
			flag = true;
			for (int k = 0; k < 32; k++)
			{
				if (array2[k] != array[k])
				{
					flag = false;
					break;
				}
			}
			if (flag)
			{
				return;
			}
			neededPallets = (Pallet[])(object)new Pallet[2];
			Enumerator<Pallet> enumerator = AssetWarehouse.Instance.GetPallets().GetEnumerator();
			while (enumerator.MoveNext())
			{
				Pallet current = enumerator.Current;
				if (((Object)((Scannable)current).Barcode).ToString() == "SLZ.BONELAB.Core")
				{
					neededPallets[0] = current;
				}
				if (((Object)((Scannable)current).Barcode).ToString() == "SLZ.BONELAB.Content")
				{
					neededPallets[1] = current;
				}
			}
			List<SpawnableCrate> list = new List<SpawnableCrate>();
			Pallet[] array3 = neededPallets;
			for (int l = 0; l < array3.Length; l++)
			{
				Enumerator<Crate> enumerator2 = array3[l].Crates.GetEnumerator();
				while (enumerator2.MoveNext())
				{
					SpawnableCrate val2 = ((Il2CppObjectBase)enumerator2.Current).TryCast<SpawnableCrate>();
					if ((Object)(object)val2 != (Object)null && !((Scannable)val2).Title.Contains("Rig Manager") && !((Scannable)val2).Title.Contains("Load Fade"))
					{
						list.Add(val2);
					}
				}
			}
			spawnableCrates = list.ToArray();
			List<MonoDisc> list2 = new List<MonoDisc>();
			array3 = neededPallets;
			for (int l = 0; l < array3.Length; l++)
			{
				Enumerator<DataCard> enumerator3 = array3[l].DataCards.GetEnumerator();
				while (enumerator3.MoveNext())
				{
					MonoDisc val3 = ((Il2CppObjectBase)enumerator3.Current).TryCast<MonoDisc>();
					if ((Object)(object)val3 != (Object)null && !((Scannable)val3).Title.Contains("Intro") && !((Scannable)val3).Title.Contains("End") && (MarrowAsset)(object)val3._audioClip != (MarrowAsset)null)
					{
						list2.Add(val3);
					}
				}
			}
			songs = list2.ToArray();
			minPosition = -levelSize.Value / 2f;
			maxPosition = levelSize.Value / 2f;
			scale = new Nullable<Vector3>
			{
				value = new Vector3(1f, 1f, 1f)
			};
			group = new Nullable<int>
			{
				value = 0
			};
			stopwatch = new Stopwatch();
			MelonCoroutines.Start(GenerationRoutine());
		}

		public void OnDestroy()
		{
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			Physics.gravity = new Vector3(0f, -9.807f, 0f);
		}

		public void Update()
		{
			if (isSlow)
			{
				Time.timeScale = 1E-06f;
			}
		}

		private IEnumerator GenerationRoutine()
		{
			isSlow = true;
			blackBox.Value.SetActive(true);
			holder.Value.SetActive(false);
			for (int k = 0; k < Il2CppValueField<int>.op_Implicit(blocksQuantity); k++)
			{
				GameObject obj = Object.Instantiate<GameObject>(boxBase.Value, holder.Value.transform);
				Vector3 nextValueInRange = Randomashaner.GetNextValueInRange(Il2CppValueField<Vector3>.op_Implicit(minBlockSize), Il2CppValueField<Vector3>.op_Implicit(maxBlockSize));
				obj.transform.Find("art").localScale = nextValueInRange;
				((Component)obj.transform.Find("collide")).GetComponent<BoxCollider>().size = nextValueInRange;
				obj.transform.localPosition = Randomashaner.GetNextValueInRange(minPosition, maxPosition);
				obj.SetActive(true);
				if (stopwatch.ElapsedTicks > 2 * Stopwatch.Frequency)
				{
					stopwatch.Restart();
					yield return null;
				}
			}
			for (int k = 0; k < Il2CppValueField<int>.op_Implicit(lightQuantity); k++)
			{
				Light obj2 = new GameObject().AddComponent<Light>();
				((Component)obj2).transform.parent = holder.Value.transform;
				((Component)obj2).transform.localPosition = Randomashaner.GetNextValueInRange(minPosition, maxPosition);
				Vector3 nextValueInRange2 = Randomashaner.GetNextValueInRange(Vector3.zero, Vector3.one);
				obj2.color = Color.HSVToRGB(nextValueInRange2.x, nextValueInRange2.y, nextValueInRange2.z);
				obj2.intensity = Randomashaner.GetNextValueInRange(1f, 50f);
				obj2.range = 30f;
				if (stopwatch.ElapsedTicks > 2 * Stopwatch.Frequency)
				{
					stopwatch.Restart();
					yield return null;
				}
			}
			for (int k = 0; k < Il2CppValueField<int>.op_Implicit(ItemQuantity); k++)
			{
				Spawnable val = new Spawnable
				{
					crateRef = new SpawnableCrateReference(((Scannable)spawnableCrates[Randomashaner.GetNextValueInRange(0, spawnableCrates.Length - 1)]).Barcode.ID)
				};
				AssetSpawner.Register(val);
				AssetSpawner.SpawnAsync(val, Randomashaner.GetNextValueInRange(minPosition, maxPosition), default(Quaternion), scale, (Transform)null, true, group, (Action<GameObject>)null, (Action<GameObject>)null, (Action<GameObject>)null);
				if (stopwatch.ElapsedTicks > 2 * Stopwatch.Frequency)
				{
					stopwatch.Restart();
					yield return null;
				}
			}
			Light obj3 = new GameObject().AddComponent<Light>();
			obj3.type = (LightType)1;
			((Component)obj3).transform.parent = holder.Value.transform;
			Vector3 nextValueInRange3 = Randomashaner.GetNextValueInRange(Vector3.zero, Vector3.one);
			obj3.color = Color.HSVToRGB(nextValueInRange3.x, nextValueInRange3.y, nextValueInRange3.z);
			((Component)obj3).transform.localEulerAngles = Randomashaner.GetNextValueInRange(new Vector3(0f, 0f, 0f), new Vector3(360f, 360f, 360f));
			obj3.intensity = Randomashaner.GetNextValueInRange(0f, 3f);
			Physics.gravity = new Vector3(0f, 0f - Randomashaner.GetNextValueInRange(1f, 9.807f), 0f);
			musicZone.Value.track = new DataCardReference<MonoDisc>(((Scannable)songs[Randomashaner.GetNextValueInRange(0, songs.Length - 1)]).Barcode.ID);
			musicZone.Value.Play();
			blackBox.Value.SetActive(false);
			holder.Value.SetActive(true);
			isSlow = false;
			Time.timeScale = 1f;
			yield return null;
		}
	}
	public class Mod : MelonMod
	{
		public override void OnInitializeMelon()
		{
			((MelonBase)this).LoggerInstance.Msg("Hi! Void mind levels loaded");
		}
	}
	internal static class Randomashaner
	{
		public static LemonSHA256 Hasher;

		public static byte[] currsha { private get; set; }

		public static void Initialize()
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Expected O, but got Unknown
			currsha = new byte[1];
			Hasher = new LemonSHA256();
		}

		public static byte[] GetNextSha()
		{
			currsha = Hasher.ComputeHash(currsha);
			return currsha;
		}

		public static float GetNextValueInRange(float min, float max)
		{
			return min + (max - min) * (float)BitConverter.ToUInt64(GetNextSha(), 0) / 1.8446744E+19f;
		}

		public static Vector3 GetNextValueInRange(Vector3 min, Vector3 max)
		{
			//IL_0006: 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_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			byte[] nextSha = GetNextSha();
			return new Vector3(min.x + (max.x - min.x) * (float)BitConverter.ToUInt64(nextSha, 0) / 1.8446744E+19f, min.y + (max.y - min.y) * (float)BitConverter.ToUInt64(nextSha, 8) / 1.8446744E+19f, min.z + (max.z - min.z) * (float)BitConverter.ToUInt64(nextSha, 16) / 1.8446744E+19f);
		}

		public static int GetNextValueInRange(int min, int max)
		{
			return Mathf.RoundToInt(GetNextValueInRange((float)min, (float)max));
		}
	}
}