Decompiled source of SomeOptimizations v0.1.5

plugins/com.github.steampunk0108.someoptimizations.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.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Photon.Pun;
using Sirenix.Utilities;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("com.github.steampunk0108.someoptimizations")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("0.1.0.0")]
[assembly: AssemblyInformationalVersion("0.1.0")]
[assembly: AssemblyProduct("com.github.steampunk0108.someoptimizations")]
[assembly: AssemblyTitle("someoptimizations")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.1.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.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 BepInEx
{
	[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
	[Conditional("CodeGeneration")]
	internal sealed class BepInAutoPluginAttribute : Attribute
	{
		public BepInAutoPluginAttribute(string? id = null, string? name = null, string? version = null)
		{
		}
	}
}
namespace BepInEx.Preloader.Core.Patching
{
	[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
	[Conditional("CodeGeneration")]
	internal sealed class PatcherAutoPluginAttribute : Attribute
	{
		public PatcherAutoPluginAttribute(string? id = null, string? name = null, string? version = null)
		{
		}
	}
}
namespace someoptimizations
{
	[BepInPlugin("com.github.steampunk0108.someoptimizations", "someoptimizations", "0.1.0")]
	public class Plugin : BaseUnityPlugin
	{
		[HarmonyPatch(typeof(Item))]
		public static class ItemPatch
		{
			[CompilerGenerated]
			private sealed class <Culling>d__1 : IEnumerator<object>, IEnumerator, IDisposable
			{
				private int <>1__state;

				private object <>2__current;

				public Item __instance;

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

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

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

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

				private bool MoveNext()
				{
					//IL_0020: Unknown result type (might be due to invalid IL or missing references)
					//IL_0026: Invalid comparison between Unknown and I4
					//IL_0123: Unknown result type (might be due to invalid IL or missing references)
					//IL_012d: Expected O, but got Unknown
					//IL_0035: Unknown result type (might be due to invalid IL or missing references)
					//IL_0045: Unknown result type (might be due to invalid IL or missing references)
					int num = <>1__state;
					if (num != 0)
					{
						if (num != 1)
						{
							return false;
						}
						<>1__state = -1;
					}
					else
					{
						<>1__state = -1;
					}
					if ((int)__instance.itemState != 2)
					{
						if (Vector3.Distance(((Component)Camera.main).transform.position, ((Component)__instance).transform.position) < config_cull_distance.Value)
						{
							LinqExtensions.ForEach<Rigidbody>((IEnumerable<Rigidbody>)((Component)__instance).GetComponentsInChildren<Rigidbody>(), (Action<Rigidbody>)delegate
							{
							});
							LinqExtensions.ForEach<MeshRenderer>((IEnumerable<MeshRenderer>)((Component)__instance).GetComponentsInChildren<MeshRenderer>(), (Action<MeshRenderer>)delegate(MeshRenderer meshRenderer)
							{
								((Renderer)meshRenderer).enabled = true;
							});
						}
						else
						{
							LinqExtensions.ForEach<Rigidbody>((IEnumerable<Rigidbody>)((Component)__instance).GetComponentsInChildren<Rigidbody>(), (Action<Rigidbody>)delegate
							{
							});
							LinqExtensions.ForEach<MeshRenderer>((IEnumerable<MeshRenderer>)((Component)__instance).GetComponentsInChildren<MeshRenderer>(), (Action<MeshRenderer>)delegate(MeshRenderer meshRenderer)
							{
								((Renderer)meshRenderer).enabled = false;
							});
						}
					}
					<>2__current = (object)new WaitForSeconds(0.2f);
					<>1__state = 1;
					return true;
				}

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

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

			[HarmonyPatch("Start")]
			[HarmonyPostfix]
			private static void Start3(Item __instance)
			{
				//IL_000e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0014: Invalid comparison between Unknown and I4
				//IL_0023: Unknown result type (might be due to invalid IL or missing references)
				//IL_002e: Unknown result type (might be due to invalid IL or missing references)
				((MonoBehaviour)__instance).StartCoroutine(Culling(__instance));
				if ((int)__instance.itemState == 2)
				{
					return;
				}
				if (Vector3.Distance(((Component)Camera.main).transform.position, ((Component)__instance).transform.position) < config_cull_distance.Value)
				{
					LinqExtensions.ForEach<Rigidbody>((IEnumerable<Rigidbody>)((Component)__instance).GetComponentsInChildren<Rigidbody>(), (Action<Rigidbody>)delegate
					{
					});
					LinqExtensions.ForEach<MeshRenderer>((IEnumerable<MeshRenderer>)((Component)__instance).GetComponentsInChildren<MeshRenderer>(), (Action<MeshRenderer>)delegate(MeshRenderer meshRenderer)
					{
						((Renderer)meshRenderer).enabled = true;
					});
				}
				else
				{
					LinqExtensions.ForEach<Rigidbody>((IEnumerable<Rigidbody>)((Component)__instance).GetComponentsInChildren<Rigidbody>(), (Action<Rigidbody>)delegate
					{
					});
					LinqExtensions.ForEach<MeshRenderer>((IEnumerable<MeshRenderer>)((Component)__instance).GetComponentsInChildren<MeshRenderer>(), (Action<MeshRenderer>)delegate(MeshRenderer meshRenderer)
					{
						((Renderer)meshRenderer).enabled = false;
					});
				}
			}

			[IteratorStateMachine(typeof(<Culling>d__1))]
			private static IEnumerator Culling(Item __instance)
			{
				//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
				return new <Culling>d__1(0)
				{
					__instance = __instance
				};
			}
		}

		public static class CharacterPatch
		{
			[CompilerGenerated]
			private sealed class <CullingC>d__1 : IEnumerator<object>, IEnumerator, IDisposable
			{
				private int <>1__state;

				private object <>2__current;

				public Character __instance;

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

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

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

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

				private bool MoveNext()
				{
					//IL_0131: Unknown result type (might be due to invalid IL or missing references)
					//IL_013b: Expected O, but got Unknown
					//IL_0043: Unknown result type (might be due to invalid IL or missing references)
					//IL_0053: Unknown result type (might be due to invalid IL or missing references)
					int num = <>1__state;
					if (num != 0)
					{
						if (num != 1)
						{
							return false;
						}
						<>1__state = -1;
					}
					else
					{
						<>1__state = -1;
					}
					if (config_player_enable_cull.Value && !__instance.IsLocal)
					{
						if (Vector3.Distance(((Component)Camera.main).transform.position, ((Component)__instance).transform.position) < config_player_cull_distance.Value)
						{
							LinqExtensions.ForEach<Rigidbody>((IEnumerable<Rigidbody>)((Component)__instance).GetComponentsInChildren<Rigidbody>(), (Action<Rigidbody>)delegate
							{
							});
							LinqExtensions.ForEach<MeshRenderer>((IEnumerable<MeshRenderer>)((Component)__instance).GetComponentsInChildren<MeshRenderer>(), (Action<MeshRenderer>)delegate(MeshRenderer meshRenderer)
							{
								((Renderer)meshRenderer).enabled = true;
							});
						}
						else
						{
							LinqExtensions.ForEach<Rigidbody>((IEnumerable<Rigidbody>)((Component)__instance).GetComponentsInChildren<Rigidbody>(), (Action<Rigidbody>)delegate
							{
							});
							LinqExtensions.ForEach<MeshRenderer>((IEnumerable<MeshRenderer>)((Component)__instance).GetComponentsInChildren<MeshRenderer>(), (Action<MeshRenderer>)delegate(MeshRenderer meshRenderer)
							{
								((Renderer)meshRenderer).enabled = false;
							});
						}
					}
					<>2__current = (object)new WaitForSeconds(0.2f);
					<>1__state = 1;
					return true;
				}

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

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

			[HarmonyPatch("Start")]
			[HarmonyPostfix]
			private static void Start3(Character __instance)
			{
				((MonoBehaviour)__instance).StartCoroutine(CullingC(__instance));
			}

			[IteratorStateMachine(typeof(<CullingC>d__1))]
			private static IEnumerator CullingC(Character __instance)
			{
				//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
				return new <CullingC>d__1(0)
				{
					__instance = __instance
				};
			}
		}

		private readonly Harmony _harmony = new Harmony("com.github.steampunk0108.someoptimizations");

		private static ConfigEntry<float> config_cull_distance;

		private static ConfigEntry<float> config_player_cull_distance;

		private static ConfigEntry<bool> config_player_enable_cull;

		public const string Id = "com.github.steampunk0108.someoptimizations";

		internal static ManualLogSource Log { get; private set; }

		public static string Name => "someoptimizations";

		public static string Version => "0.1.0";

		private void Awake()
		{
			config_cull_distance = ((BaseUnityPlugin)this).Config.Bind<float>("General", "ItemCullDistance", 20f, "Max distance at which items start culling");
			config_player_enable_cull = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Enable Player Cull", false, "Whether to cull players");
			config_player_cull_distance = ((BaseUnityPlugin)this).Config.Bind<float>("General", "Player Cull Distance", 10000f, "Max distance at which players start culling");
			Log = ((BaseUnityPlugin)this).Logger;
			Log.LogInfo((object)("Plugin " + Name + " is loaded!"));
			_harmony.PatchAll(Assembly.GetExecutingAssembly());
		}
	}
}
namespace someoptimizations.Patches
{
	[HarmonyPatch(typeof(BananaPeel))]
	internal class BananaPeelPatch
	{
		[CompilerGenerated]
		private sealed class <SlipPatch>d__2 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public BananaPeel __instance;

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

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

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

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

			private bool MoveNext()
			{
				//IL_0031: Unknown result type (might be due to invalid IL or missing references)
				//IL_0157: Unknown result type (might be due to invalid IL or missing references)
				//IL_0161: Expected O, but got Unknown
				//IL_0132: Unknown result type (might be due to invalid IL or missing references)
				//IL_013c: Expected O, but got Unknown
				//IL_006c: 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_010d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0117: Expected O, but got Unknown
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					break;
				case 1:
					<>1__state = -1;
					break;
				case 2:
					<>1__state = -1;
					break;
				case 3:
					<>1__state = -1;
					break;
				}
				if ((int)__instance.item.itemState == 0)
				{
					BananaPeel _instance = __instance;
					_instance.counter += 1f;
					if (!(__instance.counter < 3f) && !(Vector3.Distance(Character.localCharacter.Center, ((Component)__instance).transform.position) > 1f) && Character.localCharacter.data.isGrounded && !(((Vector3)(ref Character.localCharacter.data.avarageVelocity)).magnitude < 1.5f))
					{
						__instance.counter = 0f;
						((Component)__instance).GetComponent<PhotonView>().RPC("RPCA_TriggerBanana", (RpcTarget)0, new object[1] { Character.localCharacter.refs.view.ViewID });
						<>2__current = (object)new WaitForSeconds(0.1f);
						<>1__state = 1;
						return true;
					}
					<>2__current = (object)new WaitForSeconds(0.1f);
					<>1__state = 2;
					return true;
				}
				<>2__current = (object)new WaitForSeconds(0.1f);
				<>1__state = 3;
				return true;
			}

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

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

		[HarmonyPatch("Update")]
		[HarmonyPrefix]
		private static bool VoidUpdate(BananaPeel __instance)
		{
			return false;
		}

		[HarmonyPatch("Start")]
		[HarmonyPostfix]
		private static void StartB(BananaPeel __instance)
		{
			((MonoBehaviour)__instance).StartCoroutine(SlipPatch(__instance));
		}

		[IteratorStateMachine(typeof(<SlipPatch>d__2))]
		private static IEnumerator SlipPatch(BananaPeel __instance)
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <SlipPatch>d__2(0)
			{
				__instance = __instance
			};
		}
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}