Decompiled source of NoBossNoWaitHostOnly v1.1.0

KillBossChargeTeleporter.dll

Decompiled a week 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.Logging;
using Microsoft.CodeAnalysis;
using On.RoR2;
using RoR2;
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: AssemblyCompany("KillBossChargeTeleporter")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+e5a11430e8bb097f93caf15b05e3152b24a75fb7")]
[assembly: AssemblyProduct("KillBossChargeTeleporter")]
[assembly: AssemblyTitle("KillBossChargeTeleporter")]
[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 KillBossChargeTeleporter
{
	[BepInPlugin("OakPrime.KillBossChargeTeleporter", "KillBossChargeTeleporter", "1.1.0")]
	public class KillBossChargeTeleporter : BaseUnityPlugin
	{
		[Serializable]
		[CompilerGenerated]
		private sealed class <>c
		{
			public static readonly <>c <>9 = new <>c();

			public static hook_UpdateMonstersClear <>9__4_0;

			internal void <Awake>b__4_0(orig_UpdateMonstersClear orig, TeleporterInteraction self)
			{
				//IL_0074: Unknown result type (might be due to invalid IL or missing references)
				//IL_007e: 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_002e: Invalid comparison between Unknown and I4
				orig.Invoke(self);
				if ((Object)(object)self != (Object)null && self.monstersCleared && Object.op_Implicit((Object)(object)self.holdoutZoneController) && (int)self.activationState == 2 && !((double)self.chargeFraction <= 0.0199999995529652))
				{
					int displayChargePercent = TeleporterInteraction.instance.holdoutZoneController.displayChargePercent;
					float runStopwatch = Run.instance.GetRunStopwatch();
					int num = Math.Min(Util.GetItemCountForTeam(self.holdoutZoneController.chargingTeam, Items.FocusConvergence.itemIndex, true, true), 3);
					float num2 = (float)Math.Round((100.0 - (double)displayChargePercent) / 100.0 * ((double)TeleporterInteraction.instance.holdoutZoneController.baseChargeDuration / (1.0 + 0.300000011920929 * (double)num)), 2);
					GrantWouldBeRewards(num2, self.bonusDirector, self);
					Run.instance.SetRunStopwatch(runStopwatch + (float)Math.Round(num2, 2));
					TeleporterInteraction.instance.holdoutZoneController.FullyChargeHoldoutZone();
				}
			}
		}

		public const string PluginGUID = "OakPrime.KillBossChargeTeleporter";

		public const string PluginAuthor = "OakPrime";

		public const string PluginName = "KillBossChargeTeleporter";

		public const string PluginVersion = "1.1.0";

		public void Awake()
		{
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Expected O, but got Unknown
			Log.Init(((BaseUnityPlugin)this).Logger);
			try
			{
				object obj = <>c.<>9__4_0;
				if (obj == null)
				{
					hook_UpdateMonstersClear val = delegate(orig_UpdateMonstersClear orig, TeleporterInteraction self)
					{
						//IL_0074: Unknown result type (might be due to invalid IL or missing references)
						//IL_007e: 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_002e: Invalid comparison between Unknown and I4
						orig.Invoke(self);
						if ((Object)(object)self != (Object)null && self.monstersCleared && Object.op_Implicit((Object)(object)self.holdoutZoneController) && (int)self.activationState == 2 && !((double)self.chargeFraction <= 0.0199999995529652))
						{
							int displayChargePercent = TeleporterInteraction.instance.holdoutZoneController.displayChargePercent;
							float runStopwatch = Run.instance.GetRunStopwatch();
							int num = Math.Min(Util.GetItemCountForTeam(self.holdoutZoneController.chargingTeam, Items.FocusConvergence.itemIndex, true, true), 3);
							float num2 = (float)Math.Round((100.0 - (double)displayChargePercent) / 100.0 * ((double)TeleporterInteraction.instance.holdoutZoneController.baseChargeDuration / (1.0 + 0.300000011920929 * (double)num)), 2);
							GrantWouldBeRewards(num2, self.bonusDirector, self);
							Run.instance.SetRunStopwatch(runStopwatch + (float)Math.Round(num2, 2));
							TeleporterInteraction.instance.holdoutZoneController.FullyChargeHoldoutZone();
						}
					};
					<>c.<>9__4_0 = val;
					obj = (object)val;
				}
				TeleporterInteraction.UpdateMonstersClear += (hook_UpdateMonstersClear)obj;
			}
			catch (Exception ex)
			{
				((BaseUnityPlugin)this).Logger.LogError((object)(ex.Message + " - " + ex.StackTrace));
			}
		}

		private static void GrantWouldBeRewards(float timeRemaining, CombatDirector combatDirector, TeleporterInteraction tpInteraction)
		{
			//IL_0161: Unknown result type (might be due to invalid IL or missing references)
			//IL_01aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b0: Invalid comparison between Unknown and I4
			//IL_01d7: Unknown result type (might be due to invalid IL or missing references)
			float num = combatDirector.monsterCredit;
			for (int i = 0; i < combatDirector.moneyWaves.Length; i++)
			{
				num += combatDirector.moneyWaves[i].Update(timeRemaining, Run.instance.compensatedDifficultyCoefficient);
				while (combatDirector.moneyWaves[i].timer > combatDirector.moneyWaves[i].interval)
				{
					num += combatDirector.moneyWaves[i].Update(0f, Run.instance.compensatedDifficultyCoefficient);
				}
			}
			float num2 = num * combatDirector.expRewardCoefficient;
			if (!((double)num2 > (double)Mathf.Epsilon))
			{
				return;
			}
			uint num3 = (uint)Mathf.Max(1f, num2 * Run.instance.compensatedDifficultyCoefficient);
			float num4 = (float)(1.0 + ((double)Run.instance.ambientLevel - 1.0) * 0.300000011920929);
			CharacterBody val = null;
			foreach (PlayerCharacterMasterController item in PlayerCharacterMasterController._instancesReadOnly)
			{
				if ((Object)(object)item.body != (Object)null)
				{
					val = item.body;
					break;
				}
			}
			if ((Object)(object)val == (Object)null)
			{
				Log.LogError("No player bodies found!");
				return;
			}
			ExperienceManager.instance.AwardExperience(tpInteraction.teleporterPositionIndicator.defaultPosition, val, (ulong)(uint)((double)num3 * (double)num4));
			uint num5 = (uint)Mathf.Max(1f, (float)((double)num2 * (double)combatDirector.goldRewardCoefficient * 2.0) * Run.instance.compensatedDifficultyCoefficient);
			if ((int)Run.instance.selectedDifficulty >= 8)
			{
				num5 = (uint)((double)num5 * 0.800000011920929);
			}
			TeamManager.instance.GiveTeamMoney(tpInteraction.holdoutZoneController.chargingTeam, num5);
		}
	}
	internal static class Log
	{
		internal static ManualLogSource _logSource;

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

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

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

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

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

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

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