Decompiled source of NoFallDeathInBazaar v1.0.1

NoFallDeathInBazaar.dll

Decompiled 7 hours ago
using System;
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 IL.RoR2;
using Microsoft.CodeAnalysis;
using Mono.Cecil.Cil;
using MonoMod.Cil;
using RoR2;
using RoR2BepInExPack.GameAssetPaths.Version_1_39_0;
using UnityEngine;
using UnityEngine.AddressableAssets;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("NoFallDeathInBazaar")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+c8957e4da98aac4f209e4b429b874a0b0939c4c7")]
[assembly: AssemblyProduct("NoFallDeathInBazaar")]
[assembly: AssemblyTitle("NoFallDeathInBazaar")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[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 NoFallDeathInBazaar
{
	internal static class Log
	{
		private static ManualLogSource _logSource;

		internal static void Init(ManualLogSource logSource)
		{
			_logSource = logSource;
		}

		internal static void Debug(object data)
		{
			_logSource.LogDebug(data);
		}

		internal static void Error(object data)
		{
			_logSource.LogError(data);
		}

		internal static void Fatal(object data)
		{
			_logSource.LogFatal(data);
		}

		internal static void Info(object data)
		{
			_logSource.LogInfo(data);
		}

		internal static void Message(object data)
		{
			_logSource.LogMessage(data);
		}

		internal static void Warning(object data)
		{
			_logSource.LogWarning(data);
		}
	}
	[BepInPlugin("mwmw.NoFallDeathInBazaar", "NoFallDeathInBazaar", "1.0.1")]
	public class NoFallDeathInBazaar : BaseUnityPlugin
	{
		[CompilerGenerated]
		private static class <>O
		{
			public static Manipulator <0>__CancelLethalFallIfInBazaar;
		}

		public const string PluginGUID = "mwmw.NoFallDeathInBazaar";

		public const string PluginAuthor = "mwmw";

		public const string PluginName = "NoFallDeathInBazaar";

		public const string PluginVersion = "1.0.1";

		public static ConfigFile config;

		private static SceneDef bazaarDef = Addressables.LoadAssetAsync<SceneDef>((object)RoR2_Base_bazaar.bazaar_asset).WaitForCompletion();

		public void Awake()
		{
			//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_0028: Expected O, but got Unknown
			Log.Init(((BaseUnityPlugin)this).Logger);
			object obj = <>O.<0>__CancelLethalFallIfInBazaar;
			if (obj == null)
			{
				Manipulator val = CancelLethalFallIfInBazaar;
				<>O.<0>__CancelLethalFallIfInBazaar = val;
				obj = (object)val;
			}
			GlobalEventManager.OnCharacterHitGroundServer += (Manipulator)obj;
		}

		private static void CancelLethalFallIfInBazaar(ILContext il)
		{
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Expected O, but got Unknown
			//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
			Func<bool> func = () => (Object.op_Implicit((Object)(object)Stage.instance) && (Object)(object)Stage.instance.sceneDef == (Object)(object)bazaarDef) ? true : false;
			ILCursor val = new ILCursor(il);
			ILLabel val2 = val.DefineLabel();
			ILLabel val3 = default(ILLabel);
			if (val.TryGotoNext(new Func<Instruction, bool>[1]
			{
				(Instruction x) => ILPatternMatchingExt.MatchBneUn(x, ref val3)
			}) && val.TryGotoNext(new Func<Instruction, bool>[1]
			{
				(Instruction x) => ILPatternMatchingExt.MatchLdfld<DamageInfo>(x, "damage")
			}) && val.TryGotoNext((MoveType)2, new Func<Instruction, bool>[1]
			{
				(Instruction x) => ILPatternMatchingExt.MatchStfld<DamageInfo>(x, "damage")
			}))
			{
				val.EmitDelegate<Func<bool>>(func);
				val.Emit(OpCodes.Brtrue, (object)val2);
				val.MarkLabel(val2);
				if (val.TryGotoNext(new Func<Instruction, bool>[1]
				{
					(Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt<DamageTypeCombo>(x, "op_BitwiseOr")
				}) && val.TryGotoNext((MoveType)2, new Func<Instruction, bool>[1]
				{
					(Instruction x) => ILPatternMatchingExt.MatchStfld<DamageInfo>(x, "damageType")
				}))
				{
					val.MarkLabel(val2);
				}
				else
				{
					Log.Error("Part 2 of CancelLethalFallIfInBazaar ILHook failed! Fall damage in the Bazaar is unchanged!");
				}
			}
			else
			{
				Log.Error("Part 1 of CancelLethalFallIfInBazaar ILHook failed! Fall damage in the Bazaar is unchanged!");
			}
		}
	}
}