Decompiled source of ContrastTraps v1.0.1

plugins/dev.kirsho.ContrastTraps.dll

Decompiled 2 days 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 BepInEx.Logging;
using ContrastTraps.Configuration;
using ContrastTraps.Patches;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("dev.kirsho.ContrastTraps")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.1.0")]
[assembly: AssemblyInformationalVersion("1.0.1")]
[assembly: AssemblyProduct("dev.kirsho.ContrastTraps")]
[assembly: AssemblyTitle("ContrastTraps")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.1.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
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;
		}
	}
	[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 BepInEx
{
	[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
	[Conditional("CodeGeneration")]
	internal sealed class BepInAutoPluginAttribute : Attribute
	{
		public BepInAutoPluginAttribute(string? id = null, string? name = null, string? version = null)
		{
		}
	}
}
namespace BepInEx.Preloader.Core.Patching
{
	[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
	[Conditional("CodeGeneration")]
	internal sealed class PatcherAutoPluginAttribute : Attribute
	{
		public PatcherAutoPluginAttribute(string? id = null, string? name = null, string? version = null)
		{
		}
	}
}
namespace ContrastTraps
{
	[BepInPlugin("dev.kirsho.ContrastTraps", "ContrastTraps", "1.0.1")]
	public class Plugin : BaseUnityPlugin
	{
		public const string Id = "dev.kirsho.ContrastTraps";

		internal static ManualLogSource Log { get; private set; }

		public static string Name => "ContrastTraps";

		public static string Version => "1.0.1";

		private void Awake()
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			Log = ((BaseUnityPlugin)this).Logger;
			new Harmony("dev.kirsho.ContrastTraps").PatchAll(typeof(ArrowShooterPatch));
			BindConfig();
			Log.LogInfo((object)("Plugin " + Name + " is loaded!"));
		}

		private void BindConfig()
		{
			ColorConfig.Bind(((BaseUnityPlugin)this).Config);
		}
	}
}
namespace ContrastTraps.Patches
{
	internal class ArrowShooterPatch
	{
		public static Material? solidMaterial;

		private const string ShaderName = "Universal Render Pipeline/Unlit";

		public static Material EnsureMaterial()
		{
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Expected O, but got Unknown
			if ((Object)(object)solidMaterial == (Object)null)
			{
				Shader val = Shader.Find("Universal Render Pipeline/Unlit");
				if ((Object)(object)val == (Object)null)
				{
					throw new ArgumentException("Unable to find Shader with name 'Universal Render Pipeline/Unlit'");
				}
				solidMaterial = new Material(val);
			}
			return solidMaterial;
		}

		[HarmonyPatch(typeof(ArrowShooter), "Awake")]
		[HarmonyPostfix]
		public static void ExtendAwakeFunction(ArrowShooter __instance)
		{
			ChangeColorOfLine(__instance);
			SubscribeToColorChanges(__instance);
		}

		public static void ChangeColorOfLine(ArrowShooter shooter)
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			((Renderer)shooter.lineRenderer).material.color = ColorConfig.TrapColor;
		}

		public static void ReplaceLineRendererMaterial(ArrowShooter shooter)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			Material val = EnsureMaterial();
			val.color = ColorConfig.TrapColor;
			((Renderer)shooter.lineRenderer).material = val;
		}

		public static void SubscribeToColorChanges(ArrowShooter shooter)
		{
			ColorConfig._trapColor.SettingChanged += delegate
			{
				//IL_0010: Unknown result type (might be due to invalid IL or missing references)
				((Renderer)shooter.lineRenderer).material.color = ColorConfig.TrapColor;
			};
		}
	}
}
namespace ContrastTraps.Configuration
{
	internal class ColorConfig
	{
		internal static ConfigEntry<Color>? _trapColor;

		public static Color TrapColor
		{
			get
			{
				//IL_0017: Unknown result type (might be due to invalid IL or missing references)
				if (_trapColor == null)
				{
					throw new InvalidOperationException("Configuration file is not binded, cannot return value.");
				}
				return _trapColor.Value;
			}
		}

		public static void Bind(ConfigFile config)
		{
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			_trapColor = config.Bind<Color>("Colors", "WarningLineColor", new Color(150f, 150f, 150f, 1f), "Color to change the warning lines of arrow shooter traps to.");
		}
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}