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;
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: 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.metadataboost";
public const string PLUGIN_NAME = "MetadataBoost";
public const string PLUGIN_VERSION = "0.0.1";
}
namespace MetadataBoost
{
[BepInPlugin("com.yummi.dsp.metadataboost", "元神启动", "0.0.1")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class MetadataBoost : BaseUnityPlugin
{
public const string PLUGIN_GUID = "com.yummi.dsp.metadataboost";
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.metadataboost");
internal static ManualLogSource Log;
internal static ConfigEntry<bool> AutoOpenOnEnter;
private const float BoostButtonWidth = 200f;
private void Awake()
{
Log = ((BaseUnityPlugin)this).Logger;
AutoOpenOnEnter = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "AutoOpenOnEnter", true, "Open this page in the Cat panel after entering a game. | 进入游戏后自动打开猫猫面板的本页。");
UIPanel.RegisterPage("metadata_cheats", "元数据作弊", "Metadata Cheats").AddCheckbox(AutoOpenOnEnter, "进入游戏后自动打开本页", "Open this page after entering game").AddLabel("为 6 种矩阵各增加等量的生产和消耗,可用元数据不变。F9 打开/关闭本页。", "Add equal production and consumption for all 6 matrix types; available Metadata unchanged. F9 toggles this page.")
.AddButton("1万 矩阵", "10k matrices", (Action)delegate
{
MetadataBoostPage.Boost(10000);
}, 200f)
.AddButton("1亿 矩阵", "100M matrices", (Action)delegate
{
MetadataBoostPage.Boost(100000000);
}, 200f)
.AddButton("10亿 矩阵", "1B matrices", (Action)delegate
{
MetadataBoostPage.Boost(1000000000);
}, 200f);
harmony.PatchAll(typeof(MetadataBoostPage));
Log.LogInfo((object)"元神启动 v0.0.1 已加载");
}
private void OnDestroy()
{
harmony.UnpatchSelf();
}
}
[HarmonyPatch]
public static class MetadataBoostPage
{
private static readonly int[] MatrixIds = new int[6] { 6001, 6002, 6003, 6004, 6005, 6006 };
private static readonly string[] MatrixNames = new string[6] { "电磁", "能量", "结构", "信息", "引力", "宇宙" };
[HarmonyPostfix]
[HarmonyPatch(typeof(GameMain), "Begin")]
public static void OpenOnEnter()
{
if (!((Object)(object)GameMain.instance == (Object)null) && !GameMain.instance.isMenuDemo && MetadataBoost.AutoOpenOnEnter.Value)
{
UIPanel.OpenPage("metadata_cheats");
}
}
[HarmonyPostfix]
[HarmonyPatch(typeof(UIGame), "_OnUpdate")]
public static void ToggleKey()
{
if (Input.GetKeyDown((KeyCode)290) && !VFInput.inputing)
{
UIPanel.TogglePage("metadata_cheats");
}
}
public static void Boost(int amount)
{
if (GameMain.data == null || GameMain.data.gameDesc == null)
{
MetadataBoost.Log.LogWarning((object)"游戏未运行");
return;
}
PropertySystem propertySystem = DSPGame.propertySystem;
if (propertySystem == null)
{
MetadataBoost.Log.LogWarning((object)"PropertySystem 不存在");
return;
}
long seedKey = GameMain.data.gameDesc.seedKey64;
for (int i = 0; i < MatrixIds.Length; i++)
{
int num = MatrixIds[i];
int itemProduction = propertySystem.GetItemProduction(seedKey, num);
propertySystem.SetItemProduction(seedKey, num, itemProduction + amount);
GameMain.data.history.propertyData.AddItemProduction(num, amount);
int itemConsumption = propertySystem.GetItemConsumption(seedKey, num);
propertySystem.SetItemConsumption(seedKey, num, itemConsumption + amount);
GameMain.data.history.propertyData.AddItemConsumption(num, amount);
MetadataBoost.Log.LogInfo((object)$"已增加 {MatrixNames[i]}矩阵 {amount} 点生产和消耗");
}
string text = ((amount >= 100000000) ? (amount / 100000000 + "亿") : ((amount >= 10000) ? (amount / 10000 + "万") : amount.ToString()));
UIRealtimeTip.Popup("已增加 6 种矩阵各 " + text + " 点生产和消耗", true, 0);
}
}
}