Decompiled source of ProviTweaks v1.0.0

ProviTweaks.dll

Decompiled 8 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 Microsoft.CodeAnalysis;
using RoR2;
using RoR2.Projectile;
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("ProviTweaks")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+57db2c0a24f8a9e16dbdbb4c57b09186fbd4ce3d")]
[assembly: AssemblyProduct("ProviTweaks")]
[assembly: AssemblyTitle("ProviTweaks")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
}
namespace ProviTweaks
{
	[BepInPlugin("com.Moffein.ProviTweaks", "ProviTweaks", "1.0.0")]
	public class ProviTweaksPlugin : BaseUnityPlugin
	{
		public static bool buffDamage;

		public static bool freezeResist;

		public static bool nerfWurmHP;

		public static bool nerfPhase4HP;

		public static bool removePhaseSkips;

		public static bool buffProviMalachiteHoming;

		private void Awake()
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Expected O, but got Unknown
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Expected O, but got Unknown
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Expected O, but got Unknown
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: Expected O, but got Unknown
			//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f5: Expected O, but got Unknown
			//IL_0121: Unknown result type (might be due to invalid IL or missing references)
			//IL_012d: Expected O, but got Unknown
			freezeResist = ((BaseUnityPlugin)this).Config.Bind<bool>(new ConfigDefinition("Settings", "Freeze Resistance"), true, (ConfigDescription)null).Value;
			if (freezeResist)
			{
				FreezeResist();
			}
			buffDamage = ((BaseUnityPlugin)this).Config.Bind<bool>(new ConfigDefinition("Settings", "Buff Damage"), true, (ConfigDescription)null).Value;
			if (buffDamage)
			{
				BuffDamage();
			}
			buffProviMalachiteHoming = ((BaseUnityPlugin)this).Config.Bind<bool>(new ConfigDefinition("Settings", "Consistent Malachite Energy Ball Homing"), true, (ConfigDescription)null).Value;
			if (buffProviMalachiteHoming)
			{
				MalachiteHoming();
			}
			nerfWurmHP = ((BaseUnityPlugin)this).Config.Bind<bool>(new ConfigDefinition("Settings", "Phase 2 - Nerf Wurm HP"), true, (ConfigDescription)null).Value;
			if (nerfWurmHP)
			{
				NerfWurmHP();
			}
			nerfPhase4HP = ((BaseUnityPlugin)this).Config.Bind<bool>(new ConfigDefinition("Settings", "Phase 4 - Nerf HP"), true, (ConfigDescription)null).Value;
			if (nerfPhase4HP)
			{
				NerfPhase4HP();
			}
			removePhaseSkips = ((BaseUnityPlugin)this).Config.Bind<bool>(new ConfigDefinition("Settings", "Remove Phase Skipping"), true, (ConfigDescription)null).Value;
			if (removePhaseSkips)
			{
				RemovePhaseSkips();
			}
		}

