Decompiled source of WaveRoarFix v1.0.3

WaveRoarFix.dll

Decompiled 3 weeks ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using AK;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using Enemies;
using GameData;
using HarmonyLib;
using Il2CppInterop.Runtime.InteropTypes;
using Il2CppSystem;
using LevelGeneration;
using Microsoft.CodeAnalysis;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("WaveRoarFix")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("WaveRoarFix")]
[assembly: AssemblyTitle("WaveRoarFix")]
[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 WaveRoarFix
{
	[BepInPlugin("Amor.WaveRoarFix", "WaveRoarFix", "1.0.3")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	internal class EntryPoint : BasePlugin
	{
		public static ManualLogSource? LogSource { get; private set; }

		public override void Load()
		{
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			LogSource = ((BasePlugin)this).Log;
			if (!((BaseChainloader<BasePlugin>)(object)IL2CPPChainloader.Instance).Plugins.ContainsKey("GTFO.EECustomization"))
			{
				new Harmony("WaveRoarFix").PatchAll();
				((BasePlugin)this).Log.LogMessage((object)"WaveRoarFix is now loaded");
			}
			else
			{
				((BasePlugin)this).Log.LogWarning((object)"EEC is present and WaveRoarFix is incorporated into EEC. Aborting...\nConsider asking the Rundown Dev to enable WaveRoarFix in their EEC Global Config :3");
			}
		}
	}
}
namespace WaveRoarFix.Patches
{
	[HarmonyPatch]
	internal static class Inject_DoSetWaveRoar
	{
		[HarmonyPatch(typeof(LG_LevelInteractionManager), "DoSetWaveRoarSoundInformation")]
		[HarmonyPrefix]
		private static bool Pre_DoSetWaveRoarSound(pWaveRoarSettings settings)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Expected O, but got Unknown
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00da: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
			CellSoundPlayer val = new CellSoundPlayer();
			switch (settings.enemyType)
			{
			case 8:
				val.SetSwitch(ENEMY_TYPE.GROUP, SWITCH.POUNCER);
				break;
			case 9:
				val.SetSwitch(ENEMY_TYPE.GROUP, SWITCH.STRIKER_BERSERK);
				break;
			case 10:
				val.SetSwitch(ENEMY_TYPE.GROUP, SWITCH.SHOOTER_SPREAD);
				break;
			default:
				val.Recycle();
				return true;
			}
			switch (settings.roarSize)
			{
			case 1:
				val.SetSwitch(ROAR_SIZE.GROUP, SWITCH.SMALL);
				break;
			case 2:
				val.SetSwitch(ROAR_SIZE.GROUP, SWITCH.MEDIUM);
				break;
			case 3:
				val.SetSwitch(ROAR_SIZE.GROUP, SWITCH.BIG);
				break;
			default:
				val.Recycle();
				return true;
			}
			val.SetSwitch(ENVIROMENT.GROUP, settings.isOutside ? SWITCH.DESERT : SWITCH.COMPLEX);
			val.Post(EVENTS.PLAY_WAVE_DISTANT_ROAR, settings.position, 1u, EventCallback.op_Implicit((Action<Object, AkCallbackType, AkCallbackInfo>)SoundDoneCallback), (Object)(object)val);
			return false;
		}

		private static void SoundDoneCallback(Object in_cookie, AkCallbackType in_type, AkCallbackInfo callbackInfo)
		{
			CellSoundPlayer val = ((Il2CppObjectBase)in_cookie).Cast<CellSoundPlayer>();
			if (val != null)
			{
				val.Recycle();
			}
		}
	}
	[HarmonyPatch]
	internal static class Inject_EnemyGroup
	{
		private static readonly Dictionary<string, uint> _waveRoars = new Dictionary<string, uint>
		{
			{
				"Pouncer",
				SWITCH.POUNCER
			},
			{
				"Tank_Boss",
				SWITCH.IMMORTAL
			},
			{
				"MegaMother",
				SWITCH.BIRTHER
			},
			{
				"Striker_Berserk",
				SWITCH.STRIKER_BERSERK
			},
			{
				"Striker_Big_nightmare",
				SWITCH.STRIKER_BERSERK
			},
			{
				"Striker_Child_Nightmare",
				SWITCH.STRIKER_BERSERK
			},
			{
				"Shooter_Spread",
				SWITCH.SHOOTER_SPREAD
			},
			{
				"Scout_nightmare",
				SWITCH.SHOOTER_SPREAD
			}
		};

		[HarmonyPatch(typeof(EnemyGroup), "TryGetAKSwitchIDFromEnemyType")]
		[HarmonyPrefix]
		private static bool OverrideSwitchID(ref bool __result, EnemyAgent agent, out uint switchID)
		{
			if (_waveRoars.TryGetValue(((GameDataBlockBase<EnemyDataBlock>)(object)agent.EnemyData).name, out switchID))
			{
				__result = true;
				return switchID == 0;
			}
			switchID = 0u;
			return true;
		}

		[HarmonyPatch(typeof(EnemyGroup), "GetByteFromEnemyType")]
		[HarmonyPrefix]
		private static bool AppendAKEnemyTypes(ref byte __result, uint enemyType)
		{
			if (enemyType == SWITCH.POUNCER)
			{
				__result = 8;
				return false;
			}
			if (enemyType == SWITCH.STRIKER_BERSERK)
			{
				__result = 9;
				return false;
			}
			if (enemyType == SWITCH.SHOOTER_SPREAD)
			{
				__result = 10;
				return false;
			}
			return true;
		}
	}
}