Decompiled source of ChebsDemolisherSword v1.2.2

plugins/ChebsDemolisherSword.dll

Decompiled 6 months ago
using System;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Resources;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using Jotunn.Managers;
using Jotunn.Utils;
using Microsoft.CodeAnalysis;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: IgnoresAccessChecksTo("assembly_guiutils")]
[assembly: IgnoresAccessChecksTo("assembly_utils")]
[assembly: IgnoresAccessChecksTo("assembly_valheim")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = "")]
[assembly: AssemblyCompany("Cheb Gonaz")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.2.2.0")]
[assembly: AssemblyInformationalVersion("1.2.2.0+f7d585abee2656db8006bbd76f408259bceb1e9a")]
[assembly: AssemblyProduct("Cheb's Demolisher Sword")]
[assembly: AssemblyTitle("Cheb's Demolisher Sword")]
[assembly: NeutralResourcesLanguage("en")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.2.2.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.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 ChebsDemolisherSword
{
	[BepInPlugin("com.chebgonaz.chebsdemolishersword", "ChebsDemolisherSword", "1.2.2")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[NetworkCompatibility(/*Could not decode attribute arguments.*/)]
	internal class ChebsDemolisherSword : BaseUnityPlugin
	{
		public const string PluginGuid = "com.chebgonaz.chebsdemolishersword";

		public const string PluginName = "ChebsDemolisherSword";

		public const string PluginVersion = "1.2.2";

		private Mesh _demolisherSwordMesh;

		private Material _demolisherSwordMaterial;

		private void Awake()
		{
			LoadAssetBundle();
			PrefabManager.OnVanillaPrefabsAvailable += DoOnVanillaPrefabsAvailable;
		}

		private void DoOnVanillaPrefabsAvailable()
		{
			PrefabManager.OnVanillaPrefabsAvailable -= DoOnVanillaPrefabsAvailable;
			GameObject prefab = PrefabManager.Instance.GetPrefab("SledgeDemolisher");
			if ((Object)(object)prefab == (Object)null)
			{
				((BaseUnityPlugin)this).Logger.LogError((object)"Failed to get demolisher hammer prefab");
				return;
			}
			MeshFilter componentInChildren = prefab.GetComponentInChildren<MeshFilter>(true);
			if ((Object)(object)componentInChildren == (Object)null)
			{
				((BaseUnityPlugin)this).Logger.LogError((object)"Failed to get demolisher hammer prefab's mesh filter");
				return;
			}
			componentInChildren.mesh = _demolisherSwordMesh;
			MeshRenderer componentInChildren2 = prefab.GetComponentInChildren<MeshRenderer>(true);
			if ((Object)(object)componentInChildren2 == (Object)null)
			{
				((BaseUnityPlugin)this).Logger.LogError((object)"Failed to get demolisher hammer prefab's mesh renderer");
			}
			else
			{
				((Renderer)componentInChildren2).sharedMaterial = _demolisherSwordMaterial;
			}
		}

		private void LoadAssetBundle()
		{
			AssetBundle val = AssetUtils.LoadAssetBundle(Path.Combine(Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location), "enclavesix"));
			try
			{
				_demolisherSwordMesh = val.LoadAsset<Mesh>("EnclaveSix_DemolisherSwordMesh");
				_demolisherSwordMaterial = val.LoadAsset<Material>("EnclaveSix_DemolisherSwordMaterial");
			}
			catch (Exception arg)
			{
				((BaseUnityPlugin)this).Logger.LogWarning((object)$"Exception caught while loading assets: {arg}");
			}
			finally
			{
				val.Unload(false);
			}
		}
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}