using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Core.Logging.Interpolation;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using HarmonyLib;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using Microsoft.CodeAnalysis;
using ifapp.Game.Common;
using ifapp.Game.Data;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("ParticleCapacity")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("解除粒子库存9999颗的获得门槛,将容量扩展至65535颗。")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("ParticleCapacity")]
[assembly: AssemblyTitle("ParticleCapacity")]
[assembly: AssemblyVersion("1.0.0.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[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]
[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;
}
}
[CompilerGenerated]
[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 InFalsusMod
{
internal static class WindowsConsoleEncoding
{
private const uint Utf8CodePage = 65001u;
internal static void EnsureUtf8(ManualLogSource logger)
{
//IL_002d: Unknown result type (might be due to invalid IL or missing references)
//IL_0033: Expected O, but got Unknown
//IL_0072: Unknown result type (might be due to invalid IL or missing references)
//IL_0078: Expected O, but got Unknown
if (!OperatingSystem.IsWindows() || !ConsoleManager.ConsoleActive || GetConsoleOutputCP() == 65001)
{
return;
}
bool flag = default(bool);
if (!SetConsoleOutputCP(65001u))
{
BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(75, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Failed to set the BepInEx console output code page to UTF-8 (Win32 error ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(Marshal.GetLastWin32Error());
((BepInExLogInterpolatedStringHandler)val).AppendLiteral(").");
}
logger.LogError(val);
return;
}
uint consoleOutputCP = GetConsoleOutputCP();
if (consoleOutputCP != 65001)
{
BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(54, 2, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("BepInEx console output code page remained ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<uint>(consoleOutputCP);
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("; expected ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<uint>(65001u);
((BepInExLogInterpolatedStringHandler)val).AppendLiteral(".");
}
logger.LogError(val);
}
}
[DllImport("kernel32.dll")]
private static extern uint GetConsoleOutputCP();
[DllImport("kernel32.dll", SetLastError = true)]
[return: MarshalAs(UnmanagedType.Bool)]
private static extern bool SetConsoleOutputCP(uint codePage);
}
}
namespace InFalsusMod.ParticleCapacity
{
[BepInPlugin("menglei.infalsus.particlecapacity", "In Falsus Particle Capacity", "1.0.0")]
[BepInProcess("infalsus.exe")]
public sealed class Plugin : BasePlugin
{
internal const ushort Capacity = ushort.MaxValue;
private ushort originalCapacity;
private Harmony? harmony;
public override void Load()
{
//IL_001c: Unknown result type (might be due to invalid IL or missing references)
//IL_0026: Expected O, but got Unknown
//IL_0065: Unknown result type (might be due to invalid IL or missing references)
//IL_006b: Expected O, but got Unknown
WindowsConsoleEncoding.EnsureUtf8(((BasePlugin)this).Log);
originalCapacity = IotaInventory.MaxTotalIotaCount;
harmony = new Harmony("menglei.infalsus.particlecapacity");
try
{
harmony.PatchAll(typeof(Plugin).Assembly);
IotaInventory.MaxTotalIotaCount = ushort.MaxValue;
}
catch
{
harmony.UnpatchSelf();
throw;
}
ManualLogSource log = ((BasePlugin)this).Log;
bool flag = default(bool);
BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(28, 2, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("粒子容量已从 ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<ushort>(originalCapacity);
((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" 提高至 ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<ushort>(ushort.MaxValue);
((BepInExLogInterpolatedStringHandler)val).AppendLiteral(";超过9999颗后仍可获得粒子。");
}
log.LogInfo(val);
}
public override bool Unload()
{
Harmony? obj = harmony;
if (obj != null)
{
obj.UnpatchSelf();
}
harmony = null;
if (IotaInventory.MaxTotalIotaCount == ushort.MaxValue)
{
IotaInventory.MaxTotalIotaCount = originalCapacity;
}
return true;
}
}
[HarmonyPatch(typeof(IotaInventory), "Add")]
internal static class InventoryAddPatch
{
[HarmonyPrefix]
private static bool Prefix(IotaInventory __instance, ref IotaInstance __0)
{
//IL_001f: Unknown result type (might be due to invalid IL or missing references)
UnorderedListVal<IotaInstance> allIota = __instance.allIota;
if (allIota == null)
{
return true;
}
long num = 0L;
Il2CppArrayBase<IotaInstance> rawBuffer = allIota.RawBuffer;
for (int i = 0; i < allIota.Length; i++)
{
num += rawBuffer[i].Count;
}
long num2 = 65535 - num;
if (num2 <= 0)
{
return false;
}
__0.Count = (ushort)Math.Min(__0.Count, num2);
return __0.Count != 0;
}
}
}