using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UXAssist.Common;
using UXAssist.UI;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyCompany("FastTinderLaunch")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("Restore old 100% dark fog tinder launch probability, toggleable via UXAssist / 恢复旧版100%黑雾火种发射概率,可在UXAssist设置面板中开关")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+26c0c74510e96117797757ddd3935ba2ac38ecfe")]
[assembly: AssemblyProduct("FastTinderLaunch")]
[assembly: AssemblyTitle("FastTinderLaunch")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[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 FastTinderLaunch
{
[BepInPlugin("org.fyyy.fasttinderlaunch", "FastTinderLaunch", "1.0.0")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class FastTinderLaunchPlugin : BaseUnityPlugin
{
private static class TinderPatches
{
[HarmonyTranspiler]
[HarmonyPatch(typeof(DFTinderComponent), "PrepareDispatchLogic")]
private static IEnumerable<CodeInstruction> PrepareDispatchLogic_Transpiler(IEnumerable<CodeInstruction> instructions)
{
List<CodeInstruction> list = new List<CodeInstruction>(instructions);
int num = 0;
for (int i = 0; i < list.Count; i++)
{
if (list[i].opcode == OpCodes.Ldc_I4 && list[i].operand is int num2 && num2 == 1800)
{
list[i].operand = 1;
num++;
}
else if (IsDouble(list[i], 0.0625))
{
list[i].operand = 1E+300;
num++;
}
}
if (num != 3)
{
Logger.LogWarning((object)$"PrepareDispatchLogic: {num} patches (expected 3)!");
}
else
{
Logger.LogInfo((object)$"PrepareDispatchLogic: {num} patches (expected 3).");
}
return list;
}
[HarmonyTranspiler]
[HarmonyPatch(typeof(DFSCoreComponent), "LogicTick")]
private static IEnumerable<CodeInstruction> LogicTick_Transpiler(IEnumerable<CodeInstruction> instructions)
{
List<CodeInstruction> list = new List<CodeInstruction>(instructions);
int num = 0;
int num2 = 0;
for (int i = 0; i < list.Count; i++)
{
if (IsDouble(list[i], 0.75))
{
num2++;
if (num2 == 2)
{
list[i].operand = 1E+300;
num++;
}
}
else if (list[i].opcode == OpCodes.Ldc_I4_S && list[i].operand is sbyte b && b == sbyte.MaxValue)
{
list[i].operand = (sbyte)0;
num++;
}
else if (IsDouble(list[i], 0.97))
{
list[i].operand = 1.0;
num++;
}
}
if (num != 3)
{
Logger.LogWarning((object)$"LogicTick: {num} patches (expected 3), 0.75 count: {num2}!");
}
else
{
Logger.LogInfo((object)$"LogicTick: {num} patches (expected 3).");
}
return list;
}
[HarmonyTranspiler]
[HarmonyPatch(typeof(DFSCoreComponent), "LogicTickVirtual")]
private static IEnumerable<CodeInstruction> LogicTickVirtual_Transpiler(IEnumerable<CodeInstruction> instructions)
{
List<CodeInstruction> list = new List<CodeInstruction>(instructions);
int num = 0;
int num2 = 0;
for (int i = 0; i < list.Count; i++)
{
if (IsDouble(list[i], 0.75))
{
num2++;
list[i].operand = 1E+300;
num++;
}
else if (list[i].opcode == OpCodes.Ldc_I4_S && list[i].operand is sbyte b && b == sbyte.MaxValue)
{
list[i].operand = (sbyte)0;
num++;
}
else if (IsDouble(list[i], 0.97))
{
list[i].operand = 1.0;
num++;
}
}
if (num != 3)
{
Logger.LogWarning((object)$"LogicTickVirtual: {num} patches (expected 3), 0.75 count: {num2}!");
}
else
{
Logger.LogInfo((object)$"LogicTickVirtual: {num} patches (expected 3).");
}
return list;
}
[HarmonyPrefix]
[HarmonyPatch(typeof(DFSCoreComponent), "GetTargetTinderYieldRatio")]
private static bool GetTargetTinderYieldRatio_Prefix(ref double __result)
{
__result = 1.0;
return false;
}
private static bool IsDouble(CodeInstruction code, double value)
{
if (code.opcode == OpCodes.Ldc_R8 && code.operand is double num)
{
return Math.Abs(num - value) < 1E-10;
}
return false;
}
}
private static class UIConfig
{
public static void Init()
{
I18N.Add("FastTinderLaunch", "FastTinderLaunch", "黑雾火种快速发射");
I18N.Add("Restore old 100% tinder launch behavior", "Restore old 100% tinder launch behavior", "将黑雾火种的发射概率恢复为旧版100%(充满即发)");
I18N.Apply();
MyConfigWindow.OnUICreated = (Action<MyConfigWindow, RectTransform>)Delegate.Combine(MyConfigWindow.OnUICreated, new Action<MyConfigWindow, RectTransform>(CreateUI));
}
private static void CreateUI(MyConfigWindow wnd, RectTransform trans)
{
((MyWindowWithTabs)wnd).AddSplitter(trans, 10f);
((MyWindowWithTabs)wnd).AddTabGroup(trans, "FastTinderLaunch", "tab-group-fasttinderlaunch");
RectTransform val = ((MyWindowWithTabs)wnd).AddTab(trans, "FastTinderLaunch");
((MyWindow)wnd).AddCheckBox(0f, 10f, val, ModEnabled, "Restore old 100% tinder launch behavior", 15);
}
}
public static readonly ManualLogSource Logger = Logger.CreateLogSource("FastTinderLaunch");
public static ConfigEntry<bool> ModEnabled;
private Harmony _harmony;
private void Awake()
{
//IL_003c: Unknown result type (might be due to invalid IL or missing references)
//IL_0046: Expected O, but got Unknown
ModEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Enabled", true, "Restore old 100% tinder launch probability / 恢复旧版100%火种发射概率");
ModEnabled.SettingChanged += OnEnabledChanged;
_harmony = new Harmony("org.fyyy.fasttinderlaunch");
ApplyPatches();
UIConfig.Init();
Logger.LogInfo((object)"FastTinderLaunch loaded.");
}
private void OnDestroy()
{
ModEnabled.SettingChanged -= OnEnabledChanged;
Harmony harmony = _harmony;
if (harmony != null)
{
harmony.UnpatchSelf();
}
}
private void ApplyPatches()
{
if (ModEnabled.Value)
{
_harmony.PatchAll(typeof(TinderPatches));
}
}
private void OnEnabledChanged(object sender, EventArgs e)
{
_harmony.UnpatchSelf();
ApplyPatches();
IEnumerable<MethodBase> patchedMethods = _harmony.GetPatchedMethods();
Logger.LogInfo((object)string.Format("FastTinderLaunch {0}, {1} patched methods.", ModEnabled.Value ? "enabled" : "disabled", patchedMethods.Count()));
}
}
public static class PluginInfo
{
public const string PLUGIN_GUID = "org.fyyy.fasttinderlaunch";
public const string PLUGIN_NAME = "FastTinderLaunch";
public const string PLUGIN_VERSION = "1.0.0";
}
}