Decompiled source of EclipseAugments v1.1.4

EclipseAugments.dll

Decompiled 7 months 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 IL.RoR2;
using Microsoft.CodeAnalysis;
using Mono.Cecil.Cil;
using MonoMod.Cil;
using On.RoR2;
using R2API;
using RoR2;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.0", FrameworkDisplayName = ".NET Standard 2.0")]
[assembly: AssemblyCompany("EclipseAugments")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("EclipseAugments")]
[assembly: AssemblyTitle("EclipseAugments")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.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 EclipseAugments
{
	[BepInPlugin("com.Nuxlar.EclipseAugments", "EclipseAugments", "1.1.4")]
	public class EclipseAugments : BaseUnityPlugin
	{
		public void Awake()
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Expected O, but got Unknown
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Expected O, but got Unknown
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Expected O, but got Unknown
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Expected O, but got Unknown
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Expected O, but got Unknown
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Expected O, but got Unknown
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Expected O, but got Unknown
			IncreaseScaling();
			ChangeDescriptions();
			CharacterMaster.OnBodyStart += new Manipulator(RemoveE1Modifier);
			HoldoutZoneController.FixedUpdate += new Manipulator(RemoveE2Modifier);
			DeathRewards.OnKilledServer += new Manipulator(RemoveE6Modifier);
			HealthComponent.TakeDamage += new Manipulator(ReduceAdaptiveArmor);
			CharacterMaster.OnBodyStart += new hook_OnBodyStart(CharacterMaster_OnBodyStart);
			CombatDirector.OnEnable += new hook_OnEnable(CombatDirector_OnEnable);
			GlobalEventManager.OnCharacterHitGroundServer += new hook_OnCharacterHitGroundServer(GlobalEventManager_OnCharacterHitGroundServer);
		}

		private void IncreaseScaling()
		{
			DifficultyDef difficultyDef = DifficultyCatalog.GetDifficultyDef((DifficultyIndex)3);
			difficultyDef.scalingValue *= 1.25f;
			DifficultyDef difficultyDef2 = DifficultyCatalog.GetDifficultyDef((DifficultyIndex)4);
			difficultyDef2.scalingValue *= 1.25f;
			DifficultyDef difficultyDef3 = DifficultyCatalog.GetDifficultyDef((DifficultyIndex)5);
			difficultyDef3.scalingValue *= 1.25f;
			DifficultyDef difficultyDef4 = DifficultyCatalog.GetDifficultyDef((DifficultyIndex)6);
			difficultyDef4.scalingValue *= 1.25f;
			DifficultyDef difficultyDef5 = DifficultyCatalog.GetDifficultyDef((DifficultyIndex)7);
			difficultyDef5.scalingValue *= 1.25f;
			DifficultyDef difficultyDef6 = DifficultyCatalog.GetDifficultyDef((DifficultyIndex)8);
			difficultyDef6.scalingValue *= 1.25f;
			DifficultyDef difficultyDef7 = DifficultyCatalog.GetDifficultyDef((DifficultyIndex)9);
			difficultyDef7.scalingValue *= 1.25f;
			DifficultyDef difficultyDef8 = DifficultyCatalog.GetDifficultyDef((DifficultyIndex)10);
			difficultyDef8.scalingValue *= 1.25f;
		}

		private void ChangeDescriptions()
		{
			string text = "Starts at baseline Monsoon difficulty.\n";
			string text2 = "\n<mspace=0.5em>(1)</mspace> Difficulty Scaling: <style=cIsHealth>+25%</style></style>";
			string text3 = "\n<mspace=0.5em>(2)</mspace> Director Credits: <style=cIsHealth>+15%</style></style>";
			string text4 = "\n<mspace=0.5em>(3)</mspace> Ally Fall Damage: <style=cIsHealth>+100%</style></style>";
			string text5 = "\n<mspace=0.5em>(4)</mspace> Enemies: <style=cIsHealth>+40% Faster</style></style>";
			string text6 = "\n<mspace=0.5em>(5)</mspace> Ally Healing: <style=cIsHealth>-50%</style></style>";
			string text7 = "\n<mspace=0.5em>(6)</mspace> Boss Armor: <style=cIsHealth>Adaptive</style></style>";
			string text8 = "\n<mspace=0.5em>(7)</mspace> Enemy Cooldowns: <style=cIsHealth>-50%</style></style>";
			string text9 = "\n<mspace=0.5em>(8)</mspace> Allies recieve <style=cIsHealth>permanent damage</style></style>";
			string text10 = "\"You only celebrate in the light... because I allow it.\" \n\n";
			LanguageAPI.Add("ECLIPSE_1_DESCRIPTION", text + text2);
			LanguageAPI.Add("ECLIPSE_2_DESCRIPTION", text + text2 + text3);
			LanguageAPI.Add("ECLIPSE_3_DESCRIPTION", text + text2 + text3 + text4);
			LanguageAPI.Add("ECLIPSE_4_DESCRIPTION", text + text2 + text3 + text4 + text5);
			LanguageAPI.Add("ECLIPSE_5_DESCRIPTION", text + text2 + text3 + text4 + text5 + text6);
			LanguageAPI.Add("ECLIPSE_6_DESCRIPTION", text + text2 + text3 + text4 + text5 + text6 + text7);
			LanguageAPI.Add("ECLIPSE_7_DESCRIPTION", text + text2 + text3 + text4 + text5 + text6 + text7 + text8);
			LanguageAPI.Add("ECLIPSE_8_DESCRIPTION", text10 + text + text2 + text3 + text4 + text5 + text6 + text7 + text8 + text9);
		}

		private void RemoveE1Modifier(ILContext il)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Expected O, but got Unknown
			ILCursor val = new ILCursor(il);
			if (val.TryGotoNext((MoveType)0, new Func<Instruction, bool>[1]
			{
				(Instruction x) => ILPatternMatchingExt.MatchLdcR4(x, 0.5f)
			}))
			{
				val.Next.Operand = 1f;
			}
			else
			{
				Debug.LogError((object)"EclipseAugments: RemoveE1Modifier IL Hook failed");
			}
		}

		private void RemoveE2Modifier(ILContext il)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Expected O, but got Unknown
			ILCursor val = new ILCursor(il);
			if (val.TryGotoNext((MoveType)0, new Func<Instruction, bool>[1]
			{
				(Instruction x) => ILPatternMatchingExt.MatchLdcR4(x, 0.5f)
			}))
			{
				val.Next.Operand = 1f;
			}
			else
			{
				Debug.LogError((object)"EclipseAugments: RemoveE2Modifier IL Hook failed");
			}
		}

		private void RemoveE6Modifier(ILContext il)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Expected O, but got Unknown
			ILCursor val = new ILCursor(il);
			if (val.TryGotoNext((MoveType)0, new Func<Instruction, bool>[1]
			{
				(Instruction x) => ILPatternMatchingExt.MatchLdcR4(x, 0.8f)
			}))
			{
				val.Next.Operand = 1f;
			}
			else
			{
				Debug.LogError((object)"EclipseAugments: RemoveE6Modifier IL Hook failed");
			}
		}

		private void ReduceAdaptiveArmor(ILContext il)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Expected O, but got Unknown
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			ILCursor val = new ILCursor(il);
			if (val.TryGotoNext((MoveType)2, new Func<Instruction, bool>[1]
			{
				(Instruction x) => ILPatternMatchingExt.MatchLdcR4(x, 400f)
			}))
			{
				val.Emit(OpCodes.Ldarg_0);
				val.EmitDelegate<Func<float, HealthComponent, float>>((Func<float, HealthComponent, float>)((float armorCap, HealthComponent self) => (((Object)self.body).name.Contains("Brother") || ((Object)self.body).name.Contains("VoidRaid")) ? armorCap : 125f));
			}
			else
			{
				((BaseUnityPlugin)this).Logger.LogError((object)"EclipseAugments: ReduceAdaptiveArmor IL Hook failed");
			}
		}

		private void CharacterMaster_OnBodyStart(orig_OnBodyStart orig, CharacterMaster self, CharacterBody body)
		{
			orig.Invoke(self, body);
			if (Object.op_Implicit((Object)(object)body.inventory) && body.isBoss && !((Object)body).name.Contains("Brother") && !((Object)body).name.Contains("VoidRaid"))
			{
				body.inventory.GiveItemString("AdaptiveArmor");
			}
		}

		private void CombatDirector_OnEnable(orig_OnEnable orig, CombatDirector self)
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Invalid comparison between Unknown and I4
			orig.Invoke(self);
			if (!Object.op_Implicit((Object)(object)Run.instance) || (int)Run.instance.selectedDifficulty < 4)
			{
				return;
			}
			DirectorMoneyWave[] moneyWaves = self.moneyWaves;
			if (moneyWaves != null && moneyWaves.Length != 0)
			{
				DirectorMoneyWave[] array = moneyWaves;
				foreach (DirectorMoneyWave obj in array)
				{
					obj.multiplier *= 1.15f;
				}
			}
		}

		private void GlobalEventManager_OnCharacterHitGroundServer(orig_OnCharacterHitGroundServer orig, GlobalEventManager self, CharacterBody characterBody, Vector3 impactVelocity)
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_014c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0152: Unknown result type (might be due to invalid IL or missing references)
			//IL_016a: Unknown result type (might be due to invalid IL or missing references)
			//IL_016f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0179: Unknown result type (might be due to invalid IL or missing references)
			//IL_017b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0185: Unknown result type (might be due to invalid IL or missing references)
			//IL_018a: Unknown result type (might be due to invalid IL or missing references)
			//IL_018f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0194: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Expected O, but got Unknown
			//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0206: Unknown result type (might be due to invalid IL or missing references)
			//IL_0209: Unknown result type (might be due to invalid IL or missing references)
			//IL_020e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0213: Unknown result type (might be due to invalid IL or missing references)
			//IL_021e: Expected O, but got Unknown
			//IL_0113: Unknown result type (might be due to invalid IL or missing references)
			//IL_0119: Invalid comparison between Unknown and I4
			//IL_0233: Unknown result type (might be due to invalid IL or missing references)
			//IL_0238: Unknown result type (might be due to invalid IL or missing references)
			//IL_023b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0245: Unknown result type (might be due to invalid IL or missing references)
			//IL_0259: Expected O, but got Unknown
			//IL_0120: Unknown result type (might be due to invalid IL or missing references)
			//IL_0126: Invalid comparison between Unknown and I4
			//IL_02ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_0295: Unknown result type (might be due to invalid IL or missing references)
			bool flag = RunArtifactManager.instance.IsArtifactEnabled(Artifacts.weakAssKneesArtifactDef);
			float num = Mathf.Abs(impactVelocity.y);
			Inventory inventory = characterBody.inventory;
			_ = characterBody.master;
			CharacterMotor characterMotor = characterBody.characterMotor;
			bool flag2 = false;
			if (((Object.op_Implicit((Object)(object)inventory) && inventory.GetItemCount(Items.FallBoots) != 0) ? 1 : 0) <= (false ? 1 : 0) && (characterBody.bodyFlags & 1) == 0)
			{
				float num2 = Mathf.Max(num - (characterBody.jumpPower + 20f), 0f);
				if ((double)num2 > 0.0)
				{
					HealthComponent component = ((Component)characterBody).GetComponent<HealthComponent>();
					if (Object.op_Implicit((Object)(object)component))
					{
						flag2 = true;
						float num3 = num2 / 60f;
						DamageInfo val = new DamageInfo();
						val.attacker = null;
						val.inflictor = null;
						val.crit = false;
						val.damage = num3 * characterBody.maxHealth;
						val.damageType = (DamageType)2097153;
						val.force = Vector3.zero;
						val.position = characterBody.footPosition;
						val.procCoefficient = 0f;
						if (flag || ((int)characterBody.teamComponent.teamIndex == 1 && (int)Run.instance.selectedDifficulty >= 5))
						{
							val.damage *= 2f;
						}
						component.TakeDamage(val);
					}
				}
			}
			if (!Object.op_Implicit((Object)(object)characterMotor) || (double)(FixedTimeStamp.now - characterMotor.lastGroundedTime) <= 0.200000002980232)
			{
				return;
			}
			Vector3 footPosition = characterBody.footPosition;
			float radius = characterBody.radius;
			RaycastHit val2 = default(RaycastHit);
			if (!Physics.Raycast(new Ray(footPosition + Vector3.up * 1.5f, Vector3.down), ref val2, 4f, LayerMask.op_Implicit(((LayerIndex)(ref LayerIndex.world)).mask) | LayerMask.op_Implicit(((LayerIndex)(ref LayerIndex.water)).mask), (QueryTriggerInteraction)2))
			{
				return;
			}
			SurfaceDef objectSurfaceDef = SurfaceDefProvider.GetObjectSurfaceDef(((RaycastHit)(ref val2)).collider, ((RaycastHit)(ref val2)).point);
			if (!Object.op_Implicit((Object)(object)objectSurfaceDef))
			{
				return;
			}
			EffectManager.SpawnEffect(LegacyResourcesAPI.Load<GameObject>("Prefabs/Effects/ImpactEffects/CharacterLandImpact"), new EffectData
			{
				origin = footPosition,
				scale = radius,
				color = Color32.op_Implicit(objectSurfaceDef.approximateColor)
			}, true);
			if (Object.op_Implicit((Object)(object)objectSurfaceDef.footstepEffectPrefab))
			{
				EffectManager.SpawnEffect(objectSurfaceDef.footstepEffectPrefab, new EffectData
				{
					origin = ((RaycastHit)(ref val2)).point,
					scale = radius * 3f
				}, false);
			}
			SfxLocator component2 = ((Component)characterBody).GetComponent<SfxLocator>();
			if (Object.op_Implicit((Object)(object)component2))
			{
				if (objectSurfaceDef.materialSwitchString != null && objectSurfaceDef.materialSwitchString.Length > 0)
				{
					AkSoundEngine.SetSwitch("material", objectSurfaceDef.materialSwitchString, ((Component)characterBody).gameObject);
				}
				else
				{
					AkSoundEngine.SetSwitch("material", "dirt", ((Component)characterBody).gameObject);
				}
				Util.PlaySound(component2.landingSound, ((Component)characterBody).gameObject);
				if (flag2)
				{
					Util.PlaySound(component2.fallDamageSound, ((Component)characterBody).gameObject);
				}
			}
		}
	}
}