using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using BepInEx;
using HarmonyLib;
using Splatform;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyVersion("0.0.0.0")]
namespace CyganFix;
[BepInPlugin("aaa_com.cygan.cyganfix", "CyganFix", "1.0.0")]
public class CyganFixPlugin : BaseUnityPlugin
{
private static Harmony harmony;
private static bool patched;
static CyganFixPlugin()
{
patched = false;
DoPatch();
}
private static void DoPatch()
{
//IL_001b: Unknown result type (might be due to invalid IL or missing references)
//IL_0025: Expected O, but got Unknown
if (patched)
{
return;
}
patched = true;
try
{
harmony = new Harmony("aaa_com.cygan.cyganfix");
harmony.PatchAll(typeof(Patches));
}
catch
{
}
}
private void Awake()
{
DoPatch();
((BaseUnityPlugin)this).Logger.LogInfo((object)"╔════════════════════════════════════════════════════════════════════════╗");
((BaseUnityPlugin)this).Logger.LogInfo((object)"║ Fix Cygana Nanananananana ║");
((BaseUnityPlugin)this).Logger.LogInfo((object)"║ LinkedIn: https://www.linkedin.com/in/pszym89/ ║");
((BaseUnityPlugin)this).Logger.LogInfo((object)"║ Buy Me A Coffee: https://buymeacoffee.com/cygan ║");
((BaseUnityPlugin)this).Logger.LogInfo((object)"╚════════════════════════════════════════════════════════════════════════╝");
}
}
public class MockPreferencesProvider : IPreferencesProvider, IDisposable
{
public bool IsInitialized => true;
public void InitializeAsync(byte[] data, InitializePreferencesCompletedHandler completedHandler)
{
if (completedHandler != null)
{
completedHandler.Invoke(true);
}
}
public void Dispose()
{
}
public bool TryGetString(string key, out string value)
{
value = "English";
return true;
}
public bool TryGetInt(string key, out int value)
{
value = 0;
return false;
}
public bool TryGetFloat(string key, out float value)
{
value = 0f;
return false;
}
public void SetString(string key, string value)
{
}
public void SetInt(string key, int value)
{
}
public void SetFloat(string key, float value)
{
}
public bool HasKey(string key)
{
return false;
}
public void DeleteKey(string key)
{
}
public void DeleteAll()
{
}
public string[] GetAllKeys()
{
return new string[0];
}
public bool Serialize(out byte[] data)
{
data = null;
return false;
}
}
[HarmonyPatch]
public static class Patches
{
[HarmonyPrefix]
[HarmonyPatch(typeof(PlatformPrefs), "TryGetPreferencesProvider")]
public static bool TryGetPreferencesProvider_Prefix(ref IPreferencesProvider preferencesProvider, ref bool __result)
{
if (preferencesProvider == null)
{
preferencesProvider = (IPreferencesProvider)(object)new MockPreferencesProvider();
__result = true;
return false;
}
return true;
}
[HarmonyPatch(/*Could not decode attribute arguments.*/)]
[HarmonyPrefix]
public static void Localization_get_instance_Prefix()
{
FieldInfo field = typeof(Localization).GetField("m_instance", BindingFlags.Static | BindingFlags.NonPublic);
if (!(field != null) || field.GetValue(null) != null)
{
return;
}
MethodInfo method = typeof(Localization).GetMethod("SetStartupLanguage", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
if (method == null)
{
method = typeof(Localization).GetMethod("Initialize", BindingFlags.Static | BindingFlags.NonPublic);
}
if (!(method != null))
{
return;
}
try
{
if (method.IsStatic)
{
method.Invoke(null, null);
return;
}
MethodInfo method2 = typeof(Localization).GetMethod("Initialize", BindingFlags.Static | BindingFlags.NonPublic);
if (method2 != null)
{
method2.Invoke(null, null);
}
}
catch
{
}
}
}