Decompiled source of Vagrant Hates Normies v1.4.0

VagrantHatesNormies.dll

Decompiled 2 days ago
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using EntityStates.VagrantMonster;
using On.RoR2;
using R2API;
using R2API.Utils;
using RiskOfOptions;
using RiskOfOptions.Options;
using UnityEngine;

[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("VagrantHatesNormies")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("VagrantHatesNormies")]
[assembly: AssemblyTitle("VagrantHatesNormies")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace VagrantHatesNormies;

[NetworkCompatibility(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInPlugin("com.Arbition.VagrantHatesNormies", "VagrantHatesNormies", "1.4.0")]
public class VagrantHatesNormies : BaseUnityPlugin
{
	public static AssetBundle VHNBundle;

	public static ConfigEntry<float> VHNVolume { get; set; }

	public void Awake()
	{
		//IL_0081: Unknown result type (might be due to invalid IL or missing references)
		//IL_008b: Expected O, but got Unknown
		//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00af: Expected O, but got Unknown
		Logger logger = new Logger("VagrantHatesNormies");
		Assets.LoadSoundBank("VagrantHatesNormies.REEE.bnk");
		Assets.LoadBundle("VagrantHatesNormies.vagranthatesnormies");
		Sprite val = Assets.LoadSprite("VHN");
		if ((Object)(object)val != (Object)null)
		{
			logger.Log("Icon loaded successfully");
		}
		else
		{
			logger.LogError("Failed to load icon");
		}
		VHNVolume = ((BaseUnityPlugin)this).Config.Bind<float>("Audio", "Volume", 100f, "How loud it should be (between 0-100). Keep in mind that the audio for this mod is already affected by the music volume setting (and master volume as well by extension), so this is just if you want to adjust it further from there.");
		ModSettingsManager.AddOption((BaseOption)new SliderOption(VHNVolume));
		ModSettingsManager.SetModDescription("Soundmod that replaces the vagrant charge attack sound effect with the reee screech. Now with adjustable volume!");
		ModSettingsManager.SetModIcon(val);
		Util.PlayAttackSpeedSound += new hook_PlayAttackSpeedSound(Util_PlayAttackSpeedSound);
		logger.Log("Mod loaded successfully");
	}

	private uint Util_PlayAttackSpeedSound(orig_PlayAttackSpeedSound orig, string soundString, GameObject gameObject, float playbackRate)
	{
		//IL_0021: Unknown result type (might be due to invalid IL or missing references)
		if (soundString == ChargeMegaNova.chargingSoundString)
		{
			AkSoundEngine.SetRTPCValue("VHN_Volume", VHNVolume.Value, gameObject);
			return AkSoundEngine.PostEvent(2769586434u, gameObject);
		}
		return orig.Invoke(soundString, gameObject, playbackRate);
	}
}
public static class Assets
{
	public static AssetBundle Bundle;

	public static bool LoadBundle(string bndl)
	{
		using Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(bndl);
		if (stream == null)
		{
			Logger.LogErrorStatic("Embedded AssetBundle not found!");
			return false;
		}
		byte[] array = new byte[stream.Length];
		stream.Read(array, 0, array.Length);
		Bundle = AssetBundle.LoadFromMemory(array);
		if ((Object)(object)Bundle != (Object)null)
		{
			Logger.LogStatic("AssetBundle loaded from embedded resource!");
			return true;
		}
		Logger.LogErrorStatic("Failed to load AssetBundle from memory!");
		return false;
	}

	public static bool LoadSoundBank(string bnk)
	{
		using Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(bnk);
		if (stream != null)
		{
			byte[] array = new byte[stream.Length];
			stream.Read(array, 0, array.Length);
			SoundBanks.Add(array);
			Logger.LogStatic("Soundbank loaded successfully");
			return true;
		}
		Logger.LogErrorStatic("Soundbank failed to load");
		return false;
	}

	public static Sprite LoadSprite(string name)
	{
		if ((Object)(object)Bundle == (Object)null)
		{
			return null;
		}
		return Bundle.LoadAsset<Sprite>("Assets/Icons/" + name + ".png");
	}
}
public class Logger
{
	private readonly string modID;

	public static Logger Default;

	public Logger(string modID, bool setAsDefault = true)
	{
		this.modID = modID;
		if (setAsDefault)
		{
			Default = this;
		}
	}

	public void Log(string message)
	{
		Debug.Log((object)("[" + modID + "] " + message));
	}

	public void LogError(string message)
	{
		Debug.LogError((object)("[" + modID + "] " + message));
	}

	public static void LogStatic(string message)
	{
		Default?.Log(message);
	}

	public static void LogErrorStatic(string message)
	{
		Default?.LogError(message);
	}
}