Decompiled source of More Voices v1.0.2

More Voices.dll

Decompiled 6 days ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using HarmonyLib;
using MelonLoader;
using Microsoft.CodeAnalysis;
using Mimic.Voice.SpeechSystem;
using More_Voices;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: MelonInfo(typeof(MyFirstMod), "More Voices", "1.0.1", "Risikus", null)]
[assembly: MelonGame(null, null)]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("More Voices")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("More Voices")]
[assembly: AssemblyTitle("More Voices")]
[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 More_Voices
{
	public class MyFirstMod : MelonMod
	{
		[HarmonyPatch(typeof(SpeechEventArchive), "OnStartClient")]
		private static class OnStartClientPatch
		{
			private static bool Prefix(SpeechEventArchive __instance)
			{
				try
				{
					MelonLogger.Msg("=== OnStartClient Prefix START ===");
					if ((Object)(object)__instance == (Object)null)
					{
						MelonLogger.Warning("Instance is null!");
						return true;
					}
					MelonLogger.Msg("Instance OK, using FieldRef...");
					FieldRef<SpeechEventArchive, int> val = AccessTools.FieldRefAccess<SpeechEventArchive, int>("maxEvents");
					FieldRef<SpeechEventArchive, int> val2 = AccessTools.FieldRefAccess<SpeechEventArchive, int>("maxDeathMatchEvents");
					FieldRef<SpeechEventArchive, int> val3 = AccessTools.FieldRefAccess<SpeechEventArchive, int>("maxOutDoorEvents");
					MelonLogger.Msg("FieldRefs created successfully.");
					int num = val.Invoke(__instance);
					int num2 = val2.Invoke(__instance);
					int num3 = val3.Invoke(__instance);
					MelonLogger.Msg("Old field values: maxEvents=" + num + ", DM=" + num2 + ", Outdoor=" + num3);
					val.Invoke(__instance) = 3000;
					val2.Invoke(__instance) = 3000;
					val3.Invoke(__instance) = 3000;
					int num4 = val.Invoke(__instance);
					int num5 = val2.Invoke(__instance);
					int num6 = val3.Invoke(__instance);
					MelonLogger.Msg("New field values: maxEvents=" + num4 + ", DM=" + num5 + ", Outdoor=" + num6);
					if (num4 == 3000 && num5 == 3000 && num6 == 3000)
					{
						MelonLogger.Msg("=== SUCCESS! All limits increased! ===");
					}
					else
					{
						MelonLogger.Warning("Setting values failed!");
					}
				}
				catch (Exception ex)
				{
					MelonLogger.Error("=== EXCEPTION ===");
					MelonLogger.Error("Type: " + ex.GetType().FullName);
					MelonLogger.Error("Message: " + ex.Message);
					MelonLogger.Error("StackTrace: " + ex.StackTrace);
					if (ex.InnerException != null)
					{
						MelonLogger.Error("InnerException: " + ex.InnerException.Message);
					}
				}
				return true;
			}
		}

		private const int NEW_MAX_EVENTS = 3000;

		private const int NEW_MAX_DEATHMATCH = 3000;

		private const int NEW_MAX_OUTDOOR = 3000;

		public override void OnInitializeMelon()
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Expected O, but got Unknown
			((MelonBase)this).LoggerInstance.Msg("More Voices loaded. Patched SpeechEventArchive...");
			try
			{
				Harmony val = new Harmony("com.risikus.morevoices");
				val.PatchAll();
				((MelonBase)this).LoggerInstance.Msg("Patches successfully applied!");
			}
			catch (Exception ex)
			{
				((MelonBase)this).LoggerInstance.Error("Error applying patches: " + ex.Message);
			}
		}
	}
}