using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Threading;
using BepInEx;
using BepInEx.Configuration;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("packageLogistic")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("packageLogistic")]
[assembly: AssemblyCopyright("Copyright © 2026")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("8c8cf05d-4a85-4b5c-83fd-6453fe5c7d52")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.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]
[Microsoft.CodeAnalysis.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]
[Microsoft.CodeAnalysis.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 PackageLogistic
{
[BepInPlugin("com.qlvlp.dsp.PackageLogistic", "PackageLogistic", "1.1.5")]
public class PackageLogistic : BaseUnityPlugin
{
public const string GUID = "com.qlvlp.dsp.PackageLogistic";
public const string NAME = "PackageLogistic";
public const string VERSION = "1.1.5";
private ConfigEntry<bool>? autoSpray;
private ConfigEntry<bool>? costProliferator;
private ConfigEntry<bool>? infVeins;
private ConfigEntry<bool>? infItems;
private ConfigEntry<bool>? infSand;
private ConfigEntry<bool>? infBuildings;
private ConfigEntry<bool>? useStorege;
private ConfigEntry<KeyboardShortcut>? hotKey;
private ConfigEntry<bool>? enableMod;
private ConfigEntry<bool>? autoReplenishPackage;
private ConfigEntry<bool>? autoReplenishTPPFuel;
private HashSet<int>? battleBaseStorgeIDs;
private DeliveryPackage? deliveryPackage;
private Dictionary<int, int> deliveryPackageItems = new Dictionary<int, int>();
private readonly List<(int, int)> proliferators = new List<(int, int)>();
private readonly Dictionary<int, int> incPool = new Dictionary<int, int>
{
{ 1141, 0 },
{ 1142, 0 },
{ 1143, 0 }
};
private readonly Dictionary<string, bool> taskState = new Dictionary<string, bool>();
private int stackSize = 0;
private const float hydrogenThreshold = 0.6f;
private bool showGUI = false;
private Rect windowRect = new Rect(700f, 250f, 500f, 400f);
private readonly Texture2D windowTexture = new Texture2D(10, 10);
private int selectedPanel = 0;
private readonly Dictionary<int, string> fuelOptions = new Dictionary<int, string>();
private ConfigEntry<int>? fuelId;
private int selectedFuelIndex;
private ConfigEntry<bool>? infFleet;
private ConfigEntry<bool>? infAmmo;
private readonly Dictionary<EAmmoType, List<int>> ammos = new Dictionary<EAmmoType, List<int>>();
private void Start()
{
//IL_0022: Unknown result type (might be due to invalid IL or missing references)
//IL_0327: Unknown result type (might be due to invalid IL or missing references)
hotKey = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("窗口快捷键", "Key", new KeyboardShortcut((KeyCode)108, (KeyCode[])(object)new KeyCode[1] { (KeyCode)306 }), (ConfigDescription)null);
enableMod = ((BaseUnityPlugin)this).Config.Bind<bool>("配置", "EnableMod", true, "启用MOD");
autoReplenishPackage = ((BaseUnityPlugin)this).Config.Bind<bool>("配置", "autoReplenishPackage", true, "自动补充背包中开启过滤的物品(鼠标中键点击格子即可开启过滤)");
autoSpray = ((BaseUnityPlugin)this).Config.Bind<bool>("配置", "AutoSpray", true, "自动喷涂。自动对物流背包和星际运输站内的其它物品进行喷涂");
costProliferator = ((BaseUnityPlugin)this).Config.Bind<bool>("配置", "CostProliferator", true, "消耗增产剂。自动喷涂时消耗背包或星际物流站里的增产剂");
infItems = ((BaseUnityPlugin)this).Config.Bind<bool>("配置", "InfItems", false, "无限物品。物流背包和星际运输站内所有物品无限数量(无法获取成就)");
infVeins = ((BaseUnityPlugin)this).Config.Bind<bool>("配置", "InfVeins", false, "无限矿物。物流背包和星际运输站内所有矿物无限数量");
infBuildings = ((BaseUnityPlugin)this).Config.Bind<bool>("配置", "InfBuildings", false, "无限建筑。物流背包和星际运输站内所有建筑无限数量");
infSand = ((BaseUnityPlugin)this).Config.Bind<bool>("配置", "InfSand", false, "无限沙土。沙土无限数量(固定为1G)");
useStorege = ((BaseUnityPlugin)this).Config.Bind<bool>("配置", "useStorege", true, "从储物箱和储液罐回收物品");
autoReplenishTPPFuel = ((BaseUnityPlugin)this).Config.Bind<bool>("配置", "autoReplenishTPPFuel", true, "自动为火力发电站补充燃料");
fuelId = ((BaseUnityPlugin)this).Config.Bind<int>("配置", "fuelId", 0, "火力发电站燃料ID\n0:自动选择,精炼油和氢储量超60%时,谁多使用谁,否则使用煤,可防止原油裂解反应阻塞\n1006:煤, 1109:石墨, 1007:原油, 1114:精炼油, 1120:氢气, 1801:氢燃料棒, 1011:可燃冰\n5206:能量碎片, 1128:燃烧单元, 1030:木材, 1031:植物燃料");
fuelOptions.Add(0, "自动");
fuelOptions.Add(1006, "煤");
fuelOptions.Add(1109, "石墨");
fuelOptions.Add(1007, "原油");
fuelOptions.Add(1114, "精炼油");
fuelOptions.Add(1120, "氢气");
fuelOptions.Add(1801, "氢燃料棒");
fuelOptions.Add(1011, "可燃冰");
fuelOptions.Add(5206, "能量碎片");
fuelOptions.Add(1128, "燃烧单元");
fuelOptions.Add(1030, "木材");
fuelOptions.Add(1031, "植物燃料");
selectedFuelIndex = fuelOptions.Keys.ToList().FindIndex((int id) => id == fuelId.Value);
proliferators.Add((1143, 4));
proliferators.Add((1142, 2));
proliferators.Add((1141, 1));
windowTexture.SetPixels(Enumerable.Repeat<Color>(new Color(0f, 0f, 0f, 1f), 100).ToArray());
windowTexture.Apply();
infAmmo = ((BaseUnityPlugin)this).Config.Bind<bool>("配置", "InfAmmo", false, "无限弹药。物流背包和星际运输站内弹药无限数量");
infFleet = ((BaseUnityPlugin)this).Config.Bind<bool>("配置", "infFleet", false, "无限舰队。物流背包和星际运输站内无人机与战舰无限数量");
ammos.Add((EAmmoType)1, new List<int>(3) { 1603, 1602, 1601 });
ammos.Add((EAmmoType)5, new List<int>(3) { 1611, 1610, 1609 });
ammos.Add((EAmmoType)3, new List<int>(3) { 1606, 1605, 1604 });
ammos.Add((EAmmoType)4, new List<int>(2) { 1608, 1607 });
ammos.Add((EAmmoType)6, new List<int>(2) { 1613, 1612 });
new Thread((ThreadStart)delegate
{
((BaseUnityPlugin)this).Logger.LogInfo((object)"PackageLogistic start!");
while (true)
{
DateTime now = DateTime.Now;
try
{
if ((Object)(object)GameMain.instance == (Object)null || GameMain.instance.isMenuDemo || GameMain.isPaused || !GameMain.isRunning || GameMain.data == null)
{
((BaseUnityPlugin)this).Logger.LogInfo((object)"Game is not running!");
}
else if (enableMod.Value)
{
if (infSand.Value && GameMain.mainPlayer.sandCount != 1000000000)
{
Traverse.Create((object)GameMain.mainPlayer).Property("sandCount", (object[])null).SetValue((object)1000000000);
}
deliveryPackage = GameMain.mainPlayer.deliveryPackage;
CreateDeliveryPackageItemIndex();
CheckTech();
FindbattleBaseStorges();
taskState["ProcessBattleBase"] = false;
ThreadPool.QueueUserWorkItem(ProcessBattleBase, taskState);
if (useStorege.Value)
{
taskState["ProcessStorage"] = false;
ThreadPool.QueueUserWorkItem(ProcessStorage, taskState);
}
taskState["ProcessAssembler"] = false;
ThreadPool.QueueUserWorkItem(ProcessAssembler, taskState);
taskState["ProcessMiner"] = false;
ThreadPool.QueueUserWorkItem(ProcessMiner, taskState);
taskState["ProcessPowerGenerator"] = false;
ThreadPool.QueueUserWorkItem(ProcessPowerGenerator, taskState);
taskState["ProcessPowerExchanger"] = false;
ThreadPool.QueueUserWorkItem(ProcessPowerExchanger, taskState);
taskState["ProcessSilo"] = false;
ThreadPool.QueueUserWorkItem(ProcessSilo, taskState);
taskState["ProcessEjector"] = false;
ThreadPool.QueueUserWorkItem(ProcessEjector, taskState);
taskState["ProcessLab"] = false;
ThreadPool.QueueUserWorkItem(ProcessLab, taskState);
taskState["ProcessTurret"] = false;
ThreadPool.QueueUserWorkItem(ProcessTurret, taskState);
if (autoReplenishPackage.Value)
{
taskState["ProcessPackage"] = false;
ThreadPool.QueueUserWorkItem(ProcessPackage, taskState);
}
List<string> list = new List<string>(taskState.Keys);
string arg = "";
while (true)
{
Thread.Sleep(3);
bool flag = true;
DateTime now2 = DateTime.Now;
for (int i = 0; i < list.Count; i++)
{
if (!taskState[list[i]])
{
arg = list[i];
flag = false;
break;
}
}
if ((now2 - now).TotalMilliseconds >= 5000.0)
{
((BaseUnityPlugin)this).Logger.LogError((object)$"{arg} cost time >= 1000 ms");
break;
}
if (flag)
{
break;
}
Thread.Sleep(5);
}
}
}
catch (Exception ex)
{
((BaseUnityPlugin)this).Logger.LogError((object)"PackageLogistic exception!");
((BaseUnityPlugin)this).Logger.LogError((object)ex.ToString());
}
finally
{
DateTime now3 = DateTime.Now;
double totalMilliseconds = (now3 - now).TotalMilliseconds;
((BaseUnityPlugin)this).Logger.LogDebug((object)$"loop cost:{totalMilliseconds}");
}
}
}).Start();
}
private void Update()
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
KeyboardShortcut value = hotKey.Value;
if (((KeyboardShortcut)(ref value)).IsDown())
{
showGUI = !showGUI;
}
}
private void OnGUI()
{
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_0021: 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_004b: Expected O, but got Unknown
//IL_0046: Unknown result type (might be due to invalid IL or missing references)
//IL_004b: Unknown result type (might be due to invalid IL or missing references)
if (showGUI)
{
GUI.DrawTexture(windowRect, (Texture)(object)windowTexture);
windowRect = GUI.Window(0, windowRect, new WindowFunction(WindowFunction), string.Format("{0} {1}", "PackageLogistic", "1.1.5"));
}
}
private void WindowFunction(int windowID)
{
string[] array = new string[3] { "主选项", "物品", "战斗" };
selectedPanel = GUILayout.Toolbar(selectedPanel, array, Array.Empty<GUILayoutOption>());
switch (selectedPanel)
{
case 0:
MainPanel();
break;
case 1:
ItemPanel();
break;
case 2:
FightPanel();
break;
}
GUI.DragWindow();
}
private void MainPanel()
{
GUILayout.BeginVertical(Array.Empty<GUILayoutOption>());
GUILayout.Space(10f);
GUILayout.Label("启用或停止MOD运行", Array.Empty<GUILayoutOption>());
enableMod.Value = GUILayout.Toggle(enableMod.Value, "启用MOD", Array.Empty<GUILayoutOption>());
GUILayout.Space(10f);
GUILayout.Label("自动补充背包中开启过滤的物品", Array.Empty<GUILayoutOption>());
autoReplenishPackage.Value = GUILayout.Toggle(autoReplenishPackage.Value, "自动补充", Array.Empty<GUILayoutOption>());
GUILayout.Space(15f);
GUILayout.Label("自动对物流背包内的物品进行喷涂", Array.Empty<GUILayoutOption>());
GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
autoSpray.Value = GUILayout.Toggle(autoSpray.Value, "自动喷涂", Array.Empty<GUILayoutOption>());
costProliferator.Value = GUILayout.Toggle(costProliferator.Value, "消耗增产剂", Array.Empty<GUILayoutOption>());
GUILayout.EndHorizontal();
GUILayout.Space(15f);
useStorege.Value = GUILayout.Toggle(useStorege.Value, "从储物箱和储液罐回收物品", Array.Empty<GUILayoutOption>());
GUILayout.Space(15f);
autoReplenishTPPFuel.Value = GUILayout.Toggle(autoReplenishTPPFuel.Value, "自动为火力发电厂补充燃料", Array.Empty<GUILayoutOption>());
if (autoReplenishTPPFuel.Value)
{
selectedFuelIndex = GUILayout.SelectionGrid(selectedFuelIndex, fuelOptions.Values.ToArray(), 4, GUI.skin.toggle, Array.Empty<GUILayoutOption>());
fuelId.Value = fuelOptions.Keys.ToArray()[selectedFuelIndex];
}
GUILayout.Space(5f);
GUILayout.EndVertical();
}
private void ItemPanel()
{
GUILayout.BeginVertical(Array.Empty<GUILayoutOption>());
GUILayout.Space(10f);
GUILayout.Label("物流背包内所有建筑无限数量", Array.Empty<GUILayoutOption>());
infBuildings.Value = GUILayout.Toggle(infBuildings.Value, "无限建筑", Array.Empty<GUILayoutOption>());
GUILayout.Space(15f);
GUILayout.Label("物流背包内所有矿物无限数量", Array.Empty<GUILayoutOption>());
infVeins.Value = GUILayout.Toggle(infVeins.Value, "无限矿物", Array.Empty<GUILayoutOption>());
GUILayout.Space(15f);
GUILayout.Label("物流背包内所有物品无限数量(无法获取成就)", Array.Empty<GUILayoutOption>());
infItems.Value = GUILayout.Toggle(infItems.Value, "无限物品", Array.Empty<GUILayoutOption>());
GUILayout.Space(15f);
GUILayout.Label("沙土无限数量(固定为1G)", Array.Empty<GUILayoutOption>());
infSand.Value = GUILayout.Toggle(infSand.Value, "无限沙土", Array.Empty<GUILayoutOption>());
GUILayout.Space(5f);
GUILayout.EndVertical();
}
private void FightPanel()
{
//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
//IL_00c0: Expected O, but got Unknown
GUILayout.BeginVertical(Array.Empty<GUILayoutOption>());
GUILayout.Space(10f);
GUILayout.Label("物流背包内所有弹药无限数量", Array.Empty<GUILayoutOption>());
infAmmo.Value = GUILayout.Toggle(infAmmo.Value, "无限弹药", Array.Empty<GUILayoutOption>());
GUILayout.Space(15f);
GUILayout.Label("物流背包内无人机与战舰无限数量", Array.Empty<GUILayoutOption>());
infFleet.Value = GUILayout.Toggle(infFleet.Value, "无限舰队", Array.Empty<GUILayoutOption>());
GUILayout.Space(15f);
if (GUILayout.Button(new GUIContent("清理战场分析基站", "设置不掉落的物品将被丢弃"), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(150f) }))
{
ClearBattleBase();
}
GUILayout.Space(5f);
GUILayout.EndVertical();
}
private void CheckTech()
{
((BaseUnityPlugin)this).Logger.LogDebug((object)"CheckTech");
if (GameMain.history.TechUnlocked(2307) && deliveryPackage.colCount < 5)
{
deliveryPackage.colCount = 5;
deliveryPackage.NotifySizeChange();
}
else if (GameMain.history.TechUnlocked(2304) && deliveryPackage.colCount < 4)
{
deliveryPackage.colCount = 4;
deliveryPackage.NotifySizeChange();
}
else if ((!GameMain.history.TechUnlocked(1608) && deliveryPackage.colCount < 3) || !deliveryPackage.unlocked)
{
deliveryPackage.colCount = 3;
if (!deliveryPackage.unlocked)
{
deliveryPackage.unlocked = true;
}
deliveryPackage.NotifySizeChange();
}
if (GameMain.history.TechUnlocked(2307))
{
stackSize = 5000;
if (GameMain.mainPlayer.package.size < 160)
{
GameMain.mainPlayer.package.SetSize(160);
}
}
else if (GameMain.history.TechUnlocked(2306))
{
stackSize = 4000;
if (GameMain.mainPlayer.package.size < 150)
{
GameMain.mainPlayer.package.SetSize(150);
}
}
else if (GameMain.history.TechUnlocked(2305))
{
stackSize = 3000;
if (GameMain.mainPlayer.package.size < 140)
{
GameMain.mainPlayer.package.SetSize(140);
}
}
else if (GameMain.history.TechUnlocked(2304))
{
stackSize = 2000;
if (GameMain.mainPlayer.package.size < 130)
{
GameMain.mainPlayer.package.SetSize(130);
}
}
else if (GameMain.history.TechUnlocked(2303))
{
stackSize = 1000;
if (GameMain.mainPlayer.package.size < 120)
{
GameMain.mainPlayer.package.SetSize(120);
}
}
else if (GameMain.history.TechUnlocked(2302))
{
stackSize = 500;
if (GameMain.mainPlayer.package.size < 110)
{
GameMain.mainPlayer.package.SetSize(110);
}
}
else if (GameMain.history.TechUnlocked(2301))
{
stackSize = 400;
if (GameMain.mainPlayer.package.size < 100)
{
GameMain.mainPlayer.package.SetSize(100);
}
}
else
{
stackSize = 300;
if (GameMain.mainPlayer.package.size < 90)
{
GameMain.mainPlayer.package.SetSize(90);
}
}
if (GameMain.history.TechUnlocked(3510))
{
GameMain.history.remoteStationExtraStorage = 40000;
}
else if (GameMain.history.TechUnlocked(3509))
{
GameMain.history.remoteStationExtraStorage = 15000;
}
}
private void CreateDeliveryPackageItemIndex()
{
//IL_0031: Unknown result type (might be due to invalid IL or missing references)
//IL_0036: 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)
//IL_004a: Unknown result type (might be due to invalid IL or missing references)
//IL_0061: Unknown result type (might be due to invalid IL or missing references)
//IL_0090: Unknown result type (might be due to invalid IL or missing references)
//IL_007b: Unknown result type (might be due to invalid IL or missing references)
//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
//IL_012b: Unknown result type (might be due to invalid IL or missing references)
//IL_0140: Unknown result type (might be due to invalid IL or missing references)
((BaseUnityPlugin)this).Logger.LogDebug((object)"CreateDeliveryPackageItemIndex");
deliveryPackageItems = new Dictionary<int, int>();
for (int i = 0; i < deliveryPackage.gridLength; i++)
{
GRID val = deliveryPackage.grids[i];
int num = Math.Min(val.recycleCount, ((GRID)(ref val)).stackSizeModified);
if (val.itemId <= 0)
{
continue;
}
if (!deliveryPackageItems.ContainsKey(val.itemId))
{
deliveryPackageItems.Add(val.itemId, i);
}
else
{
deliveryPackageItems[val.itemId] = i;
}
ItemProto val2 = ((ProtoSet<ItemProto>)(object)LDB.items).Select(val.itemId);
if (!val2.CanBuild && stackSize > val2.StackSize)
{
deliveryPackage.grids[i].stackSize = stackSize;
}
if (infItems.Value)
{
deliveryPackage.grids[i].count = num;
}
else
{
if (infVeins.Value && IsVein(val.itemId))
{
if (val.itemId == 1120)
{
num = (int)((float)num * 0.6f);
}
deliveryPackage.grids[i].count = num;
}
if (infBuildings.Value && val2.CanBuild)
{
deliveryPackage.grids[i].count = num;
}
if (infAmmo.Value && val2.isAmmo)
{
deliveryPackage.grids[i].count = num;
}
if (infFleet.Value && val2.isFighter)
{
deliveryPackage.grids[i].count = num;
}
}
SprayDeliveryPackageItem(i);
}
}
private void FindbattleBaseStorges()
{
((BaseUnityPlugin)this).Logger.LogDebug((object)"FindbattleBaseStorges");
battleBaseStorgeIDs = new HashSet<int>();
for (int num = GameMain.data.factories.Length - 1; num >= 0; num--)
{
PlanetFactory val = GameMain.data.factories[num];
if (val != null)
{
for (int num2 = val.defenseSystem.battleBases.buffer.Length - 1; num2 >= 0; num2--)
{
BattleBaseComponent val2 = val.defenseSystem.battleBases.buffer[num2];
if (val2 != null)
{
battleBaseStorgeIDs.Add(val2.storageId);
}
}
}
}
}
private bool HasItem(int itemId)
{
if (deliveryPackageItems.ContainsKey(itemId) && deliveryPackage.grids[deliveryPackageItems[itemId]].count > 0)
{
return true;
}
return false;
}
private static bool IsVein(int itemId)
{
//IL_0022: Unknown result type (might be due to invalid IL or missing references)
//IL_0028: Invalid comparison between Unknown and I4
int[] source = new int[4] { 1000, 1116, 1120, 1121 };
if (source.Contains(itemId) || (int)LDB.veins.GetVeinTypeByItemId(itemId) > 0)
{
return true;
}
return false;
}
private void SprayDeliveryPackageItem(int index)
{
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_0029: Unknown result type (might be due to invalid IL or missing references)
//IL_002a: Unknown result type (might be due to invalid IL or missing references)
//IL_0033: Unknown result type (might be due to invalid IL or missing references)
//IL_004b: Unknown result type (might be due to invalid IL or missing references)
//IL_0058: Unknown result type (might be due to invalid IL or missing references)
//IL_0065: Unknown result type (might be due to invalid IL or missing references)
//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
//IL_0114: Unknown result type (might be due to invalid IL or missing references)
//IL_0140: Unknown result type (might be due to invalid IL or missing references)
//IL_014e: Unknown result type (might be due to invalid IL or missing references)
if (!autoSpray.Value)
{
return;
}
GRID val = deliveryPackage.grids[index];
if (val.itemId <= 0 || val.count <= 0)
{
return;
}
if (val.itemId == 1141 || val.itemId == 1142 || val.itemId == 1143)
{
deliveryPackage.grids[index].inc = deliveryPackage.grids[index].count * 4;
return;
}
ItemProto val2 = ((ProtoSet<ItemProto>)(object)LDB.items).Select(val.itemId);
if (val2.CanBuild || val2.isFighter)
{
return;
}
if (!costProliferator.Value && val.inc < val.count * 4)
{
deliveryPackage.grids[index].inc = val.count * 4;
return;
}
foreach (var proliferator in proliferators)
{
int num = val.count * proliferator.Item2 - val.inc;
if (num <= 0)
{
break;
}
int inc = GetInc(proliferator.Item1, num);
if (inc > 0)
{
deliveryPackage.grids[index].inc += inc;
}
}
}
private void ProcessStorage(object? state)
{
//IL_01d2: Unknown result type (might be due to invalid IL or missing references)
//IL_01d7: Unknown result type (might be due to invalid IL or missing references)
//IL_01d9: Unknown result type (might be due to invalid IL or missing references)
//IL_01e2: Unknown result type (might be due to invalid IL or missing references)
//IL_01eb: Unknown result type (might be due to invalid IL or missing references)
//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
//IL_0204: Unknown result type (might be due to invalid IL or missing references)
//IL_020b: Unknown result type (might be due to invalid IL or missing references)
//IL_0212: Unknown result type (might be due to invalid IL or missing references)
//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
//IL_00d4: 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_00e2: Unknown result type (might be due to invalid IL or missing references)
((BaseUnityPlugin)this).Logger.LogDebug((object)"ProcessStorage");
try
{
for (int num = GameMain.data.factories.Length - 1; num >= 0; num--)
{
PlanetFactory val = GameMain.data.factories[num];
if (val != null)
{
StorageComponent[] storagePool = val.factoryStorage.storagePool;
foreach (StorageComponent val2 in storagePool)
{
if (val2 == null || val2.isEmpty || battleBaseStorgeIDs.Contains(val2.id))
{
continue;
}
for (int num2 = val2.grids.Length - 1; num2 >= 0; num2--)
{
GRID val3 = val2.grids[num2];
if (val3.itemId > 0 && val3.count > 0)
{
int[] array = AddItem(val3.itemId, val3.count, val3.inc, assembler: false);
if (array[0] != 0)
{
val2.grids[num2].count -= array[0];
val2.grids[num2].inc -= array[1];
if (val2.grids[num2].count <= 0)
{
val2.grids[num2].itemId = val2.grids[num2].filter;
}
}
}
}
val2.NotifyStorageChange();
}
for (int num3 = val.factoryStorage.tankPool.Length - 1; num3 >= 0; num3--)
{
TankComponent val4 = val.factoryStorage.tankPool[num3];
if (val4.id != 0 && val4.fluidId != 0 && val4.fluidCount != 0)
{
int[] array2 = AddItem(val4.fluidId, val4.fluidCount, val4.fluidInc, assembler: false);
val.factoryStorage.tankPool[num3].fluidCount -= array2[0];
val.factoryStorage.tankPool[num3].fluidInc -= array2[1];
if (val.factoryStorage.tankPool[num3].fluidCount <= 0)
{
val.factoryStorage.tankPool[num3].fluidId = 0;
val.factoryStorage.tankPool[num3].fluidInc = 0;
}
}
}
}
}
}
catch (Exception ex)
{
((BaseUnityPlugin)this).Logger.LogError((object)ex);
}
finally
{
taskState["ProcessStorage"] = true;
}
}
private void ProcessAssembler(object? state)
{
//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_0062: 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_0087: Unknown result type (might be due to invalid IL or missing references)
//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
//IL_0101: Unknown result type (might be due to invalid IL or missing references)
//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
//IL_0121: Unknown result type (might be due to invalid IL or missing references)
//IL_014f: Unknown result type (might be due to invalid IL or missing references)
//IL_0165: Unknown result type (might be due to invalid IL or missing references)
((BaseUnityPlugin)this).Logger.LogDebug((object)"ProcessAssembler");
try
{
for (int num = GameMain.data.factories.Length - 1; num >= 0; num--)
{
PlanetFactory val = GameMain.data.factories[num];
if (val != null)
{
AssemblerComponent[] assemblerPool = val.factorySystem.assemblerPool;
foreach (AssemblerComponent val2 in assemblerPool)
{
if (val2.id <= 0 || val2.recipeId <= 0)
{
continue;
}
int[] products = val2.recipeExecuteData.products;
for (int num2 = products.Length - 1; num2 >= 0; num2--)
{
if (val2.produced[num2] > 0)
{
val2.produced[num2] -= AddItem(products[num2], val2.produced[num2], 0)[0];
}
}
int[] requires = val2.recipeExecuteData.requires;
int[] requireCounts = val2.recipeExecuteData.requireCounts;
for (int num3 = requires.Length - 1; num3 >= 0; num3--)
{
int num4 = Math.Max(requireCounts[num3] * 5 - val2.served[num3], 0);
if (num4 > 0)
{
int[] array = TakeItem(requires[num3], num4);
val2.served[num3] += array[0];
val2.incServed[num3] += array[1];
}
}
}
}
}
}
catch (Exception ex)
{
((BaseUnityPlugin)this).Logger.LogError((object)ex);
}
finally
{
taskState["ProcessAssembler"] = true;
}
}
private void ProcessMiner(object? state)
{
//IL_0061: 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_0068: Unknown result type (might be due to invalid IL or missing references)
//IL_0072: 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)
//IL_0095: Unknown result type (might be due to invalid IL or missing references)
//IL_009c: Unknown result type (might be due to invalid IL or missing references)
//IL_01ea: Unknown result type (might be due to invalid IL or missing references)
//IL_01ef: Unknown result type (might be due to invalid IL or missing references)
//IL_01f1: Unknown result type (might be due to invalid IL or missing references)
//IL_01fb: Unknown result type (might be due to invalid IL or missing references)
//IL_0153: Unknown result type (might be due to invalid IL or missing references)
//IL_0158: Unknown result type (might be due to invalid IL or missing references)
//IL_015a: Unknown result type (might be due to invalid IL or missing references)
//IL_0205: Unknown result type (might be due to invalid IL or missing references)
//IL_0207: Unknown result type (might be due to invalid IL or missing references)
//IL_020d: Invalid comparison between Unknown and I4
//IL_0164: 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_0225: Unknown result type (might be due to invalid IL or missing references)
//IL_016e: Unknown result type (might be due to invalid IL or missing references)
//IL_0170: Unknown result type (might be due to invalid IL or missing references)
//IL_0176: Invalid comparison between Unknown and I4
//IL_0187: Unknown result type (might be due to invalid IL or missing references)
//IL_018e: Unknown result type (might be due to invalid IL or missing references)
((BaseUnityPlugin)this).Logger.LogDebug((object)"ProcessMiner");
try
{
for (int num = GameMain.data.factories.Length - 1; num >= 0; num--)
{
PlanetFactory val = GameMain.data.factories[num];
if (val != null)
{
for (int num2 = val.factorySystem.minerPool.Length - 1; num2 >= 0; num2--)
{
MinerComponent val2 = val.factorySystem.minerPool[num2];
if (val2.id > 0 && val2.productId > 0 && val2.productCount > 0)
{
int[] array = AddItem(val2.productId, val2.productCount, 0, assembler: false);
val.factorySystem.minerPool[num2].productCount -= array[0];
}
}
StationComponent[] stationPool = val.transport.stationPool;
foreach (StationComponent val3 in stationPool)
{
if (val3 == null || val3.id <= 0)
{
continue;
}
if (val3.isStellar && val3.isCollector)
{
for (int num3 = val3.storage.Length - 1; num3 >= 0; num3--)
{
StationStore val4 = val3.storage[num3];
if (val4.itemId > 0 && val4.count > 0 && (int)val4.remoteLogic == 1)
{
int[] array2 = AddItem(val4.itemId, val4.count, 0, assembler: false);
val3.storage[num3].count -= array2[0];
}
}
}
else if (val3.isVeinCollector)
{
StationStore val5 = val3.storage[0];
if (val5.itemId > 0 && val5.count > 0 && (int)val5.localLogic == 1)
{
int[] array3 = AddItem(val5.itemId, val5.count, 0, assembler: false);
val3.storage[0].count -= array3[0];
}
}
}
}
}
}
catch (Exception ex)
{
((BaseUnityPlugin)this).Logger.LogError((object)ex);
}
taskState["ProcessMiner"] = true;
}
private int ThermalPowerPlantFuel()
{
//IL_00a4: 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_00b8: Unknown result type (might be due to invalid IL or missing references)
//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
//IL_010a: Unknown result type (might be due to invalid IL or missing references)
((BaseUnityPlugin)this).Logger.LogDebug((object)"thermalPowerPlantFuel");
if (fuelId.Value != 0 && HasItem(fuelId.Value))
{
return fuelId.Value;
}
float num = 0f;
float num2 = 0f;
float num3 = 1f;
float num4 = 1f;
float num5 = 0f;
float num6 = 0f;
if (deliveryPackageItems.ContainsKey(1114))
{
GRID val = deliveryPackage.grids[deliveryPackageItems[1114]];
num3 += (float)((GRID)(ref val)).stackSizeModified;
num5 += (float)val.count;
}
if (deliveryPackageItems.ContainsKey(1120))
{
GRID val2 = deliveryPackage.grids[deliveryPackageItems[1120]];
num4 += (float)((GRID)(ref val2)).stackSizeModified;
num6 += (float)val2.count;
}
num = num5 / num3;
num2 = num6 / num4;
if (num >= num2 && (double)num > 0.6)
{
return 1114;
}
if (num2 >= num && (double)num2 > 0.6)
{
return 1120;
}
return 1006;
}
private void ProcessPowerGenerator(object? state)
{
//IL_0064: Unknown result type (might be due to invalid IL or missing references)
//IL_0069: Unknown result type (might be due to invalid IL or missing references)
//IL_006b: Unknown result type (might be due to invalid IL or missing references)
//IL_0083: Unknown result type (might be due to invalid IL or missing references)
//IL_019b: Unknown result type (might be due to invalid IL or missing references)
//IL_0094: 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_0135: Unknown result type (might be due to invalid IL or missing references)
//IL_021f: Unknown result type (might be due to invalid IL or missing references)
//IL_013f: Unknown result type (might be due to invalid IL or missing references)
//IL_0228: Unknown result type (might be due to invalid IL or missing references)
//IL_015b: Unknown result type (might be due to invalid IL or missing references)
//IL_0162: Unknown result type (might be due to invalid IL or missing references)
//IL_026f: Unknown result type (might be due to invalid IL or missing references)
//IL_0278: Unknown result type (might be due to invalid IL or missing references)
//IL_0290: Unknown result type (might be due to invalid IL or missing references)
((BaseUnityPlugin)this).Logger.LogDebug((object)"ProcessPowerGenerator");
try
{
for (int num = GameMain.data.factories.Length - 1; num >= 0; num--)
{
PlanetFactory val = GameMain.data.factories[num];
if (val != null)
{
for (int num2 = val.powerSystem.genPool.Length - 1; num2 >= 0; num2--)
{
PowerGeneratorComponent val2 = val.powerSystem.genPool[num2];
if (val2.id > 0)
{
if (val2.gamma)
{
if (val2.catalystPoint + val2.catalystIncPoint < 3600)
{
int[] array = TakeItem(1209, 3);
if (array[0] > 0)
{
val.powerSystem.genPool[num2].catalystId = 1209;
val.powerSystem.genPool[num2].catalystPoint += array[0] * 3600;
val.powerSystem.genPool[num2].catalystIncPoint += array[1] * 3600;
}
}
if (val2.productId > 0 && val2.productCount >= 1f)
{
int[] array2 = AddItem(val2.productId, (int)val2.productCount, 0);
val.powerSystem.genPool[num2].productCount -= array2[0];
}
}
else
{
int num3 = 0;
switch (val2.fuelMask)
{
case 1:
if (autoReplenishTPPFuel.Value)
{
num3 = ThermalPowerPlantFuel();
}
break;
case 2:
num3 = 1802;
break;
case 4:
num3 = ((!HasItem(1804)) ? 1803 : 1804);
break;
}
if (num3 != 0)
{
if (num3 != val2.fuelId && val2.fuelCount == 0)
{
int[] array3 = TakeItem(num3, 5);
((PowerGeneratorComponent)(ref val.powerSystem.genPool[num2])).SetNewFuel(num3, (short)array3[0], (short)array3[1]);
}
else if (num3 == val2.fuelId && val2.fuelCount < 5)
{
int[] array4 = TakeItem(num3, 5 - val2.fuelCount);
val.powerSystem.genPool[num2].fuelCount += (short)array4[0];
val.powerSystem.genPool[num2].fuelInc += (short)array4[1];
}
}
}
}
}
}
}
}
catch (Exception ex)
{
((BaseUnityPlugin)this).Logger.LogError((object)ex);
}
finally
{
taskState["ProcessPowerGenerator"] = true;
}
}
private void ProcessPowerExchanger(object? state)
{
//IL_0064: Unknown result type (might be due to invalid IL or missing references)
//IL_0069: Unknown result type (might be due to invalid IL or missing references)
//IL_006b: Unknown result type (might be due to invalid IL or missing references)
//IL_011d: Unknown result type (might be due to invalid IL or missing references)
//IL_0083: Unknown result type (might be due to invalid IL or missing references)
//IL_0135: Unknown result type (might be due to invalid IL or missing references)
//IL_00cd: 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_009d: Unknown result type (might be due to invalid IL or missing references)
//IL_017f: Unknown result type (might be due to invalid IL or missing references)
//IL_0147: Unknown result type (might be due to invalid IL or missing references)
//IL_014f: Unknown result type (might be due to invalid IL or missing references)
//IL_00df: Unknown result type (might be due to invalid IL or missing references)
//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
//IL_0191: Unknown result type (might be due to invalid IL or missing references)
//IL_0198: Unknown result type (might be due to invalid IL or missing references)
((BaseUnityPlugin)this).Logger.LogDebug((object)"ProcessPowerExchanger");
try
{
for (int num = GameMain.data.factories.Length - 1; num >= 0; num--)
{
PlanetFactory val = GameMain.data.factories[num];
if (val != null)
{
for (int num2 = val.powerSystem.excPool.Length - 1; num2 >= 0; num2--)
{
PowerExchangerComponent val2 = val.powerSystem.excPool[num2];
if (val2.targetState == -1f)
{
if (val2.fullCount < 3)
{
int[] array = TakeItem(val2.fullId, 3 - val2.fullCount);
val.powerSystem.excPool[num2].fullCount += (short)array[0];
}
if (val2.emptyCount > 0)
{
int[] array2 = AddItem(val2.emptyId, val2.emptyCount, 0);
val.powerSystem.excPool[num2].emptyCount -= (short)array2[0];
}
}
else if (val2.targetState == 1f)
{
if (val2.emptyCount < 5)
{
int[] array3 = TakeItem(val2.emptyId, 5 - val2.emptyCount);
val.powerSystem.excPool[num2].emptyCount += (short)array3[0];
}
if (val2.fullCount > 0)
{
int[] array4 = AddItem(val2.fullId, val2.fullCount, 0);
val.powerSystem.excPool[num2].fullCount -= (short)array4[0];
}
}
}
}
}
}
catch (Exception ex)
{
((BaseUnityPlugin)this).Logger.LogError((object)ex);
}
finally
{
taskState["ProcessPowerExchanger"] = true;
}
}
private void ProcessSilo(object? state)
{
//IL_0064: Unknown result type (might be due to invalid IL or missing references)
//IL_0069: Unknown result type (might be due to invalid IL or missing references)
//IL_006b: Unknown result type (might be due to invalid IL or missing references)
//IL_0075: 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)
((BaseUnityPlugin)this).Logger.LogDebug((object)"ProcessSilo");
try
{
for (int num = GameMain.data.factories.Length - 1; num >= 0; num--)
{
PlanetFactory val = GameMain.data.factories[num];
if (val != null)
{
for (int num2 = val.factorySystem.siloPool.Length - 1; num2 >= 0; num2--)
{
SiloComponent val2 = val.factorySystem.siloPool[num2];
if (val2.id > 0 && val2.bulletCount <= 3)
{
int[] array = TakeItem(val2.bulletId, 10);
val.factorySystem.siloPool[num2].bulletCount += array[0];
val.factorySystem.siloPool[num2].bulletInc += array[1];
}
}
}
}
}
catch (Exception ex)
{
((BaseUnityPlugin)this).Logger.LogError((object)ex);
}
finally
{
taskState["ProcessSilo"] = true;
}
}
private void ProcessEjector(object? state)
{
//IL_0064: Unknown result type (might be due to invalid IL or missing references)
//IL_0069: Unknown result type (might be due to invalid IL or missing references)
//IL_006b: Unknown result type (might be due to invalid IL or missing references)
//IL_0075: 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)
((BaseUnityPlugin)this).Logger.LogDebug((object)"ProcessEjector");
try
{
for (int num = GameMain.data.factories.Length - 1; num >= 0; num--)
{
PlanetFactory val = GameMain.data.factories[num];
if (val != null)
{
for (int num2 = val.factorySystem.ejectorPool.Length - 1; num2 >= 0; num2--)
{
EjectorComponent val2 = val.factorySystem.ejectorPool[num2];
if (val2.id > 0 && val2.bulletCount <= 5)
{
int[] array = TakeItem(val2.bulletId, 15);
val.factorySystem.ejectorPool[num2].bulletCount += array[0];
val.factorySystem.ejectorPool[num2].bulletInc += array[1];
}
}
}
}
}
catch (Exception ex)
{
((BaseUnityPlugin)this).Logger.LogError((object)ex);
}
finally
{
taskState["ProcessEjector"] = true;
}
}
private void ProcessLab(object? state)
{
//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_0062: Unknown result type (might be due to invalid IL or missing references)
//IL_007a: Unknown result type (might be due to invalid IL or missing references)
//IL_019c: Unknown result type (might be due to invalid IL or missing references)
//IL_008e: Unknown result type (might be due to invalid IL or missing references)
//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
//IL_0100: Unknown result type (might be due to invalid IL or missing references)
//IL_010e: Unknown result type (might be due to invalid IL or missing references)
//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
//IL_01d4: Unknown result type (might be due to invalid IL or missing references)
//IL_012e: Unknown result type (might be due to invalid IL or missing references)
//IL_0139: Unknown result type (might be due to invalid IL or missing references)
//IL_0155: Unknown result type (might be due to invalid IL or missing references)
//IL_016b: Unknown result type (might be due to invalid IL or missing references)
//IL_0211: Unknown result type (might be due to invalid IL or missing references)
//IL_022d: Unknown result type (might be due to invalid IL or missing references)
((BaseUnityPlugin)this).Logger.LogDebug((object)"ProcessLab");
try
{
for (int num = GameMain.data.factories.Length - 1; num >= 0; num--)
{
PlanetFactory val = GameMain.data.factories[num];
if (val != null)
{
LabComponent[] labPool = val.factorySystem.labPool;
foreach (LabComponent val2 in labPool)
{
if (val2.id <= 0)
{
continue;
}
if (val2.recipeId > 0)
{
int[] products = val2.recipeExecuteData.products;
for (int num2 = products.Length - 1; num2 >= 0; num2--)
{
if (val2.produced[num2] > 0)
{
int[] array = AddItem(products[num2], val2.produced[num2], 0);
val2.produced[num2] -= array[0];
}
}
int[] requires = val2.recipeExecuteData.requires;
int[] requireCounts = val2.recipeExecuteData.requireCounts;
for (int num3 = requires.Length - 1; num3 >= 0; num3--)
{
int count = requireCounts[num3] * 5 - val2.served[num3] - val2.incServed[num3];
int[] array2 = TakeItem(requires[num3], count);
val2.served[num3] += array2[0];
val2.incServed[num3] += array2[1];
}
}
else
{
if (!val2.researchMode)
{
continue;
}
for (int num4 = LabComponent.matrixPoints.Length - 1; num4 >= 0; num4--)
{
if (LabComponent.matrixPoints[num4] > 0 && val2.matrixServed[num4] < LabComponent.matrixPoints[num4] * 3600)
{
int[] array3 = TakeItem(LabComponent.matrixIds[num4], LabComponent.matrixPoints[num4]);
val2.matrixServed[num4] += array3[0] * 3600;
val2.matrixIncServed[num4] += array3[1] * 3600;
}
}
}
}
}
}
}
catch (Exception ex)
{
((BaseUnityPlugin)this).Logger.LogError((object)ex);
}
finally
{
taskState["ProcessLab"] = true;
}
}
private void ProcessTurret(object? state)
{
//IL_006e: Unknown result type (might be due to invalid IL or missing references)
//IL_0073: Unknown result type (might be due to invalid IL or missing references)
//IL_0075: Unknown result type (might be due to invalid IL or missing references)
//IL_007e: 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_0086: Invalid comparison between Unknown and I4
//IL_0088: Unknown result type (might be due to invalid IL or missing references)
//IL_008a: Unknown result type (might be due to invalid IL or missing references)
//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
//IL_0091: 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_00de: Unknown result type (might be due to invalid IL or missing references)
((BaseUnityPlugin)this).Logger.LogDebug((object)"ProcessTurret");
try
{
for (int num = GameMain.data.factories.Length - 1; num >= 0; num--)
{
PlanetFactory val = GameMain.data.factories[num];
if (val != null)
{
for (int num2 = val.defenseSystem.turrets.buffer.Length - 1; num2 >= 0; num2--)
{
TurretComponent val2 = val.defenseSystem.turrets.buffer[num2];
if (val2.id != 0 && (int)val2.type != 2 && (int)val2.ammoType != 0 && val2.itemCount <= 0 && val2.bulletCount <= 0)
{
foreach (int item in ammos[val2.ammoType])
{
int[] array = TakeItem(item, 50 - val2.itemCount);
if (array[0] != 0)
{
((TurretComponent)(ref val.defenseSystem.turrets.buffer[num2])).SetNewItem(item, (short)array[0], (short)array[1]);
break;
}
}
}
}
}
}
}
catch (Exception ex)
{
((BaseUnityPlugin)this).Logger.LogError((object)ex);
}
finally
{
taskState["ProcessTurret"] = true;
}
}
private void ProcessBattleBase(object? state)
{
//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
//IL_0108: Unknown result type (might be due to invalid IL or missing references)
//IL_015d: Unknown result type (might be due to invalid IL or missing references)
//IL_0162: Unknown result type (might be due to invalid IL or missing references)
//IL_0164: Unknown result type (might be due to invalid IL or missing references)
//IL_016e: Unknown result type (might be due to invalid IL or missing references)
//IL_0273: Unknown result type (might be due to invalid IL or missing references)
//IL_0278: Unknown result type (might be due to invalid IL or missing references)
//IL_027a: Unknown result type (might be due to invalid IL or missing references)
//IL_018a: Unknown result type (might be due to invalid IL or missing references)
//IL_0191: Unknown result type (might be due to invalid IL or missing references)
//IL_0198: Unknown result type (might be due to invalid IL or missing references)
//IL_0283: Unknown result type (might be due to invalid IL or missing references)
//IL_028a: Unknown result type (might be due to invalid IL or missing references)
//IL_0293: Unknown result type (might be due to invalid IL or missing references)
//IL_029a: Unknown result type (might be due to invalid IL or missing references)
//IL_02ae: Unknown result type (might be due to invalid IL or missing references)
//IL_02b5: Unknown result type (might be due to invalid IL or missing references)
//IL_02bc: Unknown result type (might be due to invalid IL or missing references)
((BaseUnityPlugin)this).Logger.LogDebug((object)"ProcessBattleBase");
try
{
int[] array = new int[3] { 5103, 5102, 5101 };
for (int num = GameMain.data.factories.Length - 1; num >= 0; num--)
{
PlanetFactory val = GameMain.data.factories[num];
if (val != null)
{
for (int num2 = val.defenseSystem.battleBases.buffer.Length - 1; num2 >= 0; num2--)
{
BattleBaseComponent val2 = val.defenseSystem.battleBases.buffer[num2];
if (val2 != null && val2.combatModule != null)
{
ModuleFleet val3 = val2.combatModule.moduleFleets[0];
for (int num3 = val3.fighters.Length - 1; num3 >= 0; num3--)
{
ModuleFighter val4 = val3.fighters[num3];
if (val4.count == 0)
{
int[] array2 = TakeItem(val4.itemId, 1);
if (array2[0] != 0)
{
((ModuleFleet)(ref val3)).AddFighterToPort(num3, val4.itemId);
break;
}
}
}
StorageComponent storage = val2.storage;
bool flag = false;
for (int num4 = storage.grids.Length - 1 - storage.bans; num4 >= 0; num4--)
{
GRID val5 = storage.grids[num4];
if (val5.itemId > 0 && val5.count > 0)
{
int[] array3 = AddItem(val5.itemId, val5.count, val5.inc, assembler: false);
if (array3[0] != 0)
{
flag = true;
storage.grids[num4].count -= array3[0];
storage.grids[num4].inc -= array3[1];
if (storage.grids[num4].count <= 0)
{
storage.grids[num4].itemId = storage.grids[num4].filter;
}
}
}
}
for (int i = storage.grids.Length - storage.bans; i < storage.grids.Length; i++)
{
GRID val6 = storage.grids[i];
if (val6.filter != 0 && val6.filter == val6.itemId && val6.count < val6.stackSize)
{
int[] array4 = TakeItem(val6.itemId, val6.stackSize - val6.count);
if (array4[0] != 0)
{
flag = true;
storage.grids[i].count += array4[0];
storage.grids[i].inc += array4[1];
}
}
}
if (flag)
{
storage.NotifyStorageChange();
}
}
}
}
}
}
catch (Exception ex)
{
((BaseUnityPlugin)this).Logger.LogError((object)ex);
}
taskState["ProcessBattleBase"] = true;
}
private void ClearBattleBase()
{
//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
//IL_00d8: 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)
((BaseUnityPlugin)this).Logger.LogDebug((object)"ClearBattleBase");
try
{
HashSet<int> enemyDropBans = GameMain.data.trashSystem.enemyDropBans;
for (int num = GameMain.data.factories.Length - 1; num >= 0; num--)
{
PlanetFactory val = GameMain.data.factories[num];
if (val != null)
{
for (int num2 = val.defenseSystem.battleBases.buffer.Length - 1; num2 >= 0; num2--)
{
BattleBaseComponent val2 = val.defenseSystem.battleBases.buffer[num2];
if (val2 != null && val2.storage != null)
{
StorageComponent storage = val2.storage;
if (!storage.isEmpty)
{
for (int num3 = storage.grids.Length - 1; num3 >= 0; num3--)
{
GRID val3 = storage.grids[num3];
if (enemyDropBans.Contains(val3.itemId))
{
storage.grids[num3].count = 0;
storage.grids[num3].inc = 0;
storage.grids[num3].itemId = storage.grids[num3].filter;
}
}
storage.NotifyStorageChange();
}
}
}
}
}
}
catch (Exception ex)
{
((BaseUnityPlugin)this).Logger.LogError((object)ex);
}
}
private void ProcessPackage(object? state)
{
//IL_0038: Unknown result type (might be due to invalid IL or missing references)
//IL_003d: Unknown result type (might be due to invalid IL or missing references)
//IL_003e: Unknown result type (might be due to invalid IL or missing references)
//IL_0046: 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_005f: Unknown result type (might be due to invalid IL or missing references)
//IL_0065: Unknown result type (might be due to invalid IL or missing references)
//IL_006b: Unknown result type (might be due to invalid IL or missing references)
((BaseUnityPlugin)this).Logger.LogDebug((object)"ProcessPackage");
try
{
bool flag = false;
StorageComponent package = GameMain.mainPlayer.package;
for (int num = package.grids.Length - 1; num >= 0; num--)
{
GRID val = package.grids[num];
if (val.filter != 0 && val.count < val.stackSize)
{
int[] array = TakeItem(val.itemId, val.stackSize - val.count);
if (array[0] != 0)
{
package.grids[num].count += array[0];
package.grids[num].inc += array[1];
flag = true;
}
}
}
if (flag)
{
package.NotifyStorageChange();
}
}
catch (Exception ex)
{
((BaseUnityPlugin)this).Logger.LogError((object)ex);
}
finally
{
taskState["ProcessPackage"] = true;
}
}
private int[] AddItem(int itemId, int count, int inc, bool assembler = true)
{
if (itemId <= 0 || count <= 0 || !deliveryPackageItems.ContainsKey(itemId))
{
return new int[2];
}
int num = deliveryPackageItems[itemId];
if (num < 0 || deliveryPackage.grids[num].itemId != itemId)
{
return new int[2];
}
int num2 = Math.Min(deliveryPackage.grids[num].recycleCount, ((GRID)(ref deliveryPackage.grids[num])).stackSizeModified);
if (!assembler && itemId == 1120)
{
num2 = (int)((float)Math.Min(deliveryPackage.grids[num].recycleCount, ((GRID)(ref deliveryPackage.grids[num])).stackSizeModified) * 0.6f);
}
int num3 = num2 - deliveryPackage.grids[num].count;
if (num3 <= 0)
{
return new int[2];
}
if (count <= num3)
{
deliveryPackage.grids[num].count += count;
deliveryPackage.grids[num].inc += inc;
SprayDeliveryPackageItem(num);
return new int[2] { count, inc };
}
deliveryPackage.grids[num].count = num2;
int num4 = SplitInc(count, inc, num3);
deliveryPackage.grids[num].inc += num4;
SprayDeliveryPackageItem(num);
return new int[2] { num3, num4 };
}
private int[] TakeItem(int itemId, int count)
{
if (itemId <= 0 || count <= 0 || !deliveryPackageItems.ContainsKey(itemId))
{
return new int[2];
}
int num = deliveryPackageItems[itemId];
if (num < 0 || deliveryPackage.grids[num].itemId != itemId)
{
return new int[2];
}
if (deliveryPackage.grids[num].count <= deliveryPackage.grids[num].requireCount)
{
return new int[2];
}
int num2 = deliveryPackage.grids[num].count - deliveryPackage.grids[num].requireCount;
if (count <= num2)
{
int num3 = SplitInc(deliveryPackage.grids[num].count, deliveryPackage.grids[num].inc, count);
deliveryPackage.grids[num].count -= count;
deliveryPackage.grids[num].inc -= num3;
return new int[2] { count, num3 };
}
int num4 = SplitInc(deliveryPackage.grids[num].count, deliveryPackage.grids[num].inc, num2);
deliveryPackage.grids[num].count -= num2;
deliveryPackage.grids[num].inc -= num4;
return new int[2] { num2, num4 };
}
private static int SplitInc(int count, int inc, int expectCount)
{
int num = inc / count;
int num2 = inc - num * count;
count -= expectCount;
int num3 = num2 - count;
int num4 = ((num3 > 0) ? (num * expectCount + num3) : (num * expectCount));
inc -= num4;
return num4;
}
private int GetInc(int proliferatorId, int count)
{
int num = 0;
int num2;
switch (proliferatorId)
{
case 1143:
num2 = 75;
break;
case 1142:
num2 = 30;
break;
case 1141:
num2 = 15;
break;
default:
return 0;
}
if (count <= 0)
{
return 0;
}
while (true)
{
if (incPool[proliferatorId] >= count)
{
incPool[proliferatorId] -= count;
return num + count;
}
num += incPool[proliferatorId];
count -= incPool[proliferatorId];
incPool[proliferatorId] = 0;
int[] array = TakeItem(proliferatorId, 600 / num2);
if (array[0] == 0)
{
break;
}
incPool[proliferatorId] = array[0] * num2;
}
return num;
}
}
}