using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using CatUIPanel;
using HarmonyLib;
using Microsoft.CodeAnalysis;
[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: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[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;
}
}
}
internal static class PluginInfo
{
public const string PLUGIN_GUID = "com.yummi.dsp.metadatanocost";
public const string PLUGIN_NAME = "MetadataNoCost";
public const string PLUGIN_VERSION = "0.0.1";
}
namespace MetadataNoCost
{
[HarmonyPatch(typeof(PropertySystem))]
public static class MetadataConsumptionPatch
{
[HarmonyPostfix]
[HarmonyPatch("GameTick")]
public static void ClearConsumption(PropertySystem __instance, long tick)
{
//IL_0053: Unknown result type (might be due to invalid IL or missing references)
//IL_0067: Unknown result type (might be due to invalid IL or missing references)
//IL_006c: Unknown result type (might be due to invalid IL or missing references)
//IL_007c: Unknown result type (might be due to invalid IL or missing references)
if (tick % 60 != 0L || !MetadataNoCost.Enabled.Value || GameMain.data == null || GameMain.data.gameDesc == null)
{
return;
}
long seedKey = GameMain.data.gameDesc.seedKey64;
ClusterPropertyData clusterData = __instance.GetClusterData(seedKey);
if (clusterData.totalConsumption == null)
{
return;
}
for (int i = 0; i < clusterData.totalConsumption.Count; i++)
{
if (clusterData.totalConsumption[i].count > 0)
{
IDCNT value = clusterData.totalConsumption[i];
value.count = 0;
clusterData.totalConsumption[i] = value;
}
}
}
}
[BepInPlugin("com.yummi.dsp.metadatanocost", "元数据老赖", "0.0.1")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class MetadataNoCost : BaseUnityPlugin
{
public const string PLUGIN_GUID = "com.yummi.dsp.metadatanocost";
public const string PLUGIN_NAME = "元数据老赖";
public const string PLUGIN_VERSION = "0.0.1";
public const string PageKey = "metadata_cheats";
public const string PageTitleZh = "元数据作弊";
public const string PageTitleEn = "Metadata Cheats";
private static readonly Harmony harmony = new Harmony("com.yummi.dsp.metadatanocost");
internal static ManualLogSource Log;
internal static ConfigEntry<bool> Enabled;
private void Awake()
{
Log = ((BaseUnityPlugin)this).Logger;
Enabled = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Enabled", true, "Keep clearing cross-save Metadata consumption for the current cluster. | 持续清除当前星区的跨存档元数据消耗记录。");
UIPanel.RegisterPage("metadata_cheats", "元数据作弊", "Metadata Cheats").AddCheckbox(Enabled, "启用:不扣除元数据", "Enable: no Metadata deduction").AddLabel("每秒清除当前星区的跨存档消耗记录(Property 文件夹),存档内统计不变。", "Every second, clears cross-save consumption records (Property folder); in-save stats unchanged.");
harmony.PatchAll(typeof(MetadataConsumptionPatch));
Log.LogInfo((object)"元数据老赖 v0.0.1 已加载");
}
private void OnDestroy()
{
harmony.UnpatchSelf();
}
}
}