using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using HarmonyLib;
using MelonLoader;
using Microsoft.CodeAnalysis;
using TrueMimicVoice;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: MelonInfo(typeof(TrueMimicVoiceMod), "TrueMimicVoice", "1.0.0", "CoiriNight", null)]
[assembly: MelonGame("ReLUGames", "MIMESIS")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyCompany("TrueMimicVoice")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("TrueMimicVoice")]
[assembly: AssemblyTitle("TrueMimicVoice")]
[assembly: AssemblyVersion("1.0.0.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
internal sealed class RefSafetyRulesAttribute : Attribute
{
public readonly int Version;
public RefSafetyRulesAttribute(int P_0)
{
Version = P_0;
}
}
}
namespace TrueMimicVoice
{
public class TrueMimicVoiceMod : MelonMod
{
private const string HarmonyId = "com.mimicvoicefix.fixed";
public override void OnInitializeMelon()
{
//IL_0064: Unknown result type (might be due to invalid IL or missing references)
//IL_006a: Expected O, but got Unknown
//IL_0085: Unknown result type (might be due to invalid IL or missing references)
//IL_0092: Expected O, but got Unknown
MelonLogger.Msg("TrueMimicVoice loaded.");
try
{
Type type = Type.GetType("Mimic.Actors.ProtoActor+VoiceEffecter, Assembly-CSharp");
if (type == null)
{
MelonLogger.Error("ProtoActor+VoiceEffecter not found.");
return;
}
MethodInfo method = type.GetMethod("ApplyEffectPreset", BindingFlags.Instance | BindingFlags.NonPublic);
if (method == null)
{
MelonLogger.Error("ApplyEffectPreset not found.");
return;
}
Harmony val = new Harmony("com.mimicvoicefix.fixed");
MethodInfo method2 = typeof(TrueMimicVoiceMod).GetMethod("ApplyEffectPresetPostfix", BindingFlags.Static | BindingFlags.NonPublic);
val.Patch((MethodBase)method, (HarmonyMethod)null, new HarmonyMethod(method2), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
MelonLogger.Msg("ApplyEffectPreset patched.");
}
catch (Exception ex)
{
MelonLogger.Error("Init error: " + ex);
}
}
private static void ApplyEffectPresetPostfix(object inType, object inEffectData)
{
try
{
if (inType != null && inEffectData != null && !(inType.ToString() == "Transmitter"))
{
object memberValue = GetMemberValue(inEffectData, "Preset");
if (memberValue != null)
{
DisableFiltersOnObject(memberValue);
}
}
}
catch (Exception ex)
{
MelonLogger.Error("Patch error: " + ex);
}
}
private static object GetMemberValue(object target, string name)
{
Type type = target.GetType();
PropertyInfo property = type.GetProperty(name, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
if (property != null)
{
return property.GetValue(target, null);
}
FieldInfo field = type.GetField(name, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
if (field != null)
{
return field.GetValue(target);
}
return null;
}
private static void DisableFiltersOnObject(object target)
{
if (target != null)
{
Type type = target.GetType();
DisableFilter(target, type, "LowPass");
DisableFilter(target, type, "HighPass");
DisableFilter(target, type, "Distortion");
DisableFilter(target, type, "Chorus");
DisableFilter(target, type, "Reverb");
DisableFilter(target, type, "Echo");
DisableFilter(target, type, "Amplifier");
}
}
private static void DisableFilter(object filterRef, Type filterType, string propertyName)
{
try
{
PropertyInfo property = filterType.GetProperty(propertyName);
if (property == null)
{
return;
}
object value = property.GetValue(filterRef, null);
if (value != null)
{
PropertyInfo property2 = value.GetType().GetProperty("enabled");
if (property2 != null)
{
property2.SetValue(value, false, null);
}
}
}
catch
{
}
}
}
}