using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using ABN;
using BepInEx;
using BepInEx.Configuration;
using HarmonyLib;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("DSPConsole")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("DSPConsole")]
[assembly: AssemblyCopyright("Copyright © 2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("e7360930-48ec-4d0b-be6b-b271a453d2bf")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7", FrameworkDisplayName = ".NET Framework 4.7")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace DSPConsole;
[BepInPlugin("com.wisper.dsp.console", "DSP Console extention", "1.0.9")]
public class DSPConsole : BaseUnityPlugin
{
private static ConfigEntry<bool> config_easy_start;
private static ConfigEntry<int> config_rsp_ratio;
private static ConfigEntry<int> config_pile_ratio;
private static ConfigEntry<int> config_prop_ratio_b;
private static ConfigEntry<int> config_prop_ratio_r;
private static ConfigEntry<int> config_prop_ratio_y;
private static ConfigEntry<int> config_prop_ratio_p;
private static ConfigEntry<int> config_prop_ratio_g;
private static ConfigEntry<int> config_prop_ratio_w;
private static bool pile_set_done;
[Obsolete]
private void Start()
{
config_easy_start = ((BaseUnityPlugin)this).Config.Bind<bool>("config", "EasyStart", false, "轻松模式");
config_rsp_ratio = ((BaseUnityPlugin)this).Config.Bind<int>("config", "ResearchSpeedRatio", 10, "研究速度的倍率");
config_pile_ratio = ((BaseUnityPlugin)this).Config.Bind<int>("config", "StoragePileRatio", 10, "物品堆叠倍率");
config_prop_ratio_b = ((BaseUnityPlugin)this).Config.Bind<int>("config", "PropertyRatioElectro", 10, "电磁矩阵元数据统计倍率");
config_prop_ratio_r = ((BaseUnityPlugin)this).Config.Bind<int>("config", "PropertyRatioEnergy", 10, "能量矩阵元数据统计倍率");
config_prop_ratio_y = ((BaseUnityPlugin)this).Config.Bind<int>("config", "PropertyRatioStructure", 10, "结构矩阵元数据统计倍率");
config_prop_ratio_p = ((BaseUnityPlugin)this).Config.Bind<int>("config", "PropertyRatioInformation", 10, "信息矩阵元数据统计倍率");
config_prop_ratio_g = ((BaseUnityPlugin)this).Config.Bind<int>("config", "PropertyRatioGravity", 10, "引力矩阵元数据统计倍率");
config_prop_ratio_w = ((BaseUnityPlugin)this).Config.Bind<int>("config", "PropertyRatioUniverse", 10, "宇宙矩阵元数据统计倍率");
Harmony.CreateAndPatchAll(typeof(DSPConsole), (string)null);
}
private void Update()
{
}
[HarmonyPrefix]
[HarmonyPatch(/*Could not decode attribute arguments.*/)]
public static bool MyActive(ref bool __result)
{
__result = true;
return false;
}
[HarmonyPrefix]
[HarmonyPatch(typeof(GameAbnormalityData_0925), "TriggerAbnormality")]
public static bool MyTriggerAbnormality()
{
return false;
}
[HarmonyPrefix]
[HarmonyPatch(typeof(GameHistoryData), "UnlockTechFunction")]
public static void MyUnlockTechFunction(GameHistoryData __instance, int func, ref double value)
{
if (func == 22)
{
value *= config_rsp_ratio.Value;
}
}
[HarmonyPostfix]
[HarmonyPatch(typeof(GameHistoryData), "NotifyTechUnlock")]
public static void MyNotifyTechUnlock(GameHistoryData __instance, int _techId)
{
Debug.Log((object)$"easy mode={config_easy_start.Value},techId={_techId}");
if (!config_easy_start.Value || _techId != 1001)
{
return;
}
UnlockTechByID(2208);
UnlockTechByID(2406);
UnlockTechByID(2605);
UnlockTechByID(2705);
UnlockTechByID(2501);
UnlockTechByID(4104);
UnlockTechByID(2902);
if (GameMain.mainPlayer.package.GetItemCount(1004) > 0)
{
UnlockTechByID(1604);
UnlockTechByID(1703);
UnlockTechByID(1413);
UnlockTechByID(1302);
GameMain.mainPlayer.TryAddItemToPackage(2103, 40, 0, false, 0, false);
GameMain.mainPlayer.TryAddItemToPackage(5001, 400, 0, false, 0, false);
GameMain.mainPlayer.TryAddItemToPackage(2105, 40, 0, false, 0, false);
if (GameMain.mainPlayer.package.GetItemCount(1004) == 99)
{
UnlockTechByID(3803);
UnlockTechAllExcepetWhiteMtrix();
GameMain.mainPlayer.TryAddItemToPackage(2104, 40, 0, false, 0, false);
GameMain.mainPlayer.TryAddItemToPackage(5002, 40, 0, false, 0, false);
GameMain.mainPlayer.TryAddItemToPackage(2316, 10, 0, false, 0, false);
GameMain.mainPlayer.TryAddItemToPackage(2003, 4000, 0, false, 0, false);
GameMain.mainPlayer.TryAddItemToPackage(2013, 1000, 0, false, 0, false);
GameMain.mainPlayer.TryAddItemToPackage(2014, 200, 0, false, 0, false);
GameMain.mainPlayer.TryAddItemToPackage(6005, 10, 0, false, 0, false);
}
}
}
[HarmonyPostfix]
[HarmonyPatch(typeof(GameHistoryData), "SetForNewGame")]
public static void MySetForNewGame(GameHistoryData __instance)
{
Debug.Log((object)$"set research ratio to {config_rsp_ratio.Value}");
__instance.techSpeed *= config_rsp_ratio.Value;
}
[HarmonyPostfix]
[HarmonyPatch(typeof(StorageComponent), "LoadStatic")]
public static void MyLoadStatic(StorageComponent __instance)
{
if (pile_set_done)
{
return;
}
ItemProto[] dataArray = ((ProtoSet<ItemProto>)(object)LDB.items).dataArray;
for (int i = 0; i < dataArray.Length; i++)
{
ItemProto obj = dataArray[i];
obj.StackSize *= config_pile_ratio.Value;
if (ItemProto.isFluid(((Proto)dataArray[i]).ID))
{
ItemProto obj2 = dataArray[i];
obj2.StackSize *= 10;
}
Debug.Log((object)$"set {((Proto)dataArray[i]).ID}:{((Proto)dataArray[i]).name} size to {dataArray[i].StackSize}");
StorageComponent.itemStackCount[((Proto)dataArray[i]).ID] = dataArray[i].StackSize;
}
pile_set_done = true;
}
[HarmonyPrefix]
[HarmonyPatch(typeof(PropertyLogic), "UpdateProduction")]
public static bool MyUpdateProduction(PropertyLogic __instance)
{
FactoryProductionStat[] factoryStatPool = __instance.gameData.statistics.production.factoryStatPool;
int factoryCount = __instance.gameData.factoryCount;
ClusterPropertyData clusterData = __instance.propertySystem.GetClusterData(__instance.gameData.GetClusterSeedKey());
ClusterPropertyData propertyData = __instance.gameData.history.propertyData;
int[] productIds = PropertySystem.productIds;
foreach (int num in productIds)
{
int itemProduction = propertyData.GetItemProduction(num);
int itemProduction2 = clusterData.GetItemProduction(num);
long num2 = 0L;
for (int j = 0; j < factoryCount; j++)
{
int num3 = factoryStatPool[j].productIndices[num];
if (num3 > 0)
{
num2 += factoryStatPool[j].productPool[num3].total[3];
}
}
int num4 = 1;
switch (num)
{
case 6001:
num4 = config_prop_ratio_b.Value;
break;
case 6002:
num4 = config_prop_ratio_r.Value;
break;
case 6003:
num4 = config_prop_ratio_y.Value;
break;
case 6004:
num4 = config_prop_ratio_p.Value;
break;
case 6005:
num4 = config_prop_ratio_g.Value;
break;
case 6006:
num4 = config_prop_ratio_w.Value;
break;
}
int num5 = (int)((double)num2 * (double)num4 * (double)__instance.gameData.history.minimalPropertyMultiplier / 60.0 + 0.001);
if (num5 > itemProduction)
{
propertyData.SetItemProduction(num, num5);
}
if (num5 > itemProduction2)
{
clusterData.SetItemProduction(num, num5);
}
}
return false;
}
public static void UnlockTechAll()
{
TechProto[] dataArray = ((ProtoSet<TechProto>)(object)LDB.techs).dataArray;
for (int i = 0; i < dataArray.Length; i++)
{
UnlockTechByID(((Proto)dataArray[i]).ID);
}
}
public static void UnlockTechAllExcepetWhiteMtrix()
{
//IL_0026: Unknown result type (might be due to invalid IL or missing references)
//IL_002b: Unknown result type (might be due to invalid IL or missing references)
//IL_002d: Unknown result type (might be due to invalid IL or missing references)
//IL_0037: Unknown result type (might be due to invalid IL or missing references)
TechProto[] dataArray = ((ProtoSet<TechProto>)(object)LDB.techs).dataArray;
foreach (TechProto val in dataArray)
{
bool flag = false;
IDCNT[] unlockNeedItemArray = val.unlockNeedItemArray;
foreach (IDCNT val2 in unlockNeedItemArray)
{
if (val2.count > 0 && val2.id == 6006)
{
flag = true;
break;
}
}
if (!flag)
{
UnlockTechByID(((Proto)val).ID);
}
}
}
public static bool UnlockTechByID(int techId)
{
TechProto val = ((ProtoSet<TechProto>)(object)LDB.techs).Select(techId);
if (val == null || val.IsHiddenTech || val.IsObsolete)
{
return false;
}
if (GameMain.data.history.TechUnlocked(techId))
{
return true;
}
Debug.Log((object)$"will unlock tech {techId},level[{val.Level}:{val.MaxLevel}]");
for (int i = 0; i < val.PreTechs.Length; i++)
{
Debug.Log((object)$"unlock pre tech {val.PreTechs[i]}");
if (!GameMain.data.history.TechUnlocked(val.PreTechs[i], val.PreTechsMax) && !UnlockTechByID(val.PreTechs[i]))
{
return false;
}
}
for (int j = 0; j < val.PreTechsImplicit.Length; j++)
{
Debug.Log((object)$"unlock implicit pre tech {val.PreTechsImplicit[j]}");
if (!GameMain.data.history.TechUnlocked(val.PreTechsImplicit[j], val.PreTechsMax) && !UnlockTechByID(val.PreTechsImplicit[j]))
{
return false;
}
}
for (int k = val.Level; k <= val.MaxLevel; k++)
{
GameMain.data.history.UnlockTech(techId);
Debug.Log((object)$"unlock tech {techId},level[{val.Level}:{val.MaxLevel}]");
}
return true;
}
}