		public GameObject GetProviPhase1()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			return Addressables.LoadAssetAsync<GameObject>((object)"49a36f2f5301b6d4c81788b564647653").WaitForCompletion();
		}

		public GameObject GetProviPhase3()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			return Addressables.LoadAssetAsync<GameObject>((object)"7760f3431e7b28e4cb9db0fc8d596c34").WaitForCompletion();
		}

		public GameObject GetProviPhase4()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			return Addressables.LoadAssetAsync<GameObject>((object)"321baa9bbc94f3a41a1e0d1c53faf14d").WaitForCompletion();
		}

		public GameObject GetProviShadowClone()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			return Addressables.LoadAssetAsync<GameObject>((object)"7dca732a74031394280060323650cec2").WaitForCompletion();
		}

		public GameObject GetProviShadowCloneLasor()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			return Addressables.LoadAssetAsync<GameObject>((object)"9ae8aed032df19a449a39553df1dd1d3").WaitForCompletion();
		}

		public GameObject GetGildedWurmLaser()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			return Addressables.LoadAssetAsync<GameObject>((object)"79b1ab93254bec7459befdb838c09aee").WaitForCompletion();
		}

		public GameObject GetGildedWurmOrb()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			return Addressables.LoadAssetAsync<GameObject>((object)"b03cedc4247b68245a41b3a219d77082").WaitForCompletion();
		}

		private void FreezeResist()
		{
			AddFreezeResist(GetProviPhase1());
			AddFreezeResist(GetProviPhase3());
			AddFreezeResist(GetProviPhase4());
			AddFreezeResist(GetProviShadowClone());
			static void AddFreezeResist(GameObject bodyObject)
			{
				AlterBuffDuration[] components = bodyObject.GetComponents<AlterBuffDuration>();
				bool flag = false;
				if (components != null)
				{
					foreach (AlterBuffDuration val in components)
					{
						if (Object.op_Implicit((Object)(object)val) && val.customName == "FreezeResistance")
						{
							flag = true;
							return;
						}
					}
				}
				if (!flag)
				{
					AlterBuffDuration val2 = bodyObject.AddComponent<AlterBuffDuration>();
					val2.customName = "FreezeResistance";
					val2.durationScalar = 0.5f;
					val2.affectsFreeze = true;
					val2.affectsMidasTouch = true;
					val2.affectsStunStates = true;
				}
			}
		}

		private void MalachiteHoming()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			Addressables.LoadAssetAsync<GameObject>((object)"f659b06778fd6174397fbaf44baf2484").WaitForCompletion().GetComponent<ProvidenceMalachiteEnergyProjectileController>()
				.turnSpeedAfterActivation = 40f;
		}

		private void BuffDamage()
		{
			//IL_018e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0193: Unknown result type (might be due to invalid IL or missing references)
			GameObject proviPhase = GetProviPhase4();
			GameObject proviShadowClone = GetProviShadowClone();
			CharacterBody component = proviShadowClone.GetComponent<CharacterBody>();
			component.baseDamage = 11f;
			component.levelDamage = 2.2f;
			GameObject proviShadowCloneLasor = GetProviShadowCloneLasor();
			CharacterBody component2 = proviShadowCloneLasor.GetComponent<CharacterBody>();
			component2.baseDamage = 11f;
			component2.levelDamage = 2.2f;
			BuffMalachiteEnergyBall(GetProviPhase1());
			BuffMalachiteEnergyBall(GetProviPhase3());
			BuffMalachiteEnergyBall(GetProviPhase4());
			BuffMalachiteEnergyBall(proviPhase);
			BuffMalachiteEnergyBall(proviShadowClone);
			BuffMalachiteEnergyBall(proviShadowCloneLasor);
			GetGildedWurmOrb().GetComponent<WormBodyPositions2>().meatballDamageCoefficient = 2.4f;
			SneedUtils.SetAddressableEntityStateField("87cb60f0d335f8142abdc70bd7da6858", "damageCoefficient", "5");
			SneedUtils.SetAddressableEntityStateField("1a829e96fe9101d4ba6fd723b674f991", "damageCoefficient", "5");
			SneedUtils.SetAddressableEntityStateField("51756521a12695b48b42ceca58712e71", "damageCoefficient", "7");
			SneedUtils.SetAddressableEntityStateField("51756521a12695b48b42ceca58712e71", "projectileDamageCoefficient", "3.5");
			SneedUtils.SetAddressableEntityStateField("2af7311b34b9940428edc7c6630ef48c", "damageCoefficient", "7");
			SneedUtils.SetAddressableEntityStateField("2af7311b34b9940428edc7c6630ef48c", "projectileDamageCoefficient", "3.5");
			SneedUtils.SetAddressableEntityStateField("3c9674995c358654f8289f8017058c00", "damageCoefficient", "7");
			SneedUtils.SetAddressableEntityStateField("3c9674995c358654f8289f8017058c00", "projectileDamageCoefficient", "3.5");
			SneedUtils.SetAddressableEntityStateField("51756521a12695b48b42ceca58712e71", "desperationProjectileDamageCoefficient", "5");
			SneedUtils.SetAddressableEntityStateField("2af7311b34b9940428edc7c6630ef48c", "desperationProjectileDamageCoefficient", "5");
			GetGildedWurmLaser().GetComponent<WormBodyPositions2>().meatballDamageCoefficient = 6.25f;
			Addressables.LoadAssetAsync<GameObject>((object)"301aad72a0758474cad5ca864f9f4079").WaitForCompletion().GetComponent<ProvidenceLocalMineController>()
				.damageCoefficient = 8f;
			SneedUtils.SetAddressableEntityStateField("cdb3ef2d24b3f35419f825a646c0e8bb", "malachiteOrbDamageCoefficient", "2");
			SneedUtils.SetAddressableEntityStateField("cdb3ef2d24b3f35419f825a646c0e8bb", "lasorPillarDamageCoefficient", "5");
			proviPhase.GetComponent<ProvidenceFinalPhaseDamageAura>().hitFrequency = 10f;
			static void BuffMalachiteEnergyBall(GameObject bodyObject)
			{
				ProvidenceController component3 = bodyObject.GetComponent<ProvidenceController>();
				if (Object.op_Implicit((Object)(object)component3))
				{
					component3.malachiteEnergyDamageCoefficient = 2f;
				}
				ProvidenceShadowCloneController component4 = bodyObject.GetComponent<ProvidenceShadowCloneController>();
				if (Object.op_Implicit((Object)(object)component4))
				{
					component4.malachiteEnergyDamageCoefficient = 2f;
				}
			}
		}

		private void NerfPhase4HP()
		{
			GameObject proviPhase = GetProviPhase4();
			CharacterBody component = proviPhase.GetComponent<CharacterBody>();
			if (component.baseMaxHealth > 1000f)
			{
				component.baseMaxHealth = 1000f;
			}
			if (component.levelMaxHealth > 300f)
			{
				component.levelMaxHealth = 300f;
			}
		}

		private void NerfWurmHP()
		{
			ModifyStats(GetGildedWurmOrb());
			ModifyStats(GetGildedWurmLaser());
			static void ModifyStats(GameObject bodyObject)
			{
				CharacterBody component = bodyObject.GetComponent<CharacterBody>();
				if (component.baseMaxHealth > 400f)
				{
					component.baseMaxHealth = 400f;
				}
				if (component.levelMaxHealth > 120f)
				{
					component.levelMaxHealth = 120f;
				}
			}
		}

		private void RemovePhaseSkips()
		{
			ApplyPhaseSkipProtection(GetProviPhase1());
			ApplyPhaseSkipProtection(GetGildedWurmOrb());
			ApplyPhaseSkipProtection(GetGildedWurmLaser());
			ApplyPhaseSkipProtection(GetProviPhase3());
			ApplyPhaseSkipProtection(GetProviPhase4());
			static void ApplyPhaseSkipProtection(GameObject bodyObject)
			{
				bodyObject.AddComponent<RemoveGodModeAfterDelay>();
				bodyObject.GetComponent<HealthComponent>().isDefaultGodMode = true;
			}
		}
	}
	[RequireComponent(typeof(HealthComponent))]
	public class RemoveGodModeAfterDelay : MonoBehaviour
	{
		public float delay = 0.25f;

		private float stopwatch;

		private void OnEnable()
		{
			stopwatch = 0f;
		}

		private void FixedUpdate()
		{
			stopwatch += Time.fixedDeltaTime;
			if (stopwatch >= delay)
			{
				HealthComponent component = ((Component)this).GetComponent<HealthComponent>();
				if (Object.op_Implicit((Object)(object)component))
				{
					component.godMode = false;
				}
				((Behaviour)this).enabled = false;
			}
		}
	}
	public static class SneedUtils
	{
		public static bool SetAddressableEntityStateField(string fullEntityStatePath, string fieldName, string value)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			EntityStateConfiguration val = Addressables.LoadAssetAsync<EntityStateConfiguration>((object)fullEntityStatePath).WaitForCompletion();
			for (int i = 0; i < val.serializedFieldsCollection.serializedFields.Length; i++)
			{
				if (val.serializedFieldsCollection.serializedFields[i].fieldName == fieldName)
				{
					val.serializedFieldsCollection.serializedFields[i].fieldValue.stringValue = value;
					return true;
				}
			}
			return false;
		}
	}
}
namespace R2API.Utils
{
	[AttributeUsage(AttributeTargets.Assembly)]
	public class ManualNetworkRegistrationAttribute : Attribute
	{
	}
}