Decompiled source of UnstableRocksGameMode v1.1.0

BepInEx/plugins/lammas123.UnstableRocksGameMode.dll

Decompiled 5 days ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Core.Logging.Interpolation;
using BepInEx.IL2CPP;
using BepInEx.IL2CPP.Utils;
using BepInEx.Logging;
using CustomGameModes;
using HarmonyLib;
using Il2CppSystem.Collections.Generic;
using Microsoft.CodeAnalysis;
using UnhollowerRuntimeLib;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.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 UnstableRocksGameMode
{
	public sealed class CustomGameModeUnstableRocks : CustomGameMode
	{
		internal class UnstableRock : MonoBehaviour
		{
			internal GameObject piece;

			internal UnstableRockStandSlideCheese rockCheese;

			internal void Awake()
			{
				//IL_002f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0048: Unknown result type (might be due to invalid IL or missing references)
				((Component)this).gameObject.layer = 14;
				BoxCollider obj = ((Component)this).gameObject.AddComponent<BoxCollider>();
				((Collider)obj).isTrigger = true;
				obj.size = new Vector3(8f, 8f, 2f);
				obj.center = new Vector3(-0.3f, -0.1f, 0.25f);
			}

			internal void OnTriggerStay(Collider collider)
			{
				//IL_0016: Unknown result type (might be due to invalid IL or missing references)
				//IL_001c: Invalid comparison between Unknown and I4
				if (MonoBehaviourPublicObInUIgaStCSBoStcuCSUnique.Instance.IsLobbyOwner() && (int)MonoBehaviourPublicDi2UIObacspDi2UIObUnique.Instance.gameMode.modeState == 1 && shouldRocksBreak && ((Component)collider).gameObject.layer == 8)
				{
					int num = MonoBehaviourPublicSipiGaLipi1InGaLi11.Instance.pieces.IndexOf(piece);
					if (num != -1)
					{
						MonoBehaviourPublicInInUnique.PieceFall(num);
					}
					Object.Destroy((Object)(object)((Component)this).gameObject);
					if (Object.op_Implicit((Object)(object)rockCheese))
					{
						Object.Destroy((Object)(object)((Component)rockCheese).gameObject);
					}
				}
			}
		}

		internal class UnstableRockStandSlideCheese : MonoBehaviour
		{
			internal GameObject piece;

			internal UnstableRock rock;

			internal int inCollider;

			internal void Awake()
			{
				//IL_002f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0048: Unknown result type (might be due to invalid IL or missing references)
				((Component)this).gameObject.layer = 14;
				BoxCollider obj = ((Component)this).gameObject.AddComponent<BoxCollider>();
				((Collider)obj).isTrigger = true;
				obj.size = new Vector3(8f, 8f, 6f);
				obj.center = new Vector3(-0.3f, -0.1f, 4.25f);
			}

			internal void OnTriggerEnter(Collider collider)
			{
				//IL_003c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0042: Invalid comparison between Unknown and I4
				if (MonoBehaviourPublicObInUIgaStCSBoStcuCSUnique.Instance.IsLobbyOwner() && ((Component)collider).gameObject.layer == 8)
				{
					inCollider++;
					if (inCollider == 1 && (int)MonoBehaviourPublicDi2UIObacspDi2UIObUnique.Instance.gameMode.modeState == 1 && shouldRocksBreak)
					{
						((MonoBehaviour)this).Invoke("PieceFall", 0.75f);
					}
				}
			}

			internal void OnTriggerExit(Collider collider)
			{
				if (MonoBehaviourPublicObInUIgaStCSBoStcuCSUnique.Instance.IsLobbyOwner() && ((Component)collider).gameObject.layer == 8)
				{
					inCollider--;
					if (inCollider < 0)
					{
						inCollider = 0;
					}
					if (inCollider == 0)
					{
						((MonoBehaviour)this).CancelInvoke("PieceFall");
					}
				}
			}

			internal void PieceFall()
			{
				int num = MonoBehaviourPublicSipiGaLipi1InGaLi11.Instance.pieces.IndexOf(piece);
				if (num != -1)
				{
					MonoBehaviourPublicInInUnique.PieceFall(num);
				}
				Object.Destroy((Object)(object)((Component)this).gameObject);
				if (Object.op_Implicit((Object)(object)rock))
				{
					Object.Destroy((Object)(object)((Component)rock).gameObject);
				}
			}
		}

		[CompilerGenerated]
		private sealed class <StartDelay>d__6 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			object IEnumerator<object>.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			object IEnumerator.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			[DebuggerHidden]
			public <StartDelay>d__6(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//IL_001d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0027: Expected O, but got Unknown
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<>2__current = (object)new WaitForSeconds(2f);
					<>1__state = 1;
					return true;
				case 1:
					<>1__state = -1;
					shouldRocksBreak = true;
					foreach (UnstableRockStandSlideCheese item in rocksCheese)
					{
						if (item.inCollider >= 1)
						{
							((MonoBehaviour)item).Invoke("PieceFall", 0.75f);
						}
					}
					return false;
				}
			}

			bool IEnumerator.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				return this.MoveNext();
			}

			[DebuggerHidden]
			void IEnumerator.Reset()
			{
				throw new NotSupportedException();
			}
		}

		internal Harmony patches;

		internal static bool shouldRocksBreak;

		internal static HashSet<UnstableRockStandSlideCheese> rocksCheese;

		public CustomGameModeUnstableRocks()
			: base("Unstable Rocks", "• The rocks are unstable and will break shortly after being stood on\n\n• Stay on your toes and keep moving, but not too fast!", (EnumNPublicSealedvaWaReBaStTaHiBoLiFaUnique)8, (EnumNPublicSealedvaWaReBaStTaHiBoLiFaUnique)8, (string)null, true, (EnumNPublicSealedvaNoInMeFuScWi7vUnique)1, true, 0, int.MaxValue, 40, 40, 40, (IEnumerable<string>)new <>z__ReadOnlyArray<string>(new string[4] { "Crusty Rocks", "Icy Rocks", "Lava Lake", "Sandy Stones" }), 4, 5, 9, 100)
		{
			ClassInjector.RegisterTypeInIl2Cpp<UnstableRock>();
			ClassInjector.RegisterTypeInIl2Cpp<UnstableRockStandSlideCheese>();
		}

		public override void PreInit()
		{
			shouldRocksBreak = false;
			patches = Harmony.CreateAndPatchAll(((object)this).GetType(), (string)null);
		}

		public override void PostEnd()
		{
			shouldRocksBreak = false;
			Harmony obj = patches;
			if (obj != null)
			{
				obj.UnpatchSelf();
			}
		}

		[IteratorStateMachine(typeof(<StartDelay>d__6))]
		public static IEnumerator StartDelay()
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <StartDelay>d__6(0);
		}

		[HarmonyPatch(typeof(GameModePublicInSiInSiInInUnique), "InitMode")]
		[HarmonyPostfix]
		internal static void PostInitMode(GameModePublicInSiInSiInInUnique __instance)
		{
			if (MonoBehaviourPublicObInUIgaStCSBoStcuCSUnique.Instance.IsLobbyOwner())
			{
				__instance.field_Private_Int32_0 = (int)(35f * Mathf.Pow((float)MonoBehaviourPublicCSDi2UIInstObUIloDiUnique.Instance.nextRoundPlayers, 0.75f));
			}
		}

		[HarmonyPatch(typeof(GameModePublicInSiInSiInInUnique), "OnFreezeOver")]
		[HarmonyPrefix]
		internal static bool PreOnFreezeOver()
		{
			//IL_004f: 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_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
			if (!MonoBehaviourPublicObInUIgaStCSBoStcuCSUnique.Instance.IsLobbyOwner())
			{
				return false;
			}
			rocksCheese = new HashSet<UnstableRockStandSlideCheese>(MonoBehaviourPublicSipiGaLipi1InGaLi11.Instance.pieces.Count);
			Enumerator<GameObject> enumerator = MonoBehaviourPublicSipiGaLipi1InGaLi11.Instance.pieces.GetEnumerator();
			while (enumerator.MoveNext())
			{
				GameObject current = enumerator.Current;
				Transform transform = current.transform;
				GameObject val = new GameObject("Unstable Rock");
				val.transform.position = transform.position;
				val.transform.rotation = transform.rotation;
				val.transform.localScale = Vector3.one;
				UnstableRock unstableRock = val.AddComponent<UnstableRock>();
				unstableRock.piece = current;
				GameObject val2 = new GameObject("Unstable Rock Stand Slide Cheese");
				val2.transform.position = transform.position;
				val2.transform.localRotation = transform.rotation;
				val2.transform.localScale = Vector3.one;
				UnstableRockStandSlideCheese unstableRockStandSlideCheese = val2.AddComponent<UnstableRockStandSlideCheese>();
				unstableRockStandSlideCheese.piece = current;
				unstableRockStandSlideCheese.rock = unstableRock;
				unstableRock.rockCheese = unstableRockStandSlideCheese;
				rocksCheese.Add(unstableRockStandSlideCheese);
			}
			MonoBehaviourExtensions.StartCoroutine((MonoBehaviour)(object)MonoBehaviourPublicDi2UIObacspDi2UIObUnique.Instance, StartDelay());
			return false;
		}

		[HarmonyPatch(typeof(GameModePublicInSiInSiInInUnique), "SetPieces")]
		[HarmonyPostfix]
		internal static void PostSetPieces(GameModePublicInSiInSiInInUnique __instance)
		{
			((GameMode)__instance).modeTime = 45f;
		}
	}
	[BepInPlugin("lammas123.UnstableRocksGameMode", "UnstableRocksGameMode", "1.1.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public sealed class UnstableRocksGameMode : BasePlugin
	{
		public override void Load()
		{
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Expected O, but got Unknown
			CultureInfo.CurrentCulture = CultureInfo.InvariantCulture;
			CultureInfo.CurrentUICulture = CultureInfo.InvariantCulture;
			CultureInfo.DefaultThreadCurrentCulture = CultureInfo.InvariantCulture;
			CultureInfo.DefaultThreadCurrentUICulture = CultureInfo.InvariantCulture;
			Api.RegisterCustomGameMode((CustomGameMode)(object)new CustomGameModeUnstableRocks());
			ManualLogSource log = ((BasePlugin)this).Log;
			bool flag = default(bool);
			BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(15, 2, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Initialized [");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("UnstableRocksGameMode");
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" ");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("1.1.0");
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("]");
			}
			log.LogInfo(val);
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "lammas123.UnstableRocksGameMode";

		public const string PLUGIN_NAME = "UnstableRocksGameMode";

		public const string PLUGIN_VERSION = "1.1.0";
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}
[CompilerGenerated]
internal sealed class <>z__ReadOnlyArray<T> : IEnumerable, ICollection, IList, IEnumerable<T>, IReadOnlyCollection<T>, IReadOnlyList<T>, ICollection<T>, IList<T>
{
	int ICollection.Count => _items.Length;

	bool ICollection.IsSynchronized => false;

	object ICollection.SyncRoot => this;

	object IList.this[int index]
	{
		get
		{
			return _items[index];
		}
		set
		{
			throw new NotSupportedException();
		}
	}

	bool IList.IsFixedSize => true;

	bool IList.IsReadOnly => true;

	int IReadOnlyCollection<T>.Count => _items.Length;

	T IReadOnlyList<T>.this[int index] => _items[index];

	int ICollection<T>.Count => _items.Length;

	bool ICollection<T>.IsReadOnly => true;

	T IList<T>.this[int index]
	{
		get
		{
			return _items[index];
		}
		set
		{
			throw new NotSupportedException();
		}
	}

	public <>z__ReadOnlyArray(T[] items)
	{
		_items = items;
	}

	IEnumerator IEnumerable.GetEnumerator()
	{
		return ((IEnumerable)_items).GetEnumerator();
	}

	void ICollection.CopyTo(Array array, int index)
	{
		((ICollection)_items).CopyTo(array, index);
	}

	int IList.Add(object value)
	{
		throw new NotSupportedException();
	}

	void IList.Clear()
	{
		throw new NotSupportedException();
	}

	bool IList.Contains(object value)
	{
		return ((IList)_items).Contains(value);
	}

	int IList.IndexOf(object value)
	{
		return ((IList)_items).IndexOf(value);
	}

	void IList.Insert(int index, object value)
	{
		throw new NotSupportedException();
	}

	void IList.Remove(object value)
	{
		throw new NotSupportedException();
	}

	void IList.RemoveAt(int index)
	{
		throw new NotSupportedException();
	}

	IEnumerator<T> IEnumerable<T>.GetEnumerator()
	{
		return ((IEnumerable<T>)_items).GetEnumerator();
	}

	void ICollection<T>.Add(T item)
	{
		throw new NotSupportedException();
	}

	void ICollection<T>.Clear()
	{
		throw new NotSupportedException();
	}

	bool ICollection<T>.Contains(T item)
	{
		return ((ICollection<T>)_items).Contains(item);
	}

	void ICollection<T>.CopyTo(T[] array, int arrayIndex)
	{
		((ICollection<T>)_items).CopyTo(array, arrayIndex);
	}

	bool ICollection<T>.Remove(T item)
	{
		throw new NotSupportedException();
	}

	int IList<T>.IndexOf(T item)
	{
		return ((IList<T>)_items).IndexOf(item);
	}

	void IList<T>.Insert(int index, T item)
	{
		throw new NotSupportedException();
	}

	void IList<T>.RemoveAt(int index)
	{
		throw new NotSupportedException();
	}
}