Decompiled source of RoR2 Style Item Stealing v1.0.1

RoR2StyleItemStealing.dll

Decompiled 5 days ago
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using AddWatermark;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Logging;
using HarmonyLib;
using LBoL.Base.Extensions;
using LBoL.Core;
using LBoL.Core.StatusEffects;
using LBoL.EntityLib.StatusEffects.Enemy.SeijaItems;
using LBoL.Presentation;
using UnityEngine;

[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: IgnoresAccessChecksTo("LBoL.Base")]
[assembly: IgnoresAccessChecksTo("LBoL.ConfigData")]
[assembly: IgnoresAccessChecksTo("LBoL.Core")]
[assembly: IgnoresAccessChecksTo("LBoL.EntityLib")]
[assembly: IgnoresAccessChecksTo("LBoL.Presentation")]
[assembly: IgnoresAccessChecksTo("Untitled.ConfigDataBuilder.Base")]
[assembly: AssemblyCompany("RoR2StyleItemStealing")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("RoR2StyleItemStealing")]
[assembly: AssemblyTitle("RoR2StyleItemStealing")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace RoR2StyleItemStealing
{
	[BepInPlugin("intoxicatedkid.ror2styleitemstealing", "RoR2 Style Item Stealing", "1.0.1")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInProcess("LBoL.exe")]
	public class BepinexPlugin : BaseUnityPlugin
	{
		[HarmonyPatch(typeof(HolyGrailSe), "OnOwnerTurnStarted")]
		private class HolyGrailSe_OnOwnerTurnStarted_Patch
		{
			private static bool trigger;

			private static void Prefix(HolyGrailSe __instance)
			{
				if (!__instance._happened)
				{
					exhibits = ((GameEntity)__instance).GameRun.Player.Exhibits.Where((Exhibit e) => (int)e.LosableType == 0).ToArray();
					if (exhibits != null)
					{
						trigger = true;
					}
				}
			}

			private static void Postfix(HolyGrailSe __instance)
			{
				if (trigger)
				{
					trigger = false;
					val1 = ((StatusEffect)__instance).Owner.Hp;
					val2 = val1 / exhibits.Length;
				}
			}
		}

		[HarmonyPatch(typeof(LimitedDamage), "OnDamageReceived")]
		private class LimitedDamage_OnDamageReceived_Patch
		{
			private static void Postfix(LimitedDamage __instance)
			{
				while (((StatusEffect)__instance).Owner.Hp <= val1)
				{
					val1 -= val2;
					if (exhibits.Length != 0)
					{
						Exhibit exhibit = CollectionsExtensions.SampleOrDefault<Exhibit>((IEnumerable<Exhibit>)exhibits, ((GameEntity)__instance).GameRun.EnemyBattleRng);
						((MonoBehaviour)Singleton<GameMaster>.Instance).StartCoroutine(Singleton<GameMaster>.Instance.CurrentGameRun.GainExhibitRunner(exhibit, false, (VisualSourceData)null));
						Singleton<GameMaster>.Instance.CurrentGameRun.ExhibitRecord.Remove(((GameEntity)exhibit).Id);
						exhibits = exhibits.Where((Exhibit e) => e != exhibit).ToArray();
					}
				}
			}
		}

		private static readonly Harmony harmony = PInfo.harmony;

		internal static ManualLogSource log;

		private static int val1 = 0;

		private static int val2 = 0;

		private static Exhibit[] exhibits { get; set; }

		private void Awake()
		{
			log = ((BaseUnityPlugin)this).Logger;
			Object.DontDestroyOnLoad((Object)(object)((Component)this).gameObject);
			((Object)((Component)this).gameObject).hideFlags = (HideFlags)61;
			harmony.PatchAll();
			if (Chainloader.PluginInfos.ContainsKey("neo.lbol.tools.watermark"))
			{
				WatermarkWrapper.ActivateWatermark();
			}
		}

		private void OnDestroy()
		{
			if (harmony != null)
			{
				harmony.UnpatchSelf();
			}
		}
	}
	public static class PInfo
	{
		public const string GUID = "intoxicatedkid.ror2styleitemstealing";

		public const string Name = "RoR2 Style Item Stealing";

		public const string version = "1.0.1";

		public static readonly Harmony harmony = new Harmony("intoxicatedkid.ror2styleitemstealing");
	}
	internal class WatermarkWrapper
	{
		[MethodImpl(MethodImplOptions.NoInlining)]
		internal static void ActivateWatermark()
		{
			API.ActivateWatermark();
		}
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		internal IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}