Decompiled source of Worms Underground Overlay v1.0.0

plugins/WormsUndergroundOverlay.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 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("WormsUndergroundOverlay")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("WormsUndergroundOverlay")]
[assembly: AssemblyTitle("WormsUndergroundOverlay")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: RefSafetyRules(11)]
[module: UnverifiableCode]
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 WormsUndergroundOverlay
{
	[Serializable]
	[BepInPlugin("com.brynzananas.wormsundergroundoverlay", "Worms Underground Overlay", "1.0.0")]
	public class WormsUndergroundOverlayPlugin : BaseUnityPlugin
	{
		public const string ModGuid = "com.brynzananas.wormsundergroundoverlay";

		public const string ModName = "Worms Underground Overlay";

		public const string ModVer = "1.0.0";

		public static Material ChefAlwaysOnTop;

		public static GameObject MagmaWormBody;

		public static GameObject ElectricWormBody;

		public static Material MagmaWormMaterial;

		public static Material EletricWormMaterial;

		public static ConfigEntry<bool> ChangeRenderQueue;

		public void Awake()
		{
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//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_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			ChangeRenderQueue = ((BaseUnityPlugin)this).Config.Bind<bool>("Main", "Change render queue of body materials?", true, "Set to false to make overlay always cover body material");
			ChefAlwaysOnTop = Addressables.LoadAssetAsync<Material>((object)"RoR2/DLC2/Chef/matChef_AlwaysOnTop.mat").WaitForCompletion();
			MagmaWormBody = Addressables.LoadAssetAsync<GameObject>((object)"RoR2/Base/MagmaWorm/MagmaWormBody.prefab").WaitForCompletion();
			ElectricWormBody = Addressables.LoadAssetAsync<GameObject>((object)"RoR2/Base/ElectricWorm/ElectricWormBody.prefab").WaitForCompletion();
			AddUndergroundOverlay(MagmaWormBody);
			AddUndergroundOverlay(ElectricWormBody);
			if (ChangeRenderQueue.Value)
			{
				MagmaWormMaterial = Addressables.LoadAssetAsync<Material>((object)"RoR2/Base/MagmaWorm/matMagmaWorm.mat").WaitForCompletion();
				MagmaWormMaterial.renderQueue = 4001;
				EletricWormMaterial = Addressables.LoadAssetAsync<Material>((object)"RoR2/Base/MagmaWorm/matElectricWorm.mat").WaitForCompletion();
				EletricWormMaterial.renderQueue = 4001;
			}
		}

		public static void AddUndergroundOverlay(GameObject bodyPrefab)
		{
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			CharacterBody component = bodyPrefab.GetComponent<CharacterBody>();
			if (!Object.op_Implicit((Object)(object)component))
			{
				return;
			}
			ModelLocator component2 = bodyPrefab.GetComponent<ModelLocator>();
			if (!Object.op_Implicit((Object)(object)component2))
			{
				return;
			}
			Transform modelTransform = component2._modelTransform;
			if (Object.op_Implicit((Object)(object)modelTransform))
			{
				CharacterModel component3 = ((Component)modelTransform).GetComponent<CharacterModel>();
				if (Object.op_Implicit((Object)(object)component3))
				{
					Material val = Object.Instantiate<Material>(ChefAlwaysOnTop);
					val.color = component.bodyColor;
					((Object)val).name = "mat" + ((Object)bodyPrefab).name + "AlwaysOnTop";
					TemporaryOverlay val2 = ((Component)modelTransform).gameObject.AddComponent<TemporaryOverlay>();
					val2.animateShaderAlpha = false;
					val2.destroyComponentOnEnd = false;
					val2.destroyObjectOnEnd = false;
					val2.duration = float.MaxValue;
					val2.inspectorCharacterModel = component3;
					val2.playOnAwake = true;
					val2.originalMaterial = val;
				}
			}
		}
	}
}