Decompiled source of EnclaveSixPrivateMod v1.1.0

plugins/EnclaveSixPrivateMod.dll

Decompiled a year 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("EnclaveSixPrivateMod")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("EnclaveSixPrivateMod")]
[assembly: AssemblyCopyright("Copyright ©  2021")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("e3243d22-4307-4008-ba36-9f326008cde5")]
[assembly: AssemblyFileVersion("1.1.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.1.0.0")]
[module: UnverifiableCode]
namespace EnclaveSixPrivateMod;

[BepInPlugin("com.chebgonaz.enclavesixprivatemod", "EnclaveSixPrivateMod", "1.1.0")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[NetworkCompatibility(/*Could not decode attribute arguments.*/)]
internal class EnclaveSixPrivateMod : BaseUnityPlugin
{
	public const string PluginGuid = "com.chebgonaz.enclavesixprivatemod";

	public const string PluginName = "EnclaveSixPrivateMod";

	public const string PluginVersion = "1.1.0";

	private Mesh _bannerMesh;

	private Material _bannerMaterial;

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

	private void DoOnVanillaPrefabsAvailable()
	{
		PrefabManager.OnVanillaPrefabsAvailable -= DoOnVanillaPrefabsAvailable;
		GameObject prefab = PrefabManager.Instance.GetPrefab("piece_banner01");
		if ((Object)(object)prefab == (Object)null)
		{
			((BaseUnityPlugin)this).Logger.LogError((object)"Failed to get piece_banner01 prefab");
			return;
		}
		Transform val = prefab.transform.Find("default");
		if ((Object)(object)val == (Object)null)
		{
			((BaseUnityPlugin)this).Logger.LogError((object)"child is null; banner swap failed");
			return;
		}
		MeshFilter componentInChildren = ((Component)val).GetComponentInChildren<MeshFilter>(true);
		if ((Object)(object)componentInChildren == (Object)null)
		{
			((BaseUnityPlugin)this).Logger.LogError((object)"Failed to get banner prefab's mesh filter");
			return;
		}
		componentInChildren.mesh = _bannerMesh;
		MeshRenderer componentInChildren2 = ((Component)val).GetComponentInChildren<MeshRenderer>(true);
		if ((Object)(object)componentInChildren2 == (Object)null)
		{
			((BaseUnityPlugin)this).Logger.LogError((object)"Failed to get banner prefab's mesh renderer");
		}
		else
		{
			((Renderer)componentInChildren2).sharedMaterial = _bannerMaterial;
		}
	}

	private void LoadAssetBundle()
	{
		AssetBundle val = AssetUtils.LoadAssetBundle(Path.Combine(Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location), "enclavesixprivatemod"));
		try
		{
			_bannerMesh = val.LoadAsset<Mesh>("default");
			_bannerMaterial = val.LoadAsset<Material>("Dragon");
		}
		catch (Exception arg)
		{
			((BaseUnityPlugin)this).Logger.LogWarning((object)$"Exception caught while loading assets: {arg}");
		}
		finally
		{
			val.Unload(false);
		}
	}
}