Decompiled source of GlueFix v0.0.8

GlueFix.dll

Decompiled a month ago
using System;
using System.CodeDom.Compiler;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using AIGraph;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Core.Logging.Interpolation;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using BepInEx.Unity.IL2CPP.Utils.Collections;
using HarmonyLib;
using Il2CppSystem;
using LevelGeneration;
using Microsoft.CodeAnalysis;
using Player;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("GlueFix")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("GlueFix")]
[assembly: AssemblyTitle("GlueFix")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
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 GlueFix
{
	[BepInPlugin("GlueFix", "GlueFix", "0.0.8")]
	public class Plugin : BasePlugin
	{
		public class GlueFix : MonoBehaviour
		{
			[CompilerGenerated]
			private sealed class <GlueFixer>d__3 : IEnumerator<object>, IDisposable, IEnumerator
			{
				private int <>1__state;

				private object <>2__current;

				public GlueGunProjectile blob;

				private float <alku>5__2;

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

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

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

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

				private bool MoveNext()
				{
					//IL_0033: Unknown result type (might be due to invalid IL or missing references)
					//IL_003d: Expected O, but got Unknown
					//IL_0081: Unknown result type (might be due to invalid IL or missing references)
					//IL_0087: Invalid comparison between Unknown and I4
					//IL_010b: Unknown result type (might be due to invalid IL or missing references)
					//IL_0111: Invalid comparison between Unknown and I4
					//IL_030d: Unknown result type (might be due to invalid IL or missing references)
					//IL_0317: Expected O, but got Unknown
					//IL_0291: Unknown result type (might be due to invalid IL or missing references)
					//IL_0297: Invalid comparison between Unknown and I4
					//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
					//IL_00b3: Expected O, but got Unknown
					//IL_0144: Unknown result type (might be due to invalid IL or missing references)
					//IL_014a: Expected O, but got Unknown
					//IL_02af: Unknown result type (might be due to invalid IL or missing references)
					//IL_02b5: Expected O, but got Unknown
					//IL_020d: Unknown result type (might be due to invalid IL or missing references)
					//IL_0214: Invalid comparison between Unknown and I4
					//IL_0259: Unknown result type (might be due to invalid IL or missing references)
					//IL_025f: Expected O, but got Unknown
					float num;
					bool flag = default(bool);
					switch (<>1__state)
					{
					default:
						return false;
					case 0:
						<>1__state = -1;
						<alku>5__2 = Clock.Time;
						<>2__current = (object)new WaitForSeconds(6f);
						<>1__state = 1;
						return true;
					case 1:
						<>1__state = -1;
						_ = blob.SyncID;
						if (!((Object)(object)blob != (Object)null))
						{
							break;
						}
						goto IL_0327;
					case 2:
						{
							<>1__state = -1;
							goto IL_0327;
						}
						IL_0327:
						if (!((Object)(object)blob != (Object)null))
						{
							break;
						}
						num = Clock.Time - <alku>5__2;
						if ((int)blob.m_collisionLandingType == 5 && !((StickingProjectileBase)blob).CollisionCheck(false))
						{
							if (_verboseLogging.Value)
							{
								ManualLogSource l = L;
								BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(22, 1, ref flag);
								if (flag)
								{
									((BepInExLogInterpolatedStringHandler)val).AppendLiteral("destroy hovering blob ");
									((BepInExLogInterpolatedStringHandler)val).AppendFormatted<uint>(blob.SyncID);
								}
								l.LogInfo(val);
							}
							if (blob.m_sound != null)
							{
								blob.m_sound.Recycle();
							}
							ProjectileManager.WantToDestroyGlue(blob.SyncID);
						}
						if ((int)blob.m_collisionLandingType == 4)
						{
							if ((Object)(object)((Component)((StickingProjectileBase)blob).m_projLastRayHitCollider).gameObject == (Object)null)
							{
								if (_verboseLogging.Value)
								{
									ManualLogSource l2 = L;
									BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(35, 1, ref flag);
									if (flag)
									{
										((BepInExLogInterpolatedStringHandler)val).AppendLiteral("a true orphan is found and removed ");
										((BepInExLogInterpolatedStringHandler)val).AppendFormatted<uint>(blob.SyncID);
									}
									l2.LogInfo(val);
								}
								if (blob.m_sound != null)
								{
									blob.m_sound.Recycle();
								}
								ProjectileManager.WantToDestroyGlue(blob.SyncID);
							}
							if ((Object)(object)((Component)((StickingProjectileBase)blob).m_projLastRayHitCollider).gameObject != (Object)null)
							{
								LG_WeakDoor componentInParent = ((Component)((StickingProjectileBase)blob).m_projLastRayHitCollider).gameObject.GetComponentInParent<LG_WeakDoor>();
								if ((Object)(object)componentInParent == (Object)null)
								{
									if (blob.m_sound != null)
									{
										blob.m_sound.Recycle();
									}
									ProjectileManager.WantToDestroyGlue(blob.SyncID);
								}
								if ((Object)(object)componentInParent != (Object)null && (int)componentInParent.LastStatus == 11)
								{
									if (blob.m_sound != null)
									{
										blob.m_sound.Recycle();
									}
									ProjectileManager.WantToDestroyGlue(blob.SyncID);
									if (_verboseLogging.Value)
									{
										ManualLogSource l3 = L;
										BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(31, 1, ref flag);
										if (flag)
										{
											((BepInExLogInterpolatedStringHandler)val).AppendLiteral("destroy blob of destroyed door ");
											((BepInExLogInterpolatedStringHandler)val).AppendFormatted<uint>(blob.SyncID);
										}
										l3.LogInfo(val);
									}
								}
							}
						}
						if (num > 257f && (int)blob.m_collisionLandingType != 4)
						{
							if (_verboseLogging.Value)
							{
								ManualLogSource l4 = L;
								BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(19, 1, ref flag);
								if (flag)
								{
									((BepInExLogInterpolatedStringHandler)val).AppendLiteral("destroy ghost blob ");
									((BepInExLogInterpolatedStringHandler)val).AppendFormatted<uint>(blob.SyncID);
								}
								l4.LogInfo(val);
							}
							if (blob.m_sound != null)
							{
								blob.m_sound.Recycle();
							}
							ProjectileManager.WantToDestroyGlue(blob.SyncID);
						}
						<>2__current = (object)new WaitForSeconds(1f);
						<>1__state = 2;
						return true;
					}
					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();
				}
			}

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

				private object <>2__current;

				public InfectionSpitter spit;

				private AIG_CourseNode <node>5__2;

				private int <id>5__3;

				private PlayerAgent <plr>5__4;

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

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

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

				[DebuggerHidden]
				void IDisposable.Dispose()
				{
					<node>5__2 = null;
					<plr>5__4 = null;
					<>1__state = -2;
				}

				private bool MoveNext()
				{
					//IL_0122: Unknown result type (might be due to invalid IL or missing references)
					//IL_012c: Expected O, but got Unknown
					//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
					//IL_00b0: Expected O, but got Unknown
					int num = <>1__state;
					if (num != 0)
					{
						if (num != 1)
						{
							return false;
						}
						<>1__state = -1;
					}
					else
					{
						<>1__state = -1;
						<node>5__2 = spit.m_courseNode;
						<id>5__3 = ((Object)spit).GetInstanceID();
						<plr>5__4 = PlayerManager.GetLocalPlayerAgent();
					}
					if (<plr>5__4.m_courseNode != <node>5__2 && spit.m_sound != null && spit.m_purrLoopPlaying)
					{
						spit.m_purrLoopPlaying = false;
						spit.CleanupSound();
						if (_verboseLogging.Value)
						{
							ManualLogSource l = L;
							bool flag = default(bool);
							BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(42, 3, ref flag);
							if (flag)
							{
								((BepInExLogInterpolatedStringHandler)val).AppendLiteral("removed audio from spitter ");
								((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(<id>5__3);
								((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" in zone ");
								((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(spit.m_courseNode.m_zone.ID);
								((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" area ");
								((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(spit.m_courseNode.m_area.UID);
							}
							l.LogInfo(val);
						}
					}
					<>2__current = (object)new WaitForSeconds(1f);
					<>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();
				}
			}

			public static void Initialize()
			{
				//IL_009b: Unknown result type (might be due to invalid IL or missing references)
				//IL_00a2: Expected O, but got Unknown
				foreach (InfectionSpitter item in Object.FindObjectsOfType<InfectionSpitter>())
				{
					CoroutineManager.StartCoroutine(CollectionExtensions.WrapToIl2Cpp(SpitterKiller(item)), (Action)null);
				}
				bool flag = default(bool);
				foreach (CellSoundEmitter item2 in Object.FindObjectsOfType<CellSoundEmitter>())
				{
					Behaviour component = ((Component)item2).GetComponent<Behaviour>();
					if ((Object)(object)component != (Object)null)
					{
						component.enabled = false;
					}
					((MonoBehaviour)item2).StopAllCoroutines();
					item2.StopSound();
					if (item2.m_sound != null)
					{
						item2.m_sound.Recycle();
					}
					if (_verboseLogging.Value)
					{
						ManualLogSource l = L;
						BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(19, 1, ref flag);
						if (flag)
						{
							((BepInExLogInterpolatedStringHandler)val).AppendLiteral("removed sound from ");
							((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(((Object)((Component)((Component)item2).transform.parent).gameObject).name);
						}
						l.LogInfo(val);
					}
				}
			}

			public static void GlueKiller(GlueGunProjectile blob)
			{
				CoroutineManager.StartCoroutine(CollectionExtensions.WrapToIl2Cpp(GlueFixer(blob)), (Action)null);
			}

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

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

		[HarmonyPatch(typeof(GlueGunProjectile), "Awake")]
		private class CfoamDebugPatches
		{
			[HarmonyPostfix]
			private static void Postfix(GlueGunProjectile __instance)
			{
				GlueFix.GlueKiller(__instance);
			}

			[HarmonyPatch(typeof(GlueGunProjectile), "SyncDestroy")]
			[HarmonyPrefix]
			private static bool Prefix(GlueGunProjectile __instance)
			{
				if (__instance.m_sound != null)
				{
					if (_verboseLogging.Value)
					{
						L.LogInfo((object)"blob destroyed, m_sound recycled");
					}
					__instance.m_sound.Recycle();
				}
				return true;
			}

			[HarmonyPatch(typeof(Item), "OnDespawn")]
			[HarmonyPrefix]
			private static void KillSound(Item __instance)
			{
				//IL_0026: Unknown result type (might be due to invalid IL or missing references)
				//IL_002c: Expected O, but got Unknown
				CellSoundPlayer component = ((Component)__instance).GetComponent<CellSoundPlayer>();
				if (component == null)
				{
					return;
				}
				component.Recycle();
				if (_verboseLogging.Value)
				{
					ManualLogSource l = L;
					bool flag = default(bool);
					BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(37, 1, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral("CellSoundPlayer of item ");
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(((Object)((Component)__instance).gameObject).name);
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" was recycled");
					}
					l.LogInfo(val);
				}
			}

			[HarmonyPatch(typeof(GlueGunProjectile), "OnProjectileLanded_OnStaticSplat")]
			[HarmonyPrefix]
			private static bool SplitUpwards(GlueGunProjectile __instance, Vector3 rayHitPoint, Vector3 rayHitNormal)
			{
				//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_001d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0022: Unknown result type (might be due to invalid IL or missing references)
				//IL_002d: Unknown result type (might be due to invalid IL or missing references)
				//IL_003f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0044: 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)
				//IL_005e: Unknown result type (might be due to invalid IL or missing references)
				//IL_006a: Unknown result type (might be due to invalid IL or missing references)
				//IL_006f: 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_0077: Unknown result type (might be due to invalid IL or missing references)
				//IL_007d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0082: Unknown result type (might be due to invalid IL or missing references)
				//IL_008c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0091: Unknown result type (might be due to invalid IL or missing references)
				//IL_0092: Unknown result type (might be due to invalid IL or missing references)
				//IL_0093: Unknown result type (might be due to invalid IL or missing references)
				//IL_0099: Unknown result type (might be due to invalid IL or missing references)
				//IL_009e: Unknown result type (might be due to invalid IL or missing references)
				//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
				//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
				//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
				ProjectileManager.WantToSpawnStaticGlue(__instance.SyncID, ((Component)__instance).transform.position, __instance.m_volumeDesc);
				Vector3 projVelocity = ((StickingProjectileBase)__instance).m_projVelocity;
				_ = ((Vector3)(ref projVelocity)).magnitude;
				float num = __instance.m_volumeDesc.expandVolume * 0.3f;
				GlueVolumeDesc volumeDesc = __instance.m_volumeDesc;
				volumeDesc.expandVolume = __instance.m_volumeDesc.expandVolume - 0.3f;
				__instance.m_volumeDesc = volumeDesc;
				Vector3 val = (2f * Vector3.Dot(((StickingProjectileBase)__instance).m_projVelocity, rayHitNormal) * rayHitNormal - ((StickingProjectileBase)__instance).m_projVelocity) * -0.15f;
				Vector3 val2 = rayHitPoint + rayHitNormal * 0.03f;
				ProjectileManager.WantToFireGlue(__instance.m_owner, val2, val, num, true);
				if (_verboseLogging.Value)
				{
					L.LogInfo((object)"blob split, handled.");
				}
				return false;
			}
		}

		internal static ManualLogSource L;

		public static ConfigEntry<bool> _verboseLogging;

		public override void Load()
		{
			//IL_001b: 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_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Expected O, but got Unknown
			//IL_0045: Expected O, but got Unknown
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			L = ((BasePlugin)this).Log;
			_verboseLogging = new ConfigFile(Path.Combine(Paths.ConfigPath, "GlueFix.cfg"), true).Bind<bool>(new ConfigDefinition("General", "Verbose_Logging"), false, new ConfigDescription("Verbose logging enable?", (AcceptableValueBase)null, Array.Empty<object>()));
			new Harmony("GlueFix").PatchAll();
			((BasePlugin)this).AddComponent<GlueFix>();
			LG_Factory.OnFactoryBuildDone += Action.op_Implicit((Action)GlueFix.Initialize);
			L.LogInfo((object)"initialized and ready. No additional logging provided without config-file Verbose_Logging set to true");
		}
	}
	[GeneratedCode("VersionInfoGenerator", "2.0.0+git50a4b1a-master")]
	[CompilerGenerated]
	internal static class VersionInfo
	{
		public const string RootNamespace = "GlueFix";

		public const string Version = "1.0.0";

		public const string VersionPrerelease = null;

		public const string VersionMetadata = null;

		public const string SemVer = "1.0.0";

		public const string GitRevShort = null;

		public const string GitRevLong = null;

		public const string GitBranch = null;

		public const string GitTag = null;

		public const bool GitIsDirty = false;
	}
}