Decompiled source of BetterArrowRain v1.0.0

plugins/ExamplePlugin.dll

Decompiled 9 hours ago
using System;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using EntityStates;
using EntityStates.Huntress;
using HG.GeneralSerializer;
using Microsoft.CodeAnalysis;
using On.EntityStates.Huntress;
using R2API;
using RiskOfOptions;
using RiskOfOptions.Options;
using RoR2;
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("ExamplePlugin")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("ExamplePlugin")]
[assembly: AssemblyTitle("ExamplePlugin")]
[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 ExamplePlugin
{
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInPlugin("nayDPz.ArrowRain2", "ArrowRain2", "1.0.0")]
	public class ExamplePlugin : BaseUnityPlugin
	{
		public const string PluginGUID = "nayDPz.ArrowRain2";

		public const string PluginAuthor = "nayDPz";

		public const string PluginName = "ArrowRain2";

		public const string PluginVersion = "1.0.0";

		public const string RiskOfOptionsGUID = "com.rune580.riskofoptions";

		private static ItemDef myItemDef;

		public static ConfigEntry<float> HitboxHeight { get; set; }

		public void Awake()
		{
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_0296: Unknown result type (might be due to invalid IL or missing references)
			//IL_029b: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ec: Expected O, but got Unknown
			//IL_03f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_03fe: Expected O, but got Unknown
			//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0306: Unknown result type (might be due to invalid IL or missing references)
			//IL_030b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0314: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0111: Unknown result type (might be due to invalid IL or missing references)
			//IL_0118: Expected O, but got Unknown
			//IL_012e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0186: Unknown result type (might be due to invalid IL or missing references)
			//IL_018b: 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_021a: Expected O, but got Unknown
			//IL_0230: Unknown result type (might be due to invalid IL or missing references)
			//IL_0372: Unknown result type (might be due to invalid IL or missing references)
			//IL_038b: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b0: Unknown result type (might be due to invalid IL or missing references)
			Log.Init(((BaseUnityPlugin)this).Logger);
			HitboxHeight = ((BaseUnityPlugin)this).Config.Bind<float>("Hitbox Y Scale", "Value", 3.61f, "Modifies the vertical scale of Arrow Rain's hitbox");
			if (Chainloader.PluginInfos.ContainsKey("com.rune580.riskofoptions"))
			{
				ROOConfig.DoConfigDude();
			}
			GameObject val = Addressables.LoadAssetAsync<GameObject>((object)"RoR2/DLC2/Seeker/UnseenHandAreaIndicator.prefab").WaitForCompletion();
			GameObject val2 = PrefabAPI.InstantiateClone(val, "ArrowRain2Indicator");
			EntityStateConfiguration val3 = Addressables.LoadAssetAsync<EntityStateConfiguration>((object)"RoR2/Base/Huntress/EntityStates.Huntress.ArrowRain.asset").WaitForCompletion();
			if (Object.op_Implicit((Object)(object)val3) && Object.op_Implicit((Object)(object)val2))
			{
				Transform val4 = val2.transform.Find("Mesh/Point Light");
				Light val5 = default(Light);
				if (Object.op_Implicit((Object)(object)val4) && ((Component)val4).TryGetComponent<Light>(ref val5))
				{
					val5.color = new Color(0f, 0.75f, 1f);
				}
				Material val6 = Addressables.LoadAssetAsync<Material>((object)"RoR2/DLC2/Seeker/matUnseenHandAreaIndicator.mat").WaitForCompletion();
				if (Object.op_Implicit((Object)(object)val6))
				{
					val6 = new Material(val6);
					val6.SetColor("_TintColor", new Color(0f, 0.38039216f, 1f));
					val6.SetFloat("_SrcBlend", 1f);
					val6.SetFloat("_SrcBlendFloat", 1f);
					val6.SetFloat("_DstBlend", 1f);
					val6.SetFloat("_DstBlendFloat", 1f);
					Texture val7 = Addressables.LoadAssetAsync<Texture>((object)"RoR2/Base/Common/ColorRamps/texRampHuntressSoft.png").WaitForCompletion();
					if (Object.op_Implicit((Object)(object)val7))
					{
						val6.SetTexture("_RemapTex", val7);
					}
					Transform val8 = val2.transform.Find("Mesh");
					MeshRenderer val9 = default(MeshRenderer);
					if (Object.op_Implicit((Object)(object)val8) && ((Component)val8).TryGetComponent<MeshRenderer>(ref val9))
					{
						((Renderer)val9).sharedMaterial = val6;
					}
				}
				Material val10 = Addressables.LoadAssetAsync<Material>((object)"RoR2/DLC2/Seeker/matUnseenHandVerticalWallRay.mat").WaitForCompletion();
				if (Object.op_Implicit((Object)(object)val10))
				{
					val10 = new Material(val10);
					val10.SetColor("_TintColor", new Color(0f, 0.8745098f, 1f));
					Transform val11 = val2.transform.Find("Mesh/GlowGradient");
					ParticleSystemRenderer val12 = default(ParticleSystemRenderer);
					if (Object.op_Implicit((Object)(object)val11) && ((Component)val11).TryGetComponent<ParticleSystemRenderer>(ref val12))
					{
						((Renderer)val12).sharedMaterial = val10;
					}
				}
				((SerializedFieldCollection)(ref val3.serializedFieldsCollection)).GetOrCreateField("areaIndicatorPrefab").fieldValue.objectValue = (Object)(object)val2;
			}
			GameObject val13 = Addressables.LoadAssetAsync<GameObject>((object)"RoR2/Base/Huntress/HuntressArrowRain.prefab").WaitForCompletion();
			if (Object.op_Implicit((Object)(object)val13))
			{
				Transform val14 = val13.transform.Find("FX/ArrowsFalling");
				ParticleSystem val15 = default(ParticleSystem);
				if (Object.op_Implicit((Object)(object)val14) && ((Component)val14).TryGetComponent<ParticleSystem>(ref val15))
				{
					((Component)val14).transform.localPosition = new Vector3(0f, 4f, 0f);
					MainModule main = val15.main;
					((MainModule)(ref main)).startLifetime = MinMaxCurve.op_Implicit(0.3f);
				}
				HitBoxGroup component = val13.GetComponent<HitBoxGroup>();
				if (Object.op_Implicit((Object)(object)component))
				{
					for (int i = 0; i < component.hitBoxes.Length; i++)
					{
						HitBox val16 = component.hitBoxes[i];
						if (Object.op_Implicit((Object)(object)val16))
						{
							((Component)val16).transform.localPosition = new Vector3(0f, 1.68f, 0f);
							((Component)val16).transform.localScale = new Vector3(((Component)val16).transform.localScale.x, HitboxHeight.Value, ((Component)val16).transform.localScale.z);
						}
					}
				}
			}
			ArrowRain.OnEnter += new hook_OnEnter(ArrowRain_OnEnter);
			ArrowRain.UpdateAreaIndicator += new hook_UpdateAreaIndicator(ArrowRain_UpdateAreaIndicator);
		}

		private void ArrowRain_OnEnter(orig_OnEnter orig, ArrowRain self)
		{
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			orig.Invoke(self);
			UnseenHandIndicator val = default(UnseenHandIndicator);
			if (Object.op_Implicit((Object)(object)self.areaIndicatorInstance) && self.areaIndicatorInstance.TryGetComponent<UnseenHandIndicator>(ref val))
			{
				val.teamMask = TeamMask.GetUnprotectedTeams(((EntityState)self).teamComponent.teamIndex);
				val.caster = ((EntityState)self).characterBody;
			}
		}

		private void ArrowRain_UpdateAreaIndicator(orig_UpdateAreaIndicator orig, ArrowRain self)
		{
			//IL_0023: 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_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			orig.Invoke(self);
			if (Object.op_Implicit((Object)(object)self.areaIndicatorInstance))
			{
				float num = 1000f;
				Ray aimRay = ((BaseState)self).GetAimRay();
				RaycastHit val = default(RaycastHit);
				if (Physics.Raycast(aimRay, ref val, num, LayerMask.op_Implicit(((LayerIndex)(ref LayerIndex.world)).mask)))
				{
					self.areaIndicatorInstance.transform.position = ((RaycastHit)(ref val)).point;
					self.areaIndicatorInstance.transform.up = Vector3.up;
				}
				else
				{
					self.areaIndicatorInstance.transform.position = ((Ray)(ref aimRay)).GetPoint(num);
					self.areaIndicatorInstance.transform.up = Vector3.up;
				}
			}
		}
	}
	internal static class Log
	{
		private static ManualLogSource _logSource;

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

		private static string Format(object data, string file, int line)
		{
			string fileName = Path.GetFileName(file);
			return $"[{fileName}:{line}] {data}";
		}

		internal static void Debug(object data, [CallerFilePath] string file = "", [CallerLineNumber] int line = 0)
		{
			_logSource.LogDebug((object)Format(data, file, line));
		}

		internal static void Error(object data, [CallerFilePath] string file = "", [CallerLineNumber] int line = 0)
		{
			_logSource.LogError((object)Format(data, file, line));
		}

		internal static void Fatal(object data, [CallerFilePath] string file = "", [CallerLineNumber] int line = 0)
		{
			_logSource.LogFatal((object)Format(data, file, line));
		}

		internal static void Info(object data, [CallerFilePath] string file = "", [CallerLineNumber] int line = 0)
		{
			_logSource.LogInfo((object)Format(data, file, line));
		}

		internal static void Message(object data, [CallerFilePath] string file = "", [CallerLineNumber] int line = 0)
		{
			_logSource.LogMessage((object)Format(data, file, line));
		}

		internal static void Warning(object data, [CallerFilePath] string file = "", [CallerLineNumber] int line = 0)
		{
			_logSource.LogWarning((object)Format(data, file, line));
		}
	}
	public static class ROOConfig
	{
		[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
		public static void DoConfigDude()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Expected O, but got Unknown
			ModSettingsManager.AddOption((BaseOption)new FloatFieldOption(ExamplePlugin.HitboxHeight));
		}
	}
}