Decompiled source of VoidCritVineBoom v1.0.0

VoidCritVineBoom.dll

Decompiled 2 weeks ago
using System;
using System.Collections;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using Microsoft.CodeAnalysis;
using On.RoR2;
using R2API;
using R2API.Networking;
using R2API.Networking.Interfaces;
using RoR2;
using RoR2.Audio;
using UnityEngine;
using UnityEngine.Networking;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("VoidCritVineBoom")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("VoidCritVineBoom")]
[assembly: AssemblyTitle("VoidCritVineBoom")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
}
namespace SylmarDev.VoidCritVineBoom
{
	internal static class Log
	{
		internal static ManualLogSource _logSource;

		internal static void Init(ManualLogSource logSource)
		{
			_logSource = logSource;
		}

		internal static void Debug(object data)
		{
			_logSource.LogDebug(data);
		}

		internal static void Error(object data)
		{
			_logSource.LogError(data);
		}

		internal static void Fatal(object data)
		{
			_logSource.LogFatal(data);
		}

		internal static void Info(object data)
		{
			_logSource.LogInfo(data);
		}

		internal static void Message(object data)
		{
			_logSource.LogMessage(data);
		}

		internal static void Warning(object data)
		{
			_logSource.LogWarning(data);
		}
	}
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInPlugin("SylmarDev.VoidCritVineBoom", "VoidCritVineBoom", "1.0.0")]
	public class Main : BaseUnityPlugin
	{
		public const string PluginAuthor = "SylmarDev";

		public const string PluginName = "VoidCritVineBoom";

		public const string PluginGUID = "SylmarDev.VoidCritVineBoom";

		public const string PluginVersion = "1.0.0";

		public bool shouldMuteOriginalSFX;

		public void Awake()
		{
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Expected O, but got Unknown
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Expected O, but got Unknown
			Log.Init(((BaseUnityPlugin)this).Logger);
			Log.Info("SylmarDev.VoidCritVineBoom // ver 1.0.0");
			Log.Info("Starting Process. . .");
			new VoidCritVineBoomConfig().Init(Paths.ConfigPath);
			shouldMuteOriginalSFX = VoidCritVineBoomConfig.muteOriginalVoidExecute.Value;
			NetworkingAPI.RegisterMessageType<SyncSound>();
			using (Stream stream = ((object)this).GetType().Assembly.GetManifestResourceStream("VoidCritVineBoom.Resources.vineboom.bnk"))
			{
				byte[] array = new byte[stream.Length];
				stream.Read(array, 0, array.Length);
				SoundBanks.Add(array);
			}
			EffectManager.SpawnEffect_GameObject_EffectData_bool += new hook_SpawnEffect_GameObject_EffectData_bool(EffectManager_SpawnEffect_GameObject_EffectData_bool);
			if (shouldMuteOriginalSFX)
			{
				EffectCatalog.GetEffectDef += new hook_GetEffectDef(EffectCatalog_GetEffectDef);
			}
			Log.Info("awake complete");
		}

		private IEnumerator DelayPostSound(float delayTime, Vector3 pos)
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			yield return (object)new WaitForSeconds(delayTime);
			GameObject val = new GameObject();
			val.transform.position = pos;
			GameObject val2 = val;
			AkSoundEngine.PostEvent("Play_vineboom", val2);
			NetMessageExtensions.Send((INetMessage)(object)new SyncSound(pos), (NetworkDestination)1);
		}

		private void EffectManager_SpawnEffect_GameObject_EffectData_bool(orig_SpawnEffect_GameObject_EffectData_bool orig, GameObject effectPrefab, EffectData effectData, bool transmit)
		{
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			if (((Object)effectPrefab).name.Trim() == "CritGlassesVoidExecuteEffect")
			{
				if (shouldMuteOriginalSFX)
				{
					effectData.networkSoundEventIndex = (NetworkSoundEventIndex)(-1);
				}
				((MonoBehaviour)this).StartCoroutine(DelayPostSound(0f, effectData.origin));
			}
			orig.Invoke(effectPrefab, effectData, transmit);
		}

		private EffectDef EffectCatalog_GetEffectDef(orig_GetEffectDef orig, EffectIndex effectIndex)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Invalid comparison between Unknown and I4
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Expected O, but got Unknown
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			if ((int)effectIndex != 136)
			{
				return orig.Invoke(effectIndex);
			}
			GameObject obj = PrefabAPI.InstantiateClone(orig.Invoke(effectIndex).prefab, "mutedvoidexecute", false);
			obj.GetComponent<EffectComponent>().soundName = "";
			return new EffectDef(obj);
		}

		public void Update()
		{
		}
	}
	public class SyncSound : INetMessage, ISerializableObject
	{
		private Vector3 soundPosition;

		public SyncSound()
		{
		}

		public SyncSound(Vector3 soundPosition)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			this.soundPosition = soundPosition;
		}

		public void Deserialize(NetworkReader reader)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			soundPosition = reader.ReadVector3();
		}

		public void OnReceived()
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Expected O, but got Unknown
			if (!NetworkServer.active)
			{
				GameObject val = new GameObject();
				val.transform.position = soundPosition;
				AkSoundEngine.PostEvent("Play_vineboom", val);
			}
		}

		public void Serialize(NetworkWriter writer)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			writer.Write(soundPosition);
		}
	}
	public class VoidCritVineBoomConfig
	{
		public static ConfigEntry<bool> muteOriginalVoidExecute;

		public void Init(string configPath)
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			muteOriginalVoidExecute = new ConfigFile(Path.Combine(configPath, "SylmarDev.VoidCritVineBoom.cfg"), true).Bind<bool>("Tweaks", "Mute Original Void Crit SFX", true, "Set to true to mute the vanilla Void Crit proc SFX");
		}
	}
}