Decompiled source of Arachnophobia v1.0.0

Arachnophobia.dll

Decompiled 3 hours ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using Actors.Enemies;
using Assets.Scripts.Actors.Enemies;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Core.Logging.Interpolation;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using HarmonyLib;
using Il2CppInterop.Runtime.InteropTypes;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using Il2CppSystem.Collections.Generic;
using Microsoft.CodeAnalysis;
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("Arachnophobia")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("Arachnophobia")]
[assembly: AssemblyTitle("Arachnophobia")]
[assembly: AssemblyVersion("1.0.0.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[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 Arachnophobia
{
	[BepInPlugin("pizzaman.arachnophobia", "Arachnophobia", "1.0.0")]
	public class Plugin : BasePlugin
	{
		public const string Guid = "pizzaman.arachnophobia";

		internal static ManualLogSource Logger;

		internal static ConfigEntry<bool> Enabled;

		public override void Load()
		{
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Expected O, but got Unknown
			Logger = ((BasePlugin)this).Log;
			Enabled = ((BasePlugin)this).Config.Bind<bool>("General", "Enabled", true, "Show the desert scorpions, the scorpion miniboss and the exploding forest spiders as other creatures. Only the look changes: hitboxes, attacks and stats stay the same.");
			Enabled.SettingChanged += OnEnabledChanged;
			Harmony.CreateAndPatchAll(typeof(Patches), "pizzaman.arachnophobia");
			ManualLogSource logger = Logger;
			bool flag = default(bool);
			BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(17, 1, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Loaded (enabled=");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<bool>(Enabled.Value);
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral(")");
			}
			logger.LogInfo(val);
		}

		private static void OnEnabledChanged(object sender, EventArgs args)
		{
			Swaps.Refresh("setting changed");
		}
	}
	internal struct Shape
	{
		public Vector3 Center;

		public Vector3 Extents;

		public float Height => 2f * Extents.y;

		public float Width => 2f * Mathf.Max(Extents.x, Extents.z);

		public override string ToString()
		{
			return $"w={Width:0.###} h={Height:0.###}";
		}
	}
	internal struct Look
	{
		public Material Material;

		public AnimatedMeshScriptableObject Animation;

		public Vector3 RendererOffset;

		public Vector3 RendererRotation;

		public float RendererScale;

		public float ColliderRadius;

		public float OverrideHeight;

		public Vector3 ColliderCenter;

		public static Look Read(EnemyData d)
		{
			//IL_0025: 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_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			return new Look
			{
				Material = d.material,
				Animation = d.animation,
				RendererOffset = d.rendererOffset,
				RendererRotation = d.rendererRotationOffset,
				RendererScale = d.rendererScale,
				ColliderRadius = d.colliderRadius,
				OverrideHeight = d.overrideHeight,
				ColliderCenter = d.colliderCenter
			};
		}

		public void Write(EnemyData d)
		{
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			d.material = Material;
			d.animation = Animation;
			d.rendererOffset = RendererOffset;
			d.rendererRotationOffset = RendererRotation;
			d.rendererScale = RendererScale;
			d.colliderRadius = ColliderRadius;
			d.overrideHeight = OverrideHeight;
			d.colliderCenter = ColliderCenter;
		}
	}
	internal sealed class Swap
	{
		public readonly EEnemy Target;

		public readonly EEnemy Donor;

		public readonly bool Red;

		public EnemyData Data;

		public bool Applied;

		public Look Original;

		public Look Replaced;

		public Swap(EEnemy target, EEnemy donor, bool red = false)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			Target = target;
			Donor = donor;
			Red = red;
		}
	}
	internal static class Swaps
	{
		public static readonly Swap[] All = new Swap[4]
		{
			new Swap((EEnemy)26, (EEnemy)9),
			new Swap((EEnemy)30, (EEnemy)9, red: true),
			new Swap((EEnemy)27, (EEnemy)7),
			new Swap((EEnemy)22, (EEnemy)33)
		};

		public static bool Tried;

		private static readonly string[] TextureSlots = new string[4] { "_AlbedoMap", "_MainTex", "_EmissionMap", "_DissolveMap" };

		public static void Refresh(string why)
		{
			//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fd: Expected O, but got Unknown
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Expected O, but got Unknown
			//IL_0119: Unknown result type (might be due to invalid IL or missing references)
			//IL_015c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0162: Expected O, but got Unknown
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			Tried = true;
			DataManager instance = DataManager.Instance;
			bool flag = default(bool);
			BepInExInfoLogInterpolatedStringHandler val;
			if ((Object)(object)instance == (Object)null || instance.unsortedEnemies == null)
			{
				ManualLogSource logger = Plugin.Logger;
				val = new BepInExInfoLogInterpolatedStringHandler(27, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(why);
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral(": enemy data not loaded yet");
				}
				logger.LogInfo(val);
				Tried = false;
				return;
			}
			Dictionary<EEnemy, EnemyData> dictionary = new Dictionary<EEnemy, EnemyData>();
			for (int i = 0; i < instance.unsortedEnemies.Count; i++)
			{
				EnemyData val2 = instance.unsortedEnemies[i];
				if ((Object)(object)val2 != (Object)null && !dictionary.ContainsKey(val2.enemyName))
				{
					dictionary[val2.enemyName] = val2;
				}
			}
			int num = 0;
			Swap[] all = All;
			foreach (Swap swap in all)
			{
				try
				{
					num = ((!Plugin.Enabled.Value) ? (num + (Revert(swap) ? 1 : 0)) : (num + (Apply(swap, dictionary, why) ? 1 : 0)));
				}
				catch (Exception ex)
				{
					ManualLogSource logger2 = Plugin.Logger;
					BepInExErrorLogInterpolatedStringHandler val3 = new BepInExErrorLogInterpolatedStringHandler(4, 3, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<string>(why);
						((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(": ");
						((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<EEnemy>(swap.Target);
						((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(": ");
						((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<Exception>(ex);
					}
					logger2.LogError(val3);
				}
			}
			ManualLogSource logger3 = Plugin.Logger;
			val = new BepInExInfoLogInterpolatedStringHandler(19, 4, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(why);
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral(": ");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(Plugin.Enabled.Value ? "replaced" : "restored");
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" ");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(num);
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" of ");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(All.Length);
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" enemy looks");
			}
			logger3.LogInfo(val);
		}

		private static bool Apply(Swap s, Dictionary<EEnemy, EnemyData> byType, string why)
		{
			//IL_0002: 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: Expected O, but got Unknown
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: 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)
			if (!byType.TryGetValue(s.Target, out var value) || !byType.TryGetValue(s.Donor, out var value2))
			{
				ManualLogSource logger = Plugin.Logger;
				bool flag = default(bool);
				BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(46, 3, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(why);
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral(": ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<EEnemy>(s.Target);
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" or ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<EEnemy>(s.Donor);
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" is not in the game any more, left as is");
				}
				logger.LogWarning(val);
				return false;
			}
			if ((Object)(object)s.Data == (Object)null || ((Il2CppObjectBase)s.Data).Pointer != ((Il2CppObjectBase)value).Pointer)
			{
				s.Data = value;
				s.Original = Look.Read(value);
				Keep(s.Original.Material, s.Original.Animation);
				s.Replaced = Fit(s, value2);
			}
			s.Replaced.Write(value);
			s.Applied = true;
			return true;
		}

		private static bool Revert(Swap s)
		{
			if ((Object)(object)s.Data == (Object)null || !s.Applied)
			{
				return false;
			}
			s.Original.Write(s.Data);
			s.Applied = false;
			return true;
		}

		private static Look Fit(Swap s, EnemyData donor)
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: 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_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: 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_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_0117: Unknown result type (might be due to invalid IL or missing references)
			//IL_011c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0129: Unknown result type (might be due to invalid IL or missing references)
			//IL_0136: Unknown result type (might be due to invalid IL or missing references)
			//IL_013b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0161: Unknown result type (might be due to invalid IL or missing references)
			//IL_0167: Unknown result type (might be due to invalid IL or missing references)
			//IL_016c: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a9: Expected O, but got Unknown
			//IL_01b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e0: Unknown result type (might be due to invalid IL or missing references)
			Look original = s.Original;
			Shape shape = Measure(original.Animation, original.RendererRotation);
			Shape shape2 = Measure(donor.animation, donor.rendererRotationOffset);
			float num = shape.Width / shape2.Width;
			float num2 = original.RendererOffset.x + shape.Center.x;
			float num3 = original.RendererOffset.z + shape.Center.z;
			float num4 = 0f - (original.RendererOffset.y + shape.Extents.y) + (shape.Center.y - shape.Extents.y);
			float num5 = num2 / num - shape2.Center.x;
			float num6 = num3 / num - shape2.Center.z;
			float num7 = num4 / num - (shape2.Center.y - shape2.Extents.y);
			Look result = new Look
			{
				Material = (s.Red ? RedCopy(donor.material) : donor.material),
				Animation = donor.animation,
				RendererRotation = donor.rendererRotationOffset,
				RendererOffset = new Vector3(num5, 0f - num7 - shape2.Extents.y, num6),
				RendererScale = original.RendererScale * num,
				ColliderRadius = original.ColliderRadius / num,
				ColliderCenter = original.ColliderCenter / num,
				OverrideHeight = ((original.OverrideHeight > 0f) ? original.OverrideHeight : shape.Height) / num
			};
			ManualLogSource logger = Plugin.Logger;
			bool flag = default(bool);
			BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(23, 6, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<EEnemy>(s.Target);
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral(": ");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<Shape>(shape);
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" -> ");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<EEnemy>(s.Donor);
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(s.Red ? " (red)" : "");
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" ");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<Shape>(shape2);
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral(", drawn ");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<float>(num, "0.###");
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("x larger");
			}
			logger.LogInfo(val);
			return result;
		}

		private static void Keep(Material mat, AnimatedMeshScriptableObject anim)
		{
			Keep((Object)(object)mat);
			string[] textureSlots = TextureSlots;
			foreach (string text in textureSlots)
			{
				if ((Object)(object)mat != (Object)null && mat.HasProperty(text))
				{
					Keep((Object)(object)mat.GetTexture(text));
				}
			}
			Keep((Object)(object)anim);
			int num = 0;
			while ((Object)(object)anim != (Object)null && num < anim.Animations.Count)
			{
				List<Mesh> meshes = anim.Animations[num].Meshes;
				for (int j = 0; j < meshes.Count; j++)
				{
					Keep((Object)(object)meshes[j]);
				}
				num++;
			}
		}

		private static void Keep(Object o)
		{
			//IL_000b: 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)
			if (o != (Object)null)
			{
				o.hideFlags = (HideFlags)(o.hideFlags | 0x20);
			}
		}

		public static Shape Measure(AnimatedMeshScriptableObject anim, Vector3 euler)
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: 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_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: 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_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_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: 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_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: 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_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dd: 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)
			//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
			Bounds bounds = anim.Animations[0].Meshes[0].bounds;
			Matrix4x4 val = Matrix4x4.Rotate(Quaternion.Euler(euler));
			Vector3 extents = ((Bounds)(ref bounds)).extents;
			return new Shape
			{
				Center = ((Matrix4x4)(ref val)).MultiplyVector(((Bounds)(ref bounds)).center),
				Extents = new Vector3(Mathf.Abs(val.m00) * extents.x + Mathf.Abs(val.m01) * extents.y + Mathf.Abs(val.m02) * extents.z, Mathf.Abs(val.m10) * extents.x + Mathf.Abs(val.m11) * extents.y + Mathf.Abs(val.m12) * extents.z, Mathf.Abs(val.m20) * extents.x + Mathf.Abs(val.m21) * extents.y + Mathf.Abs(val.m22) * extents.z)
			};
		}

		private static Material RedCopy(Material src)
		{
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Expected O, but got Unknown
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: 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_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_011e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0123: Unknown result type (might be due to invalid IL or missing references)
			//IL_0139: Unknown result type (might be due to invalid IL or missing references)
			//IL_0145: Unknown result type (might be due to invalid IL or missing references)
			//IL_0151: Unknown result type (might be due to invalid IL or missing references)
			//IL_015a: Expected O, but got Unknown
			Texture val = src.GetTexture("_AlbedoMap") ?? src.mainTexture;
			RenderTexture temporary = RenderTexture.GetTemporary(val.width, val.height, 0, (RenderTextureFormat)0);
			Graphics.Blit(val, temporary);
			RenderTexture active = RenderTexture.active;
			RenderTexture.active = temporary;
			Texture2D val2 = new Texture2D(val.width, val.height, (TextureFormat)4, false);
			val2.ReadPixels(new Rect(0f, 0f, (float)val.width, (float)val.height), 0, 0);
			RenderTexture.active = active;
			RenderTexture.ReleaseTemporary(temporary);
			Il2CppStructArray<Color32> pixels = val2.GetPixels32();
			for (int i = 0; i < ((Il2CppArrayBase<Color32>)(object)pixels).Length; i++)
			{
				Color32 val3 = ((Il2CppArrayBase<Color32>)(object)pixels)[i];
				ref byte r = ref val3.r;
				ref byte g = ref val3.g;
				byte g2 = val3.g;
				byte r2 = val3.r;
				r = g2;
				g = r2;
				((Il2CppArrayBase<Color32>)(object)pixels)[i] = val3;
			}
			val2.SetPixels32(pixels);
			((Texture)val2).filterMode = val.filterMode;
			((Texture)val2).wrapMode = val.wrapMode;
			val2.Apply();
			((Object)val2).name = ((Object)val).name + " (red)";
			((Object)val2).hideFlags = (HideFlags)32;
			Material val4 = new Material(src)
			{
				name = ((Object)src).name + " (red)"
			};
			val4.SetTexture("_AlbedoMap", (Texture)(object)val2);
			val4.SetTexture("_MainTex", (Texture)(object)val2);
			((Object)val4).hideFlags = (HideFlags)32;
			return val4;
		}
	}
	internal static class Patches
	{
		[HarmonyPostfix]
		[HarmonyPatch(typeof(DataManager), "Load")]
		private static void AfterDataLoad()
		{
			Run("enemy data loaded");
		}

		[HarmonyPrefix]
		[HarmonyPatch(typeof(Enemy), "InitEnemy")]
		private static void BeforeInitEnemy()
		{
			if (!Swaps.Tried)
			{
				Run("first enemy");
			}
		}

		private static void Run(string why)
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Expected O, but got Unknown
			try
			{
				Swaps.Refresh(why);
			}
			catch (Exception ex)
			{
				ManualLogSource logger = Plugin.Logger;
				bool flag = default(bool);
				BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(2, 2, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(why);
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral(": ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<Exception>(ex);
				}
				logger.LogError(val);
			}
		}
	}
}