Decompiled source of ChebsDemolisherSword v1.2.0

plugins/ChebsDemolisherSword.dll

Decompiled 7 months ago
using System;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using Jotunn.Managers;
using Jotunn.Utils;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("ChebsDemolisherSword")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("ChebsDemolisherSword")]
[assembly: AssemblyCopyright("Copyright ©  2021")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("e3243d22-4307-4008-ba36-9f326008cde5")]
[assembly: AssemblyFileVersion("1.2.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.6.2", FrameworkDisplayName = ".NET Framework 4.6.2")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.2.0.0")]
[module: UnverifiableCode]
namespace ChebsDemolisherSword;

[BepInPlugin("com.chebgonaz.chebsdemolishersword", "ChebsDemolisherSword", "1.2.0")]
[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.0";

	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);
		}
	}
}