Decompiled source of UltimatePerformanceMod v1.0.0

UltimatePerformance.dll

Decompiled a month 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 HG.Reflection;
using On.RoR2;
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: OptIn]
[assembly: TargetFramework(".NETStandard,Version=v2.0", FrameworkDisplayName = "")]
[assembly: AssemblyCompany("UltimatePerformance")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("UltimatePerformance")]
[assembly: AssemblyTitle("UltimatePerformance")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace UltimatePerformance;

internal class GhostTeamIndicator : MonoBehaviour
{
	private ProjectileGhostController ghost;

	private ProjectileController controller;

	private void Start()
	{
		ghost = ((Component)this).GetComponent<ProjectileGhostController>();
	}

	private void FixedUpdate()
	{
		//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00be: Invalid comparison between Unknown and I4
		if ((!Object.op_Implicit((Object)(object)controller) && Object.op_Implicit((Object)(object)ghost) && Object.op_Implicit((Object)(object)ghost.authorityTransform)) || Object.op_Implicit((Object)(object)ghost.predictionTransform))
		{
			controller = (Object.op_Implicit((Object)(object)ghost.authorityTransform) ? ((Component)ghost.authorityTransform).GetComponent<ProjectileController>() : ((Component)ghost.predictionTransform).GetComponent<ProjectileController>());
			if (Object.op_Implicit((Object)(object)controller) && Object.op_Implicit((Object)(object)controller.teamFilter))
			{
				((Component)this).GetComponent<Renderer>().material = (((int)controller.teamFilter.teamIndex == 1) ? Prefabs.playerProjectileMat : Prefabs.enemyProjectileMat);
				((Behaviour)this).enabled = false;
			}
		}
	}
}
internal class Hook
{
	[Serializable]
	[CompilerGenerated]
	private sealed class <>c
	{
		public static readonly <>c <>9 = new <>c();

		public static hook_SpawnEffect_EffectIndex_EffectData_bool <>9__0_0;

		public static hook_FindProjectileGhostPrefab <>9__0_1;

		internal void <Hooks>b__0_0(orig_SpawnEffect_EffectIndex_EffectData_bool o, EffectIndex e, EffectData d, bool b)
		{
		}

		internal GameObject <Hooks>b__0_1(orig_FindProjectileGhostPrefab o, ProjectileController g)
		{
			return Prefabs.basicProjectileGhost;
		}
	}

	internal static void Hooks()
	{
		//IL_0024: Unknown result type (might be due to invalid IL or missing references)
		//IL_0029: Unknown result type (might be due to invalid IL or missing references)
		//IL_002f: Expected O, but got Unknown
		//IL_0059: Unknown result type (might be due to invalid IL or missing references)
		//IL_005e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0064: Expected O, but got Unknown
		if (MainPlugin.removeEffects.Value)
		{
			object obj = <>c.<>9__0_0;
			if (obj == null)
			{
				hook_SpawnEffect_EffectIndex_EffectData_bool val = delegate
				{
				};
				<>c.<>9__0_0 = val;
				obj = (object)val;
			}
			EffectManager.SpawnEffect_EffectIndex_EffectData_bool += (hook_SpawnEffect_EffectIndex_EffectData_bool)obj;
		}
		if (!MainPlugin.removeProjectileGhosts.Value)
		{
			return;
		}
		object obj2 = <>c.<>9__0_1;
		if (obj2 == null)
		{
			hook_FindProjectileGhostPrefab val2 = (orig_FindProjectileGhostPrefab o, ProjectileController g) => Prefabs.basicProjectileGhost;
			<>c.<>9__0_1 = val2;
			obj2 = (object)val2;
		}
		ProjectileGhostReplacementManager.FindProjectileGhostPrefab += (hook_FindProjectileGhostPrefab)obj2;
	}

	[SystemInitializer(new Type[] { typeof(ProjectileCatalog) })]
	public static void RemoveGhosts()
	{
		if (!MainPlugin.removeProjectileGhosts.Value)
		{
			return;
		}
		GameObject[] projectilePrefabs = ProjectileCatalog.projectilePrefabs;
		foreach (GameObject val in projectilePrefabs)
		{
			DotController component = val.GetComponent<DotController>();
			if (Object.op_Implicit((Object)(object)component) && !MainPlugin.removeDotEffects.Value)
			{
				Renderer[] componentsInChildren = val.GetComponentsInChildren<Renderer>();
				foreach (Renderer val2 in componentsInChildren)
				{
					if (!Object.op_Implicit((Object)(object)val.GetComponent<TeamAreaIndicator>()))
					{
						((Component)val2).gameObject.SetActive(false);
					}
				}
				continue;
			}
			Renderer[] componentsInChildren2 = val.GetComponentsInChildren<Renderer>();
			foreach (Renderer val3 in componentsInChildren2)
			{
				if (!Object.op_Implicit((Object)(object)val.GetComponent<TeamAreaIndicator>()))
				{
					((Component)val3).gameObject.SetActive(false);
				}
			}
		}
	}
}
[BepInPlugin("com.Dragonyck.UltimatePerformance", "UltimatePerformance", "1.0.0")]
public class MainPlugin : BaseUnityPlugin
{
	public const string MODUID = "com.Dragonyck.UltimatePerformance";

	public const string MODNAME = "UltimatePerformance";

	public const string VERSION = "1.0.0";

	public static ConfigEntry<bool> removeProjectileGhosts;

	public static ConfigEntry<bool> removeDotEffects;

	public static ConfigEntry<bool> removeEffects;

	private void Awake()
	{
		//IL_0011: 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_002c: Expected O, but got Unknown
		//IL_002c: Expected O, but got Unknown
		//IL_0041: 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_005c: Expected O, but got Unknown
		//IL_005c: Expected O, but got Unknown
		//IL_0071: Unknown result type (might be due to invalid IL or missing references)
		//IL_0082: Unknown result type (might be due to invalid IL or missing references)
		//IL_008c: Expected O, but got Unknown
		//IL_008c: Expected O, but got Unknown
		removeProjectileGhosts = ((BaseUnityPlugin)this).Config.Bind<bool>(new ConfigDefinition("Remove Projectile Effects", "Value"), true, new ConfigDescription("Projectile visuals will be swapped for team colored circles. Doesn't affect Dot prefabs.", (AcceptableValueBase)null, Array.Empty<object>()));
		removeDotEffects = ((BaseUnityPlugin)this).Config.Bind<bool>(new ConfigDefinition("Remove DotZone Effects", "Value"), true, new ConfigDescription("DotZone effects on the ground will be removed, but circle indicators will stay. Needs 'Remove Projectile Effects' enabled to work.", (AcceptableValueBase)null, Array.Empty<object>()));
		removeEffects = ((BaseUnityPlugin)this).Config.Bind<bool>(new ConfigDefinition("Remove All Effects", "Value"), true, new ConfigDescription("Removes all effects that are spawned through EffectManager, like hit/muzzle effects. Some charge effects will still spawn. OrbEffects are left untouched. NetworkedBodyAttachment prefabs are also untouched, so particle effects on it will still show up.", (AcceptableValueBase)null, Array.Empty<object>()));
		Prefabs.CreatePrefabs();
		Hook.Hooks();
	}
}
internal class Prefabs
{
	internal static GameObject basicProjectileGhost;

	internal static Material playerProjectileMat;

	internal static Material enemyProjectileMat;

	internal static T Load<T>(string path)
	{
		//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)
		return Addressables.LoadAssetAsync<T>((object)path).WaitForCompletion();
	}

	internal static void CreatePrefabs()
	{
		//IL_000d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0017: Expected O, but got Unknown
		//IL_0021: Unknown result type (might be due to invalid IL or missing references)
		//IL_002d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0037: Expected O, but got Unknown
		//IL_0041: Unknown result type (might be due to invalid IL or missing references)
		//IL_0051: Unknown result type (might be due to invalid IL or missing references)
		//IL_0057: Expected O, but got Unknown
		//IL_007e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0088: Expected O, but got Unknown
		//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
		//IL_00af: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
		//IL_0106: Unknown result type (might be due to invalid IL or missing references)
		//IL_010b: Unknown result type (might be due to invalid IL or missing references)
		Material val = Load<Material>("RoR2/Base/Captain/matCaptainFlareRing.mat");
		playerProjectileMat = new Material(val);
		playerProjectileMat.SetColor("_TintColor", Color.blue);
		enemyProjectileMat = new Material(val);
		enemyProjectileMat.SetColor("_TintColor", Color.red);
		GameObject val2 = new GameObject("Prefabs");
		Object.DontDestroyOnLoad((Object)(object)val2);
		val2.SetActive(false);
		basicProjectileGhost = new GameObject("ProjectileGhost", new Type[1] { typeof(ParticleSystem) });
		basicProjectileGhost.AddComponent<ProjectileGhostController>();
		basicProjectileGhost.AddComponent<GhostTeamIndicator>();
		ParticleSystem component = basicProjectileGhost.GetComponent<ParticleSystem>();
		MainModule main = component.main;
		((MainModule)(ref main)).duration = 1f;
		((MainModule)(ref main)).startLifetime = MinMaxCurve.op_Implicit(99999f);
		((MainModule)(ref main)).startSpeed = MinMaxCurve.op_Implicit(0f);
		((MainModule)(ref main)).loop = false;
		((MainModule)(ref main)).playOnAwake = true;
		((MainModule)(ref main)).maxParticles = 1;
		((MainModule)(ref main)).scalingMode = (ParticleSystemScalingMode)0;
		ShapeModule shape = component.shape;
		((ShapeModule)(ref shape)).enabled = false;
		basicProjectileGhost.transform.parent = val2.transform;
	}
}