Decompiled source of WaveRoarFix v1.0.2

WaveRoarFix.dll

Decompiled 3 months ago
using System;
using System.Collections;
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 BepInEx.Unity.IL2CPP.Utils.Collections;
using Enemies;
using GameData;
using HarmonyLib;
using Il2CppSystem;
using LevelGeneration;
using Microsoft.CodeAnalysis;
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(".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.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	internal class EntryPoint : BasePlugin
	{
		public static ManualLogSource? LogSource { get; private set; }

		public override void Load()
		{
			//IL_0033: 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(typeof(LG_LevelInteractionManager), "DoSetWaveRoarSoundInformation")]
	internal static class Inject_DoSetWaveRoar
	{
		public static bool Prefix(pWaveRoarSettings settings)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Expected O, but got Unknown
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00de: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_0100: Unknown result type (might be due to invalid IL or missing references)
			CellSoundPlayer val = new CellSoundPlayer(Vector3.zero);
			val.UpdatePosition(settings.position);
			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:
				CoroutineManager.StartCoroutine(CollectionExtensions.WrapToIl2Cpp(Cleanup(val)), (Action)null);
				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;
			}
			val.SetSwitch(ENVIROMENT.GROUP, settings.isOutside ? SWITCH.DESERT : SWITCH.COMPLEX);
			val.Post(EVENTS.PLAY_WAVE_DISTANT_ROAR, true);
			CoroutineManager.StartCoroutine(CollectionExtensions.WrapToIl2Cpp(Cleanup(val)), (Action)null);
			return false;
		}

		private static IEnumerator Cleanup(CellSoundPlayer csPlayer)
		{
			yield return (object)new WaitForSeconds(10f);
			csPlayer.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]
		public 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]
		public 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;
		}
	}
}