using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using CommonAPI;
using CommonAPI.Systems;
using CommonAPI.Systems.ModLocalization;
using HarmonyLib;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.UI;
using xiaoye97;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("Water electrolysis")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Water electrolysis")]
[assembly: AssemblyCopyright("Copyright © 2021")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("7c9af07a-64ff-409f-b5bc-b78e172b5e36")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace RecyclableFuelRod;
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInPlugin("Gnimaerd.DSP.plugin.RecyclableFuelRod", "RecyclableFuelRod", "2.0")]
[CommonAPISubmoduleDependency(new string[] { "ProtoRegistry", "TabSystem", "LocalizationModule" })]
public class RecyclableFuelRod : BaseUnityPlugin
{
public class StringProto
{
public string name;
public string Name;
public string ZHCN;
public string ENUS;
public string FRFR;
public int ID { get; set; }
public void RegisterTranslation()
{
LocalizationModule.RegisterTranslation(Name, ENUS, ZHCN, FRFR);
}
}
private Sprite iconAntiInject;
private Sprite iconDeutInject;
private Sprite iconEptA;
private Sprite iconEptD;
public static ConfigEntry<bool> AntiFuelRecycle;
public static List<int> OriRods;
public static List<int> EmptyRods;
public static List<int> RelatedGenerators;
public static string GUID = "Gnimaerd.DSP.plugin.RecyclableFuelRod";
public static string MODID = "FractionateEverything";
public static int pagenum = 3;
public static ResourceData resources;
public void Awake()
{
//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
//IL_00c0: Expected O, but got Unknown
//IL_0029: Unknown result type (might be due to invalid IL or missing references)
//IL_0033: Expected O, but got Unknown
//IL_0071: Unknown result type (might be due to invalid IL or missing references)
//IL_007b: Expected O, but got Unknown
string directoryName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
try
{
using (ProtoRegistry.StartModLoad(GUID))
{
resources = new ResourceData(GUID, "Recycle", directoryName);
resources.LoadAssetBundle("recycleicons");
ProtoRegistry.AddResource(resources);
pagenum = TabSystem.RegisterTab(MODID + ":" + MODID + "Tab", new TabData("FractionateTab", "Assets/Recycle/add1"));
}
}
catch (Exception)
{
pagenum = TabSystem.RegisterTab(MODID + ":" + MODID + "Tab", new TabData("FractionateTab", "Assets/Recycle/add1"));
}
AntiFuelRecycle = ((BaseUnityPlugin)this).Config.Bind<bool>("config", "AntiFuelRecycle", true, "Turn this to false to deactivate recyclable Antimatter Fuel Rod. 设置为false来停用反物质燃料棒的循环使用。");
OriRods = new List<int> { 1802 };
EmptyRods = new List<int> { 9451 };
RelatedGenerators = new List<int> { 2211 };
if (AntiFuelRecycle.Value)
{
OriRods.Add(1803);
EmptyRods.Add(9452);
RelatedGenerators.Add(2210);
}
AddTranslateDInj();
AddTranslateEptD();
LDBTool.PreAddDataAction = (Action)Delegate.Combine(LDBTool.PreAddDataAction, new Action(AddDeutRods));
bool flag = true;
AddTranslateAInj();
AddTranslateEptA();
LDBTool.PostAddDataAction = (Action)Delegate.Combine(LDBTool.PostAddDataAction, new Action(AddAntiRods));
Harmony.CreateAndPatchAll(typeof(RecyclableFuelRod), (string)null);
Harmony.CreateAndPatchAll(typeof(UIPatchers), (string)null);
}
public void Start()
{
UIPatchers.InitAll();
}
[HarmonyPrefix]
[HarmonyPatch(typeof(PlanetFactory), "InsertInto")]
public static bool InsertIntoPatch(PlanetFactory __instance, int entityId, int itemId, ref byte itemCount, ref byte itemInc, out byte remainInc, ref int __result)
{
remainInc = itemInc;
int beltId = __instance.entityPool[entityId].beltId;
if (beltId > 0)
{
return true;
}
int powerGenId = __instance.entityPool[entityId].powerGenId;
int protoId = __instance.entityPool[entityId].protoId;
int[] array = __instance.entityNeeds[entityId];
if (powerGenId > 0)
{
PowerGeneratorComponent[] genPool = __instance.powerSystem.genPool;
if (!RelatedGenerators.Contains(protoId))
{
return true;
}
Mutex val = __instance.entityMutexs[entityId];
lock (val)
{
if (itemId == genPool[powerGenId].fuelId)
{
if (genPool[powerGenId].fuelCount < 10)
{
PowerGeneratorComponent[] array2 = genPool;
int num = powerGenId;
array2[num].fuelCount = (short)(array2[num].fuelCount + itemCount);
PowerGeneratorComponent[] array3 = genPool;
int num2 = powerGenId;
array3[num2].fuelInc = (short)(array3[num2].fuelInc + itemInc);
remainInc = 0;
__result = itemCount;
return false;
}
__result = 0;
return false;
}
if (genPool[powerGenId].fuelId == 0 && !EmptyRods.Contains(itemId))
{
array = ItemProto.fuelNeeds[genPool[powerGenId].fuelMask];
if (array == null || array.Length == 0)
{
__result = 0;
return false;
}
for (int i = 0; i < array.Length; i++)
{
if (array[i] == itemId)
{
((PowerGeneratorComponent)(ref genPool[powerGenId])).SetNewFuel(itemId, (short)itemCount, (short)itemInc);
remainInc = 0;
__result = itemCount;
return false;
}
}
__result = 0;
return false;
}
if (EmptyRods.Contains(itemId) && (genPool[powerGenId].productHeat == 0L || genPool[powerGenId].productHeat == itemId))
{
PowerGeneratorComponent[] array4 = genPool;
int num3 = powerGenId;
array4[num3].productCount = (short)(array4[num3].productCount + (float)(int)itemCount);
PowerGeneratorComponent[] array5 = genPool;
int num4 = powerGenId;
array5[num4].productHeat = itemId;
remainInc = 0;
__result = itemCount;
return false;
}
}
__result = 0;
return false;
}
return true;
}
[HarmonyPrefix]
[HarmonyPatch(typeof(PowerGeneratorComponent), "GenEnergyByFuel")]
public static bool GenEnergyByFuelPatch(ref PowerGeneratorComponent __instance, long energy, ref int[] consumeRegister)
{
if (!OriRods.Contains(__instance.fuelId))
{
return true;
}
long num = (__instance.productive ? (energy * __instance.useFuelPerTick * 40 / (__instance.genEnergyPerTick * Cargo.incFastDivisionNumerator[__instance.fuelIncLevel])) : (energy * __instance.useFuelPerTick / __instance.genEnergyPerTick));
num = ((energy > 0 && num == 0L) ? 1 : num);
if (__instance.fuelEnergy > num)
{
__instance.fuelEnergy -= num;
return false;
}
__instance.curFuelId = 0;
if (__instance.fuelCount > 0)
{
int num2 = __instance.fuelInc / __instance.fuelCount;
num2 = ((num2 > 0) ? ((num2 > 10) ? 10 : num2) : 0);
__instance.fuelInc -= (short)num2;
__instance.productive = ((ProtoSet<ItemProto>)(object)LDB.items).Select((int)__instance.fuelId).Productive;
if (__instance.productive)
{
__instance.fuelIncLevel = (byte)num2;
num = energy * __instance.useFuelPerTick * 40 / (__instance.genEnergyPerTick * Cargo.incFastDivisionNumerator[__instance.fuelIncLevel]);
}
else
{
__instance.fuelIncLevel = (byte)num2;
num = energy * __instance.useFuelPerTick / __instance.genEnergyPerTick;
}
long num3 = num - __instance.fuelEnergy;
__instance.fuelEnergy = __instance.fuelHeat - num3;
__instance.curFuelId = __instance.fuelId;
__instance.fuelCount--;
consumeRegister[__instance.fuelId]++;
if (__instance.fuelId == 1802)
{
if (__instance.productHeat != 9451)
{
__instance.productCount = 0f;
}
__instance.productHeat = 9451L;
__instance.productCount += 1f;
}
else if (__instance.fuelId == 1803 && OriRods.Contains(1803))
{
if (__instance.productHeat != 9452)
{
__instance.productCount = 0f;
}
__instance.productHeat = 9452L;
__instance.productCount += 1f;
}
if (__instance.fuelCount == 0)
{
__instance.fuelId = 0;
__instance.fuelHeat = 0L;
}
if (__instance.fuelEnergy < 0)
{
__instance.fuelEnergy = 0L;
return false;
}
}
else
{
__instance.fuelEnergy = 0L;
__instance.productive = false;
}
return false;
}
[HarmonyPrefix]
[HarmonyPatch(typeof(PowerGeneratorComponent), "PickFuelFrom")]
public static bool PickFuelFromPatch(ref PowerGeneratorComponent __instance, ref int __result, int filter, out int inc)
{
inc = 0;
if (!EmptyRods.Contains((int)__instance.productHeat))
{
return true;
}
if (filter == 0 && __instance.fuelId > 0 && __instance.fuelCount > 5 && (filter == 0 || filter == __instance.fuelId))
{
if (__instance.fuelInc > 0)
{
inc = __instance.fuelInc / __instance.fuelCount;
}
__instance.fuelInc -= (short)inc;
__instance.fuelCount--;
__result = __instance.fuelId;
return false;
}
if (EmptyRods.Contains((int)__instance.productHeat) && (filter <= 0 || filter == (int)__instance.productHeat))
{
__instance.productCount -= 1f;
__result = (int)__instance.productHeat;
if (__instance.productCount == 0f)
{
__instance.productHeat = 0L;
}
return false;
}
return true;
}
[HarmonyPrefix]
[HarmonyPatch(typeof(PlanetFactory), "PickFrom")]
public static bool PickFromPatch(ref PlanetFactory __instance, ref int __result, int entityId, int offset, int filter, int[] needs, out byte stack, out byte inc)
{
stack = 1;
inc = 0;
int beltId = __instance.entityPool[entityId].beltId;
if (beltId > 0)
{
return true;
}
int powerGenId = __instance.entityPool[entityId].powerGenId;
if (powerGenId > 0 && RelatedGenerators.Contains(__instance.entityPool[entityId].protoId))
{
Mutex val = __instance.entityMutexs[entityId];
lock (val)
{
if (offset > 0 && __instance.powerSystem.genPool[offset].id == offset && __instance.powerSystem.genPool[offset].fuelCount <= 8)
{
int num = default(int);
int num2 = ((PowerGeneratorComponent)(ref __instance.powerSystem.genPool[powerGenId])).PickFuelFrom(filter, ref num);
inc = (byte)num;
__result = num2;
return false;
}
if (EmptyRods.Contains(filter) || filter == 0)
{
int num3 = default(int);
int num4 = ((PowerGeneratorComponent)(ref __instance.powerSystem.genPool[powerGenId])).PickFuelFrom(-1, ref num3);
inc = (byte)num3;
__result = num4;
return false;
}
}
return true;
}
return true;
}
[HarmonyPrefix]
[HarmonyPatch(typeof(Mecha), "GenerateEnergy")]
public static bool MechaGenerateEnergyPatch(ref Mecha __instance, double dt)
{
double num = 1.0;
ItemProto val = ((__instance.reactorItemId > 0) ? ((ProtoSet<ItemProto>)(object)LDB.items).Select(__instance.reactorItemId) : null);
if (val != null)
{
num = val.ReactorInc + 1f;
if (__instance.reactorItemInc > 0)
{
num = ((!val.Productive) ? (num * (1.0 + Cargo.accTableMilli[__instance.reactorItemInc])) : (num * (1.0 + Cargo.incTableMilli[__instance.reactorItemInc])));
}
}
double num2 = __instance.coreEnergyCap - __instance.coreEnergy;
double num3 = __instance.reactorPowerGen * num * dt;
if (num3 > num2)
{
num3 = num2;
}
int num5;
int num4 = default(int);
if (__instance.reactorEnergy < num3 && OriRods.Contains(__instance.reactorItemId) && (num5 = __instance.player.package.AddItemStacked(__instance.reactorItemId - 1802 + 9451, 1, __instance.reactorItemInc, ref num4)) != 0)
{
UIItemup.Up(__instance.reactorItemId - 1802 + 9451, num5);
}
return true;
}
private void AddDeutRods()
{
//IL_0010: Unknown result type (might be due to invalid IL or missing references)
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_0038: Unknown result type (might be due to invalid IL or missing references)
//IL_004c: Unknown result type (might be due to invalid IL or missing references)
//IL_0095: Unknown result type (might be due to invalid IL or missing references)
//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
IconDesc defaultIconDesc = ProtoRegistry.GetDefaultIconDesc(new Color(1f, 1f, 1f), new Color(0f, 1f, 1f), new Color(0f, 0.2f, 0.3f), new Color(0f, 0.4f, 0.5f));
ItemProto val = ProtoRegistry.RegisterItem(9451, "空的氘核燃料棒", "空的氘核燃料棒描述", "Assets/Recycle/EmptyDeut", 611 + pagenum * 1000, 30, (EItemType)4, defaultIconDesc);
IconDesc defaultIconDesc2 = ProtoRegistry.GetDefaultIconDesc(new Color(1f, 1f, 1f), new Color(0f, 1f, 1f), new Color(0f, 0.2f, 0.3f), new Color(0f, 0.4f, 0.5f));
ItemProto val2 = ProtoRegistry.RegisterItem(9452, "空的反物质燃料棒", "空的反物质燃料棒描述", "Assets/Recycle/EmptyAnti", 612 + pagenum * 1000, 30, (EItemType)4, defaultIconDesc2);
RecipeProto val3 = ProtoRegistry.RegisterRecipe(458, (ERecipeType)4, 360, new int[2] { 9451, 1121 }, new int[2] { 1, 10 }, new int[1] { 1802 }, new int[1] { 1 }, "氘核燃料棒再灌注描述", 1416, 511 + pagenum * 1000, "氘核燃料棒再灌注", "Assets/Recycle/DeutInject");
val3.Explicit = true;
RecipeProto val4 = ProtoRegistry.RegisterRecipe(460, (ERecipeType)4, 720, new int[2] { 1107, 1205 }, new int[2] { 1, 1 }, new int[1] { 9451 }, new int[1] { 2 }, "空的氘核燃料棒描述", 1416, 611 + pagenum * 1000, "空的氘核燃料棒", "Assets/Recycle/EmptyDeut");
RecipeProto val5 = ProtoRegistry.RegisterRecipe(459, (ERecipeType)4, 720, new int[3] { 1122, 1120, 9452 }, new int[3] { 6, 6, 1 }, new int[1] { 1803 }, new int[1] { 1 }, "反物质燃料棒再灌注描述", 1145, 512 + pagenum * 1000, "反物质燃料棒再灌注", "Assets/Recycle/AntiInject");
val5.Explicit = true;
RecipeProto val6 = ProtoRegistry.RegisterRecipe(461, (ERecipeType)4, 1440, new int[2] { 1107, 1403 }, new int[2] { 1, 1 }, new int[1] { 9452 }, new int[1] { 2 }, "空的反物质燃料棒描述", 1145, 612 + pagenum * 1000, "空的反物质燃料棒", "Assets/Recycle/EmptyAnti");
}
private void AddAntiRods()
{
}
private void AddTranslateDInj()
{
StringProto stringProto = new StringProto();
StringProto stringProto2 = new StringProto();
stringProto.ID = 10559;
stringProto.Name = "氘核燃料棒再灌注";
stringProto.name = "氘核燃料棒再灌注";
stringProto.ZHCN = "氘核燃料棒再灌注";
stringProto.ENUS = "Deuteron fuel rod reperfusion";
stringProto.FRFR = "Deuteron fuel rod reperfusion";
stringProto2.ID = 10560;
stringProto2.Name = "氘核燃料棒再灌注描述";
stringProto2.name = "氘核燃料棒再灌注描述";
stringProto2.ZHCN = "使用重氢填充空的氘核燃料棒。";
stringProto2.ENUS = "Fill empty deuteron fuel rods with deuterium.";
stringProto2.FRFR = "Fill empty deuteron fuel rods with deuterium.";
stringProto.RegisterTranslation();
stringProto2.RegisterTranslation();
}
private void AddTranslateEptD()
{
StringProto stringProto = new StringProto();
StringProto stringProto2 = new StringProto();
stringProto.ID = 10561;
stringProto.Name = "空的氘核燃料棒";
stringProto.name = "空的氘核燃料棒";
stringProto.ZHCN = "空的氘核燃料棒";
stringProto.ENUS = "Empty deuteron fuel rod";
stringProto.FRFR = "Empty deuteron fuel rod";
stringProto2.ID = 10562;
stringProto2.Name = "空的氘核燃料棒描述";
stringProto2.name = "空的氘核燃料棒描述";
stringProto2.ZHCN = "这有啥可描述的?它本来是个氘核燃料棒,然后用光了……就变成这样了。";
stringProto2.ENUS = "It was originally a deuteron fuel rod, and then ran out, and it became like this:)";
stringProto2.FRFR = "It was originally a deuteron fuel rod, and then ran out, and it became like this:)";
stringProto.RegisterTranslation();
stringProto2.RegisterTranslation();
}
private void AddTranslateAInj()
{
StringProto stringProto = new StringProto();
StringProto stringProto2 = new StringProto();
stringProto.ID = 10563;
stringProto.Name = "反物质燃料棒再灌注";
stringProto.name = "反物质燃料棒再灌注";
stringProto.ZHCN = "反物质燃料棒再灌注";
stringProto.ENUS = "Anitimatter fuel rod reperfusion";
stringProto.FRFR = "Anitimatter fuel rod reperfusion";
stringProto2.ID = 10564;
stringProto2.Name = "反物质燃料棒再灌注描述";
stringProto2.name = "反物质燃料棒再灌注描述";
stringProto2.ZHCN = "使用氢和反物质氢装填空的反物质燃料棒。";
stringProto2.ENUS = "Use hydrogen and antimatter hydrogen to fill empty antimatter fuel rods.";
stringProto2.FRFR = "Use hydrogen and antimatter hydrogen to fill empty antimatter fuel rods.";
stringProto.RegisterTranslation();
stringProto2.RegisterTranslation();
}
private void AddTranslateEptA()
{
StringProto stringProto = new StringProto();
StringProto stringProto2 = new StringProto();
StringProto stringProto3 = new StringProto();
stringProto.ID = 10565;
stringProto.Name = "空的反物质燃料棒";
stringProto.name = "空的反物质燃料棒";
stringProto.ZHCN = "空的反物质燃料棒";
stringProto.ENUS = "Empty antimatter fuel rods";
stringProto.FRFR = "Empty antimatter fuel rods";
stringProto2.ID = 10566;
stringProto2.Name = "空的反物质燃料棒描述";
stringProto2.name = "空的反物质燃料棒描述";
stringProto2.ZHCN = "这是一个空的,反物质燃料棒。";
stringProto2.ENUS = "This is an empty, anti-matter fuel rod. ";
stringProto2.FRFR = "This is an empty, anti-matter fuel rod. ";
stringProto3.ID = 10567;
stringProto3.Name = "FractionateTab";
stringProto3.name = "FractionateTab";
stringProto3.ZHCN = "分馏";
stringProto3.ENUS = "Fract/Rods";
stringProto3.FRFR = "Fract/Rods";
stringProto.RegisterTranslation();
stringProto2.RegisterTranslation();
stringProto3.RegisterTranslation();
LocalizationModule.RegisterTranslation("不相符的物品gm", "Item not match", "物品不相符", "Item not match");
}
}
public class UIPatchers
{
[Serializable]
[CompilerGenerated]
private sealed class <>c
{
public static readonly <>c <>9 = new <>c();
public static UnityAction <>9__6_0;
internal void <InitAll>b__6_0()
{
OnEmptyRodIconClick();
}
}
public static GameObject usedFuelObj;
public static GameObject emptyRodIconObj;
public static Image emptyRodIcon;
public static Text emptyRodCount;
public static UIButton emptyRodUIButton;
public static Button emptyRodButton;
public static void InitAll()
{
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Expected O, but got Unknown
//IL_0098: Unknown result type (might be due to invalid IL or missing references)
//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
//IL_00db: Unknown result type (might be due to invalid IL or missing references)
//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
//IL_0136: Unknown result type (might be due to invalid IL or missing references)
//IL_01a4: Unknown result type (might be due to invalid IL or missing references)
//IL_01f5: Unknown result type (might be due to invalid IL or missing references)
//IL_01fa: Unknown result type (might be due to invalid IL or missing references)
//IL_0200: Expected O, but got Unknown
if (!((Object)(object)usedFuelObj == (Object)null))
{
return;
}
Transform transform = GameObject.Find("UI Root/Overlay Canvas/In Game/Windows/Power Generator Window/produce-2").transform;
usedFuelObj = new GameObject();
((Object)usedFuelObj).name = "usedFuel";
usedFuelObj.transform.SetParent(transform, false);
usedFuelObj.AddComponent<Image>();
usedFuelObj.GetComponent<Image>().sprite = GameObject.Find("UI Root/Overlay Canvas/In Game/Windows/Power Generator Window/produce-2/fuel").GetComponent<Image>().sprite;
((Graphic)usedFuelObj.GetComponent<Image>()).color = ((Graphic)GameObject.Find("UI Root/Overlay Canvas/In Game/Windows/Power Generator Window/produce-2/fuel").GetComponent<Image>()).color;
usedFuelObj.GetComponent<RectTransform>().sizeDelta = new Vector2(64f, 64f);
usedFuelObj.transform.localScale = new Vector3(0.75f, 0.75f, 0.75f);
usedFuelObj.transform.localPosition = new Vector3(68f, -56f, 0f);
Transform transform2 = usedFuelObj.transform;
GameObject val = GameObject.Find("UI Root/Overlay Canvas/In Game/Windows/Power Generator Window/produce-2/fuel/fuel-icon");
emptyRodIconObj = Object.Instantiate<GameObject>(val, transform2);
emptyRodIconObj.transform.localScale = Vector3.one;
emptyRodIcon = emptyRodIconObj.GetComponent<Image>();
((Behaviour)emptyRodIcon).enabled = true;
emptyRodCount = ((Component)emptyRodIconObj.transform.Find("cnt-text")).GetComponent<Text>();
emptyRodCount.fontSize = 16;
GameObject val2 = GameObject.Find("UI Root/Overlay Canvas/In Game/Windows/Power Generator Window/produce-2/fuel/button");
GameObject val3 = Object.Instantiate<GameObject>(val2, transform2);
val3.transform.localScale = Vector3.one;
emptyRodUIButton = val3.GetComponent<UIButton>();
emptyRodButton = val3.GetComponent<Button>();
((UnityEventBase)emptyRodButton.onClick).RemoveAllListeners();
ButtonClickedEvent onClick = emptyRodButton.onClick;
object obj = <>c.<>9__6_0;
if (obj == null)
{
UnityAction val4 = delegate
{
OnEmptyRodIconClick();
};
<>c.<>9__6_0 = val4;
obj = (object)val4;
}
((UnityEvent)onClick).AddListener((UnityAction)obj);
}
[HarmonyPostfix]
[HarmonyPatch(typeof(EntityBriefInfo), "SetBriefInfo")]
public static void SetBriefInfoPostPatch(ref EntityBriefInfo __instance, PlanetFactory _factory, int _entityId)
{
//IL_004c: Unknown result type (might be due to invalid IL or missing references)
//IL_0051: Unknown result type (might be due to invalid IL or missing references)
//IL_0053: Unknown result type (might be due to invalid IL or missing references)
//IL_0066: Unknown result type (might be due to invalid IL or missing references)
//IL_007f: Unknown result type (might be due to invalid IL or missing references)
if (_factory == null || _entityId == 0)
{
return;
}
EntityData[] entityPool = _factory.entityPool;
InserterComponent[] inserterPool = _factory.factorySystem.inserterPool;
PowerSystem powerSystem = _factory.powerSystem;
CargoTraffic cargoTraffic = _factory.cargoTraffic;
VeinData[] veinPool = _factory.veinPool;
EntityData val = entityPool[_entityId];
if (val.id != 0 && val.powerGenId > 0)
{
PowerGeneratorComponent[] genPool = powerSystem.genPool;
int powerGenId = val.powerGenId;
if (RecyclableFuelRod.EmptyRods.Contains((int)genPool[powerGenId].productHeat))
{
__instance.storage.Add((int)genPool[powerGenId].productHeat, (int)genPool[powerGenId].productCount, 0);
}
}
}
[HarmonyPostfix]
[HarmonyPatch(typeof(UIPowerGeneratorWindow), "OnGeneratorIdChange")]
public static void UIPowerGenIdChangePatch(ref UIPowerGeneratorWindow __instance)
{
//IL_0035: Unknown result type (might be due to invalid IL or missing references)
//IL_003a: Unknown result type (might be due to invalid IL or missing references)
//IL_003b: Unknown result type (might be due to invalid IL or missing references)
try
{
if (__instance.generatorId == 0 || __instance.factory == null)
{
return;
}
PowerGeneratorComponent val = __instance.powerSystem.genPool[__instance.generatorId];
if (val.id == __instance.generatorId)
{
int entityId = __instance.powerSystem.genPool[__instance.generatorId].entityId;
int protoId = __instance.factory.entityPool[entityId].protoId;
if (RecyclableFuelRod.RelatedGenerators.Contains(protoId))
{
usedFuelObj.SetActive(true);
}
else
{
usedFuelObj.SetActive(false);
}
}
}
catch (Exception)
{
}
}
[HarmonyPostfix]
[HarmonyPatch(typeof(UIPowerGeneratorWindow), "_OnUpdate")]
public static void UIPowerGenWinOnUpdatePatch(ref UIPowerGeneratorWindow __instance)
{
//IL_005a: Unknown result type (might be due to invalid IL or missing references)
//IL_005f: Unknown result type (might be due to invalid IL or missing references)
//IL_0060: Unknown result type (might be due to invalid IL or missing references)
//IL_008d: Unknown result type (might be due to invalid IL or missing references)
//IL_00be: Unknown result type (might be due to invalid IL or missing references)
//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
//IL_010f: Unknown result type (might be due to invalid IL or missing references)
//IL_0134: Unknown result type (might be due to invalid IL or missing references)
//IL_016a: Unknown result type (might be due to invalid IL or missing references)
//IL_01d2: Unknown result type (might be due to invalid IL or missing references)
if (!usedFuelObj.activeSelf)
{
return;
}
UIPowerGeneratorWindow val = __instance;
if ((Object)(object)val == (Object)null || val.generatorId == 0 || val.factory == null)
{
return;
}
PowerGeneratorComponent val2 = val.powerSystem.genPool[val.generatorId];
if (val2.id != val.generatorId)
{
return;
}
ItemProto val3 = ((ProtoSet<ItemProto>)(object)LDB.items).Select((int)val.factory.entityPool[val2.entityId].protoId);
if (val3 == null)
{
return;
}
PowerNetwork val4 = val.powerSystem.netPool[val2.networkId];
val.powerNetworkDesc.powerNetwork = val4;
Assert.NotNull((object)val4);
if (val4 != null)
{
if (val2.productHeat > 0)
{
emptyRodIconObj.SetActive(true);
ItemProto val5 = ((ProtoSet<ItemProto>)(object)LDB.items).Select((int)val2.productHeat);
emptyRodIcon.sprite = val5.iconSprite;
emptyRodCount.text = ((int)val2.productCount).ToString();
emptyRodUIButton.tips.itemId = ((Proto)val5).ID;
emptyRodUIButton.tips.itemCount = (int)val2.productCount;
}
else
{
emptyRodIconObj.SetActive(false);
emptyRodCount.text = "";
emptyRodUIButton.tips.itemId = 0;
emptyRodUIButton.tips.itemCount = 0;
}
emptyRodUIButton.tips.itemInc = 0;
emptyRodUIButton.tips.type = (ItemTipType)0;
}
}
public static void OnEmptyRodIconClick()
{
//IL_005d: Unknown result type (might be due to invalid IL or missing references)
//IL_0062: Unknown result type (might be due to invalid IL or missing references)
//IL_0063: Unknown result type (might be due to invalid IL or missing references)
//IL_0080: Unknown result type (might be due to invalid IL or missing references)
//IL_009b: Unknown result type (might be due to invalid IL or missing references)
//IL_04a6: Unknown result type (might be due to invalid IL or missing references)
//IL_01f9: Unknown result type (might be due to invalid IL or missing references)
//IL_0202: Unknown result type (might be due to invalid IL or missing references)
//IL_0527: Unknown result type (might be due to invalid IL or missing references)
//IL_053a: Unknown result type (might be due to invalid IL or missing references)
//IL_04d8: Unknown result type (might be due to invalid IL or missing references)
//IL_04df: Unknown result type (might be due to invalid IL or missing references)
//IL_04f1: Unknown result type (might be due to invalid IL or missing references)
//IL_021e: Unknown result type (might be due to invalid IL or missing references)
//IL_0427: Unknown result type (might be due to invalid IL or missing references)
//IL_043a: Unknown result type (might be due to invalid IL or missing references)
//IL_03d5: Unknown result type (might be due to invalid IL or missing references)
//IL_03dc: Unknown result type (might be due to invalid IL or missing references)
//IL_03ee: Unknown result type (might be due to invalid IL or missing references)
//IL_02aa: Unknown result type (might be due to invalid IL or missing references)
UIPowerGeneratorWindow generatorWindow = UIRoot.instance.uiGame.generatorWindow;
if (generatorWindow.generatorId == 0 || generatorWindow.factory == null || generatorWindow.player == null)
{
return;
}
PowerGeneratorComponent[] genPool = generatorWindow.powerSystem.genPool;
int generatorId = generatorWindow.generatorId;
PowerGeneratorComponent val = generatorWindow.powerSystem.genPool[generatorWindow.generatorId];
if (val.id != generatorWindow.generatorId || val.useFuelPerTick == 0)
{
return;
}
int[] array = ItemProto.fuelNeeds[val.fuelMask];
int[] array2 = new int[1] { 9451 };
if (array == null)
{
return;
}
for (int i = 0; i < array.Length; i++)
{
if (array[i] == 1803 && RecyclableFuelRod.OriRods.Contains(1803))
{
array2[i] = 9452;
}
}
if (generatorWindow.player.inhandItemId > 0 && generatorWindow.player.inhandItemCount == 0)
{
generatorWindow.player.SetHandItems(0, 0, 0);
}
else if (generatorWindow.player.inhandItemId > 0 && generatorWindow.player.inhandItemCount > 0)
{
if (generatorWindow.player.inhandItemId == 1000)
{
return;
}
bool flag = false;
for (int j = 0; j < array2.Length; j++)
{
if (array2[j] == generatorWindow.player.inhandItemId)
{
flag = true;
break;
}
}
if (!flag)
{
UIRealtimeTip.Popup(Localization.Translate("错误燃料"), true, 0);
}
else if (generatorWindow.player.inhandItemId == (int)val.productHeat || val.productHeat == 0)
{
int num = (int)(100f - val.productCount);
if (num < 0)
{
num = 0;
}
int num2 = ((generatorWindow.player.inhandItemCount < num) ? generatorWindow.player.inhandItemCount : num);
if (num2 <= 0)
{
UIRealtimeTip.Popup(Localization.Translate("栏位已满"), true, 0);
return;
}
int inhandItemCount = generatorWindow.player.inhandItemCount;
int inhandItemInc = generatorWindow.player.inhandItemInc;
int num3 = num2;
int num4 = ((inhandItemCount != 0) ? (inhandItemInc / inhandItemCount) : 0);
if (val.productHeat == 0)
{
genPool[generatorId].productHeat = generatorWindow.player.inhandItemId;
}
genPool[generatorId].productCount = genPool[generatorId].productCount + (float)(short)num3;
generatorWindow.player.AddHandItemCount_Unsafe(-num3);
generatorWindow.player.SetHandItemInc_Unsafe(generatorWindow.player.inhandItemInc - num4);
if (generatorWindow.player.inhandItemCount <= 0)
{
generatorWindow.player.SetHandItemId_Unsafe(0);
generatorWindow.player.SetHandItemCount_Unsafe(0);
generatorWindow.player.SetHandItemInc_Unsafe(0);
}
}
else if (generatorWindow.player.inhandItemCount > 100)
{
UIRealtimeTip.Popup(Localization.Translate("不相符的物品gm"), true, 0);
}
else
{
generatorWindow.player.SetHandItemId_Unsafe(0);
generatorWindow.player.SetHandItemCount_Unsafe(0);
generatorWindow.player.SetHandItemInc_Unsafe(0);
if (VFInput.shift || VFInput.control)
{
int num5 = generatorWindow.player.TryAddItemToPackage((int)val.productHeat, (int)val.productCount, 0, false, 0, false);
UIItemup.Up((int)val.productHeat, num5);
genPool[generatorId].productHeat = 0L;
genPool[generatorId].productCount = 0f;
}
else
{
generatorWindow.player.SetHandItemId_Unsafe((int)val.productHeat);
generatorWindow.player.SetHandItemCount_Unsafe((int)val.productCount);
generatorWindow.player.SetHandItemInc_Unsafe(0);
genPool[generatorId].productHeat = 0L;
genPool[generatorId].productCount = 0f;
}
}
}
else if (generatorWindow.player.inhandItemId == 0 && generatorWindow.player.inhandItemCount == 0 && val.productHeat != 0)
{
if (VFInput.shift || VFInput.control)
{
int num6 = generatorWindow.player.TryAddItemToPackage((int)val.productHeat, (int)val.productCount, 0, false, 0, false);
UIItemup.Up((int)val.productHeat, num6);
genPool[generatorId].productHeat = 0L;
genPool[generatorId].productCount = 0f;
}
else
{
generatorWindow.player.SetHandItemId_Unsafe((int)val.productHeat);
generatorWindow.player.SetHandItemCount_Unsafe((int)val.productCount);
generatorWindow.player.SetHandItemInc_Unsafe(0);
genPool[generatorId].productHeat = 0L;
genPool[generatorId].productCount = 0f;
}
}
}
}