Decompiled source of FixGenesisLoopConsoleSpam v1.0.0

FixGenesisLoopConsoleSpam.dll

Decompiled 5 months ago
using System;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using EntityStates.VagrantNovaItem;
using On.EntityStates.VagrantNovaItem;
using RiskOfOptions;
using RiskOfOptions.Options;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("FixGenesisLoopConsoleSpam")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("FixGenesisLoopConsoleSpam")]
[assembly: AssemblyCopyright("Copyright ©  2023")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("ede9dd6b-45bf-4288-b2eb-50338c6b9d6e")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace FixGenesisLoopConsoleSpam
{
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInPlugin("com.Moffein.FixGenesisLoopConsoleSpam", "FixGenesisLoopConsoleSpam", "1.0.0")]
	public class FixGenesisLoopConsoleSpam : BaseUnityPlugin
	{
		public static ConfigEntry<bool> allowUnreadable;

		private void Awake()
		{
			//IL_0011: 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_002c: Expected O, but got Unknown
			//IL_002c: Expected O, but got Unknown
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Expected O, but got Unknown
			allowUnreadable = ((BaseUnityPlugin)this).Config.Bind<bool>(new ConfigDefinition("Settings", "Allow Unreadable Meshes"), true, new ConfigDescription("Meshes with unreadable Tri-counts (usually custom skins) are allowed to keep the Genesis Loop effect. Set to false if you're still getting console spam (may cause Genesis Loop particles to get removed from valid custom skins).", (AcceptableValueBase)null, Array.Empty<object>()));
			BaseVagrantNovaItemState.OnEnter += new hook_OnEnter(BaseVagrantNovaItemState_OnEnter);
			if (Chainloader.PluginInfos.ContainsKey("com.rune580.riskofoptions"))
			{
				RiskOfOptionsCompat();
			}
		}

		[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
		private void RiskOfOptionsCompat()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Expected O, but got Unknown
			ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(allowUnreadable));
		}

		private void BaseVagrantNovaItemState_OnEnter(orig_OnEnter orig, BaseVagrantNovaItemState self)
		{
			//IL_004e: 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)
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: 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_00bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
			bool flag = false;
			try
			{
				orig.Invoke(self);
			}
			catch (NullReferenceException)
			{
				flag = true;
			}
			if (!Object.op_Implicit((Object)(object)self.chargeSparks))
			{
				return;
			}
			if (flag)
			{
				Object.Destroy((Object)(object)self.chargeSparks);
				return;
			}
			bool flag2 = true;
			ShapeModule shape = self.chargeSparks.shape;
			if (Object.op_Implicit((Object)(object)((ShapeModule)(ref shape)).skinnedMeshRenderer))
			{
				shape = self.chargeSparks.shape;
				if (Object.op_Implicit((Object)(object)((ShapeModule)(ref shape)).skinnedMeshRenderer.sharedMesh))
				{
					shape = self.chargeSparks.shape;
					if (((ShapeModule)(ref shape)).skinnedMeshRenderer.sharedMesh.isReadable)
					{
						shape = self.chargeSparks.shape;
						int num;
						if (((ShapeModule)(ref shape)).skinnedMeshRenderer.sharedMesh.triangles == null)
						{
							num = 0;
						}
						else
						{
							shape = self.chargeSparks.shape;
							num = ((ShapeModule)(ref shape)).skinnedMeshRenderer.sharedMesh.triangles.Count();
						}
						int num2 = num;
						if (num2 > 0)
						{
							Debug.Log((object)"FixGenesisLoopConsoleSpam: Valid mesh confirmed.");
							flag2 = false;
						}
						else
						{
							Debug.LogWarning((object)"FixGenesisLoopConsoleSpam: Invalid mesh with 0 tris detected.");
						}
					}
					else if (allowUnreadable.Value)
					{
						Debug.LogWarning((object)"FixGenesisLoopConsoleSpam: Could not validate mesh because isReadable is set to false. Allowing due to config settings.");
						flag2 = false;
					}
					else
					{
						Debug.LogWarning((object)"FixGenesisLoopConsoleSpam: Could not validate mesh because isReadable is set to false.");
					}
				}
			}
			if (flag2)
			{
				Debug.LogWarning((object)"FixGenesisLoopConsoleSpam: Could not confirm mesh is valid. Destroying Gensis Loop particles.");
				Object.Destroy((Object)(object)self.chargeSparks);
			}
		}
	}
}
namespace R2API.Utils
{
	[AttributeUsage(AttributeTargets.Assembly)]
	public class ManualNetworkRegistrationAttribute : Attribute
	{
	}
}