using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Logging;
using CommonAPI;
using CommonAPI.Systems;
using CommonAPI.Systems.ModLocalization;
using FactoryLocator.Compat;
using FactoryLocator.UI;
using HarmonyLib;
using NebulaAPI;
using NebulaModel.Networking;
using NebulaModel.Packets.Warning;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.Events;
using UnityEngine.UI;
using xiaoye97;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyFileVersion("1.3.8")]
[assembly: AssemblyInformationalVersion("1.3.8")]
[assembly: AssemblyProduct("FactoryLocator")]
[assembly: AssemblyTitle("FactoryLocator")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.3.8.0")]
[module: UnverifiableCode]
namespace FactoryLocator
{
public class MainLogic
{
private readonly List<PlanetFactory> factories = new List<PlanetFactory>();
private readonly Dictionary<int, int> filterIds = new Dictionary<int, int>();
private readonly Dictionary<int, Color> filterColors = new Dictionary<int, Color>();
private readonly List<int> planetIds = new List<int>();
private readonly List<Vector3> localPos = new List<Vector3>();
private readonly List<int> detailIds = new List<int>();
private int state;
private readonly List<int> networkIds = new List<int>();
private readonly HashSet<int> tmp_ids = new HashSet<int>();
private bool isRecording;
private readonly Dictionary<int, HashSet<long>> hashDict = new Dictionary<int, HashSet<long>>();
private int tick;
private Vector2 windowPos = new Vector2(-300f, 250f);
private static readonly Color ORANGE = new Color(0.9906f, 0.5897f, 0.3691f, 0.7059f);
private static readonly Color CYAN = new Color(0.2821f, 0.7455f, 1f, 0.7059f);
private static readonly Color PINK = new Color(1f, 0.5f, 0.5f, 0.7059f);
private const int SIGNAL_BPERROR = 404;
private const int SIGNAL_NOSPRAY = 600;
private const int SIGNAL_NOINPUTBELT = 601;
private const int SIGNAL_NOOUTPUTBELT = 602;
public int SignalId { get; set; } = 401;
public int SetFactories(StarData star, PlanetData planet)
{
state = 0;
isRecording = false;
factories.Clear();
if (star != null)
{
PlanetData[] planets = star.planets;
foreach (PlanetData val in planets)
{
if (val?.factory != null)
{
factories.Add(val.factory);
}
}
}
else if (planet?.factory != null)
{
factories.Add(planet.factory);
}
List<float> list = new List<float>();
List<int> list2 = new List<int>();
networkIds.Clear();
foreach (PlanetFactory factory in factories)
{
if (factory.powerSystem == null)
{
continue;
}
for (int j = 1; j < factory.powerSystem.netCursor; j++)
{
PowerNetwork val2 = factory.powerSystem.netPool[j];
if (val2 != null && val2.id == j)
{
list.Add((float)val2.consumerRatio);
list2.Add(val2.consumers.Count);
networkIds.Add(j);
}
}
}
if (((ManualBehaviour)Plugin.mainWindow).active && Plugin.mainLogic == this)
{
Plugin.mainWindow.SetStatusTipText(list.ToArray(), list2.ToArray());
Plugin.mainWindow.SetPowerNetworkDropdownList((factories.Count == 1) ? networkIds : null);
}
return factories.Count;
}
public void GameTick()
{
if (isRecording && ((ManualBehaviour)UIRoot.instance.uiGame.signalPicker).active)
{
RecordAllSignal();
if (tick++ > 30)
{
tick = 0;
RecordToFilter();
UIRoot.instance.uiGame.signalPicker.RefreshIcons();
UIRoot.instance.uiGame.signalPicker.OnTypeButtonClick(UIRoot.instance.uiGame.signalPicker.currentType);
}
}
}
public void PickBuilding(int networkId)
{
//IL_0022: Unknown result type (might be due to invalid IL or missing references)
state = networkId;
RefreshBuilding(-1, state);
UIentryCount.OnOpen((ESignalType)1, filterIds);
UIItemPickerExtension.Popup(windowPos, (Action<ItemProto>)OnBuildingPickReturn, (Func<ItemProto, bool>)((ItemProto itemProto) => filterIds.ContainsKey(((Proto)itemProto).ID)));
UIRoot.instance.uiGame.itemPicker.OnTypeButtonClick(2);
}
public void OnBuildingPickReturn(ItemProto itemProto)
{
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
windowPos = UIRoot.instance.uiGame.itemPicker.pickerTrans.anchoredPosition;
if (itemProto != null)
{
int iD = ((Proto)itemProto).ID;
RefreshBuilding(iD, state);
WarningSystemPatch.AddWarningData(SignalId, iD, planetIds, localPos);
}
}
public void PickVein(int mode)
{
//IL_0022: Unknown result type (might be due to invalid IL or missing references)
state = mode;
RefreshVein(-1, state);
UIentryCount.OnOpen((ESignalType)1, filterIds);
UIItemPickerExtension.Popup(windowPos, (Action<ItemProto>)OnVeinPickReturn, true, (Func<ItemProto, bool>)((ItemProto itemProto) => filterIds.ContainsKey(((Proto)itemProto).ID)));
UIRoot.instance.uiGame.itemPicker.OnTypeButtonClick(1);
}
public void OnVeinPickReturn(ItemProto itemProto)
{
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
windowPos = UIRoot.instance.uiGame.itemPicker.pickerTrans.anchoredPosition;
if (itemProto != null)
{
int iD = ((Proto)itemProto).ID;
RefreshVein(iD, state);
WarningSystemPatch.AddWarningData(SignalId, iD, planetIds, localPos);
}
}
public void PickAssembler(int mode)
{
//IL_0027: Unknown result type (might be due to invalid IL or missing references)
state = mode;
RefreshAssemblers(-1, state);
UIentryCount.OnOpen((ESignalType)2, filterIds, filterColors);
UIRecipePickerExtension.Popup(windowPos, (Action<RecipeProto>)OnAssemblerPickReturn, (Func<RecipeProto, bool>)((RecipeProto recipeProto) => filterIds.ContainsKey(((Proto)recipeProto).ID)));
}
public void OnAssemblerPickReturn(RecipeProto recipeProto)
{
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
windowPos = UIRoot.instance.uiGame.recipePicker.pickerTrans.anchoredPosition;
if (recipeProto != null)
{
int iD = ((Proto)recipeProto).ID;
RefreshAssemblers(iD, state);
WarningSystemPatch.AddWarningData(SignalId, SignalProtoSet.SignalId((ESignalType)2, iD), planetIds, localPos);
}
}
public void PickWarning(int mode)
{
//IL_003c: Unknown result type (might be due to invalid IL or missing references)
state = mode;
if (mode == 1)
{
isRecording = true;
hashDict.Clear();
Log.Debug("Start recording");
}
RefreshSignal(-1);
UIentryCount.OnOpen((ESignalType)0, filterIds);
UISignalPickerExtension.Popup(windowPos, (Action<int>)OnWarningPickReturn, (Func<int, bool>)((int signalId) => filterIds.ContainsKey(signalId)));
UIRoot.instance.uiGame.signalPicker.OnTypeButtonClick(1);
}
public void OnWarningPickReturn(int signalId)
{
//IL_002e: 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)
if (isRecording)
{
isRecording = false;
Log.Debug("Stop recording");
}
windowPos = UIRoot.instance.uiGame.signalPicker.pickerTrans.anchoredPosition;
if (signalId > 0)
{
if (state == 0)
{
RefreshSignal(signalId);
}
else if (state == 1)
{
RecordToResult(signalId);
hashDict.Clear();
}
WarningSystemPatch.AddWarningData(SignalId, signalId, planetIds, localPos, detailIds);
}
}
public void PickStorage(int mode)
{
//IL_002e: Unknown result type (might be due to invalid IL or missing references)
state = mode;
if (mode == 0)
{
RefreshStorage(-1);
}
else
{
RefreshDispenser(-1, state);
}
UIentryCount.OnOpen((ESignalType)1, filterIds);
UIItemPickerExtension.Popup(windowPos, (Action<ItemProto>)OnStoragePickReturn, (Func<ItemProto, bool>)((ItemProto itemProto) => filterIds.ContainsKey(((Proto)itemProto).ID)));
}
public void OnStoragePickReturn(ItemProto itemProto)
{
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
windowPos = UIRoot.instance.uiGame.itemPicker.pickerTrans.anchoredPosition;
if (itemProto != null)
{
int iD = ((Proto)itemProto).ID;
if (state == 0)
{
RefreshStorage(iD);
}
else
{
RefreshDispenser(iD, state);
}
WarningSystemPatch.AddWarningData(SignalId, iD, planetIds, localPos);
}
}
public void PickStation(int mode)
{
//IL_0022: Unknown result type (might be due to invalid IL or missing references)
state = mode;
RefreshStation(-1, state);
UIentryCount.OnOpen((ESignalType)1, filterIds);
UIItemPickerExtension.Popup(windowPos, (Action<ItemProto>)OnStationPickReturn, (Func<ItemProto, bool>)((ItemProto itemProto) => filterIds.ContainsKey(((Proto)itemProto).ID)));
}
public void OnStationPickReturn(ItemProto itemProto)
{
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
windowPos = UIRoot.instance.uiGame.itemPicker.pickerTrans.anchoredPosition;
if (itemProto != null)
{
int iD = ((Proto)itemProto).ID;
RefreshStation(iD, state);
WarningSystemPatch.AddWarningData(SignalId, iD, planetIds, localPos);
}
}
public void RefreshBuilding(int itemId, int comboIndex = 0)
{
//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
//IL_00f7: 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_0106: Unknown result type (might be due to invalid IL or missing references)
filterIds.Clear();
localPos.Clear();
planetIds.Clear();
foreach (PlanetFactory factory in factories)
{
for (int i = 0; i < factory.entityCursor; i++)
{
if (i != factory.entityPool[i].id)
{
continue;
}
ref EntityData reference = ref factory.entityPool[i];
if (comboIndex != 0 && comboIndex <= networkIds.Count && networkIds[comboIndex - 1] != GetPowerNetworkId(factory, in reference))
{
continue;
}
if (itemId == -1)
{
int protoId = reference.protoId;
if (filterIds.ContainsKey(protoId))
{
Dictionary<int, int> dictionary = filterIds;
int key = protoId;
int value = dictionary[key] + 1;
dictionary[key] = value;
}
else
{
filterIds[protoId] = 1;
}
}
else if (itemId == reference.protoId)
{
localPos.Add(reference.pos + ((Vector3)(ref reference.pos)).normalized * 0.5f);
planetIds.Add(factory.planetId);
}
}
}
}
public static int GetPowerNetworkId(PlanetFactory factory, in EntityData entity)
{
if (entity.powerConId > 0)
{
return factory.powerSystem.consumerPool[entity.powerConId].networkId;
}
if (entity.powerNodeId > 0)
{
return factory.powerSystem.nodePool[entity.powerNodeId].networkId;
}
if (entity.powerGenId > 0)
{
return factory.powerSystem.genPool[entity.powerGenId].networkId;
}
if (entity.powerExcId > 0)
{
return factory.powerSystem.excPool[entity.powerExcId].networkId;
}
if (entity.powerAccId > 0)
{
return factory.powerSystem.accPool[entity.powerAccId].networkId;
}
return 0;
}
public void RefreshVein(int itemId, int mode = 0)
{
//IL_0022: 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_0032: Unknown result type (might be due to invalid IL or missing references)
//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
//IL_0184: Unknown result type (might be due to invalid IL or missing references)
//IL_0192: Unknown result type (might be due to invalid IL or missing references)
//IL_0110: Unknown result type (might be due to invalid IL or missing references)
//IL_0116: Invalid comparison between Unknown and I4
//IL_01b1: Unknown result type (might be due to invalid IL or missing references)
//IL_01c7: Unknown result type (might be due to invalid IL or missing references)
//IL_0133: Unknown result type (might be due to invalid IL or missing references)
//IL_013d: Expected I4, but got Unknown
filterIds.Clear();
localPos.Clear();
planetIds.Clear();
EVeinType val = (EVeinType)0;
if (itemId > 0)
{
val = LDB.veins.GetVeinTypeByItemId(itemId);
}
foreach (PlanetFactory factory in factories)
{
if (mode != 0)
{
tmp_ids.Clear();
for (int i = 1; i < factory.veinPool.Length; i++)
{
if (factory.veinPool[i].id == i && factory.veinPool[i].minerCount != 0)
{
tmp_ids.Add(factory.veinPool[i].groupIndex);
}
}
}
for (int j = 1; j < factory.veinGroups.Length; j++)
{
if ((int)factory.veinGroups[j].type == 0 || (mode == 1 && !tmp_ids.Contains(j)) || (mode == 2 && tmp_ids.Contains(j)))
{
continue;
}
if (itemId == -1)
{
int num = (((int)factory.veinGroups[j].type != 7) ? ((ProtoSet<VeinProto>)(object)LDB.veins).Select((int)factory.veinGroups[j].type).MiningItem : 1007);
if (filterIds.ContainsKey(num))
{
Dictionary<int, int> dictionary = filterIds;
int key = num;
int value = dictionary[key] + 1;
dictionary[key] = value;
}
else
{
filterIds[num] = 1;
}
}
else if (val == factory.veinGroups[j].type)
{
localPos.Add(((Vector3)(ref factory.veinGroups[j].pos)).normalized * (factory.planet.realRadius + 0.5f));
planetIds.Add(factory.planetId);
}
}
}
}
public void RefreshAssemblers(int recipeId, int mode = 0)
{
//IL_0132: 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_0102: Unknown result type (might be due to invalid IL or missing references)
//IL_011a: 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_00a6: Unknown result type (might be due to invalid IL or missing references)
//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
//IL_02f2: Unknown result type (might be due to invalid IL or missing references)
//IL_02be: Unknown result type (might be due to invalid IL or missing references)
//IL_02c0: Unknown result type (might be due to invalid IL or missing references)
//IL_01ac: Unknown result type (might be due to invalid IL or missing references)
//IL_01b8: Unknown result type (might be due to invalid IL or missing references)
//IL_01c2: Unknown result type (might be due to invalid IL or missing references)
//IL_01c7: Unknown result type (might be due to invalid IL or missing references)
//IL_02d9: Unknown result type (might be due to invalid IL or missing references)
//IL_0295: Unknown result type (might be due to invalid IL or missing references)
//IL_0261: Unknown result type (might be due to invalid IL or missing references)
//IL_0263: Unknown result type (might be due to invalid IL or missing references)
//IL_027c: Unknown result type (might be due to invalid IL or missing references)
//IL_036f: Unknown result type (might be due to invalid IL or missing references)
//IL_037b: Unknown result type (might be due to invalid IL or missing references)
//IL_0385: Unknown result type (might be due to invalid IL or missing references)
//IL_038a: Unknown result type (might be due to invalid IL or missing references)
filterIds.Clear();
filterColors.Clear();
localPos.Clear();
planetIds.Clear();
foreach (PlanetFactory factory in factories)
{
for (int i = 1; i < factory.factorySystem.assemblerCursor; i++)
{
ref AssemblerComponent reference = ref factory.factorySystem.assemblerPool[i];
if (i != reference.id || (mode >= 3 && mode != GetAssemblerWorkingStatus(in reference)))
{
continue;
}
if (reference.productive && !reference.forceAccMode)
{
if (mode == 2)
{
continue;
}
if (filterColors.TryGetValue(reference.recipeId, out var value) && value != CYAN)
{
filterColors[reference.recipeId] = PINK;
}
else
{
filterColors[reference.recipeId] = CYAN;
}
}
else
{
if (mode == 1)
{
continue;
}
if (filterColors.TryGetValue(reference.recipeId, out var value2) && value2 != ORANGE)
{
filterColors[reference.recipeId] = PINK;
}
else
{
filterColors[reference.recipeId] = ORANGE;
}
}
if (recipeId == -1)
{
int recipeId2 = reference.recipeId;
if (filterIds.ContainsKey(recipeId2))
{
Dictionary<int, int> dictionary = filterIds;
int key = recipeId2;
int value3 = dictionary[key] + 1;
dictionary[key] = value3;
}
else
{
filterIds[recipeId2] = 1;
}
}
else if (recipeId == reference.recipeId)
{
ref EntityData reference2 = ref factory.entityPool[reference.entityId];
localPos.Add(reference2.pos + ((Vector3)(ref reference2.pos)).normalized * 0.5f);
planetIds.Add(factory.planetId);
}
}
for (int j = 1; j < factory.factorySystem.labCursor; j++)
{
ref LabComponent reference3 = ref factory.factorySystem.labPool[j];
if (j != reference3.id || (mode >= 3 && mode != GetLabWorkingStatus(in reference3)))
{
continue;
}
if (reference3.productive && !reference3.forceAccMode)
{
if (mode == 2)
{
continue;
}
if (filterColors.TryGetValue(reference3.recipeId, out var value4) && value4 != CYAN)
{
filterColors[reference3.recipeId] = PINK;
}
else
{
filterColors[reference3.recipeId] = CYAN;
}
}
else
{
if (mode == 1)
{
continue;
}
if (filterColors.TryGetValue(reference3.recipeId, out var value5) && value5 != ORANGE)
{
filterColors[reference3.recipeId] = PINK;
}
else
{
filterColors[reference3.recipeId] = ORANGE;
}
}
if (recipeId == -1)
{
int recipeId3 = reference3.recipeId;
if (filterIds.ContainsKey(recipeId3))
{
Dictionary<int, int> dictionary2 = filterIds;
int value3 = recipeId3;
int key = dictionary2[value3] + 1;
dictionary2[value3] = key;
}
else
{
filterIds[recipeId3] = 1;
}
}
else if (recipeId == reference3.recipeId)
{
ref EntityData reference4 = ref factory.entityPool[reference3.entityId];
localPos.Add(reference4.pos + ((Vector3)(ref reference4.pos)).normalized * 0.5f);
planetIds.Add(factory.planetId);
}
}
}
}
public static int GetAssemblerWorkingStatus(in AssemblerComponent assembler)
{
if (assembler.replicating)
{
return 0;
}
if (assembler.time >= assembler.timeSpend)
{
return 4;
}
for (int i = 0; i < assembler.requireCounts.Length; i++)
{
if (assembler.served[i] < assembler.requireCounts[i])
{
return 3;
}
}
return -1;
}
public static int GetLabWorkingStatus(in LabComponent lab)
{
if (lab.replicating)
{
return 0;
}
if (lab.time >= lab.timeSpend)
{
return 4;
}
for (int i = 0; i < lab.requireCounts.Length; i++)
{
if (lab.served[i] < lab.requireCounts[i])
{
return 3;
}
}
return -1;
}
public void RefreshSignal(int signalId)
{
//IL_0110: Unknown result type (might be due to invalid IL or missing references)
//IL_0126: Unknown result type (might be due to invalid IL or missing references)
//IL_0130: 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_0250: Unknown result type (might be due to invalid IL or missing references)
//IL_025c: Unknown result type (might be due to invalid IL or missing references)
//IL_0266: Unknown result type (might be due to invalid IL or missing references)
//IL_026b: Unknown result type (might be due to invalid IL or missing references)
//IL_0347: Unknown result type (might be due to invalid IL or missing references)
//IL_0353: Unknown result type (might be due to invalid IL or missing references)
//IL_0359: Invalid comparison between Unknown and I4
//IL_03b6: Unknown result type (might be due to invalid IL or missing references)
filterIds.Clear();
localPos.Clear();
planetIds.Clear();
detailIds.Clear();
foreach (PlanetFactory factory in factories)
{
int entityCursor = factory.entityCursor;
for (int i = 1; i < entityCursor; i++)
{
if (i != factory.entityPool[i].id)
{
continue;
}
if (signalId == -1)
{
if (factory.entitySignPool[i].signType != 0)
{
int num = (int)(factory.entitySignPool[i].signType + 500);
if (filterIds.ContainsKey(num))
{
Dictionary<int, int> dictionary = filterIds;
int key = num;
int value = dictionary[key] + 1;
dictionary[key] = value;
}
else
{
filterIds[num] = 1;
}
}
}
else if (signalId == (int)(factory.entitySignPool[i].signType + 500))
{
localPos.Add(factory.entityPool[i].pos + ((Vector3)(ref factory.entityPool[i].pos)).normalized * 0.5f);
detailIds.Add(factory.entityPool[i].protoId);
planetIds.Add(factory.planetId);
}
}
entityCursor = factory.cargoTraffic.spraycoaterCursor;
for (int j = 1; j < entityCursor; j++)
{
ref SpraycoaterComponent reference = ref factory.cargoTraffic.spraycoaterPool[j];
if (j != reference.id)
{
continue;
}
int num2 = 0;
if (reference.incBeltId == 0)
{
num2 = 601;
}
else if (reference.cargoBeltId == 0)
{
num2 = 602;
}
else if (reference.incCount == 0)
{
num2 = 600;
}
if (num2 == 0)
{
continue;
}
if (signalId == -1)
{
if (filterIds.ContainsKey(num2))
{
Dictionary<int, int> dictionary2 = filterIds;
int value = num2;
int key = dictionary2[value] + 1;
dictionary2[value] = key;
}
else
{
filterIds[num2] = 1;
}
}
else if (signalId == num2)
{
ref EntityData reference2 = ref factory.entityPool[reference.entityId];
localPos.Add(reference2.pos + ((Vector3)(ref reference2.pos)).normalized * 0.5f);
detailIds.Add(reference2.protoId);
planetIds.Add(factory.planetId);
}
}
}
if (factories.Count != 1 || factories[0] != GameMain.localPlanet?.factory)
{
return;
}
Player mainPlayer = GameMain.mainPlayer;
BuildTool_BlueprintPaste val = ((mainPlayer == null) ? null : mainPlayer.controller?.actionBuild?.blueprintPasteTool);
if (val == null)
{
return;
}
int id = GameMain.localPlanet.id;
for (int k = 0; k < val.bpCursor; k++)
{
BuildPreview val2 = val.bpPool[k];
if ((int)val2.condition == 0 || (int)val2.condition == 2)
{
continue;
}
int num3 = 404;
if (signalId == -1)
{
if (filterIds.ContainsKey(num3))
{
Dictionary<int, int> dictionary3 = filterIds;
int key = num3;
int value = dictionary3[key] + 1;
dictionary3[key] = value;
}
else
{
filterIds[num3] = 1;
}
}
else if (signalId == num3)
{
localPos.Add(val2.lpos);
detailIds.Add(((Proto)(val2.item?)).ID ?? 0);
planetIds.Add(id);
}
}
}
public void RecordAllSignal()
{
foreach (PlanetFactory factory in factories)
{
int entityCursor = factory.entityCursor;
for (int i = 1; i < entityCursor; i++)
{
if (factory.entitySignPool[i].signType != 0)
{
int key = (int)(factory.entitySignPool[i].signType + 500);
long item = ((long)factory.index << 32) | i;
if (!hashDict.TryGetValue(key, out var value))
{
value = new HashSet<long>();
hashDict.Add(key, value);
}
value.Add(item);
}
}
entityCursor = factory.cargoTraffic.spraycoaterCursor;
for (int j = 1; j < entityCursor; j++)
{
ref SpraycoaterComponent reference = ref factory.cargoTraffic.spraycoaterPool[j];
if (j != reference.id)
{
continue;
}
int num = 0;
if (reference.incBeltId == 0)
{
num = 601;
}
else if (reference.cargoBeltId == 0)
{
num = 602;
}
else if (reference.incCount == 0)
{
num = 600;
}
if (num != 0)
{
long item2 = ((long)factory.index << 32) | reference.entityId;
if (!hashDict.TryGetValue(num, out var value2))
{
value2 = new HashSet<long>();
hashDict.Add(num, value2);
}
value2.Add(item2);
}
}
}
}
public void RecordToFilter()
{
filterIds.Clear();
foreach (KeyValuePair<int, HashSet<long>> item in hashDict)
{
filterIds[item.Key] = item.Value.Count;
}
}
public void RecordToResult(int signalId)
{
//IL_0083: Unknown result type (might be due to invalid IL or missing references)
//IL_008f: Unknown result type (might be due to invalid IL or missing references)
//IL_0099: Unknown result type (might be due to invalid IL or missing references)
//IL_009e: Unknown result type (might be due to invalid IL or missing references)
localPos.Clear();
planetIds.Clear();
detailIds.Clear();
if (!hashDict.TryGetValue(signalId, out var value))
{
return;
}
foreach (long item in value)
{
int num = (int)(item >> 32);
int num2 = (int)(item & 0xFFFFFFFFu);
PlanetFactory val = GameMain.data.factories[num];
if (val != null && num2 < val.entityCursor)
{
ref EntityData reference = ref val.entityPool[num2];
localPos.Add(reference.pos + ((Vector3)(ref reference.pos)).normalized * 0.5f);
detailIds.Add(reference.protoId);
planetIds.Add(val.planetId);
}
}
}
public void RefreshStorage(int itemId)
{
//IL_0271: Unknown result type (might be due to invalid IL or missing references)
//IL_027d: Unknown result type (might be due to invalid IL or missing references)
//IL_0287: Unknown result type (might be due to invalid IL or missing references)
//IL_028c: 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_016e: Unknown result type (might be due to invalid IL or missing references)
//IL_0178: Unknown result type (might be due to invalid IL or missing references)
//IL_017d: Unknown result type (might be due to invalid IL or missing references)
filterIds.Clear();
localPos.Clear();
planetIds.Clear();
foreach (PlanetFactory factory in factories)
{
for (int i = 1; i < factory.factoryStorage.storageCursor; i++)
{
StorageComponent val = factory.factoryStorage.storagePool[i];
if (val == null || val.id != i)
{
continue;
}
if (itemId == -1)
{
for (int j = 0; j < val.size; j++)
{
if (val.grids[j].count > 0)
{
int itemId2 = val.grids[j].itemId;
if (!filterIds.ContainsKey(itemId2))
{
filterIds[itemId2] = val.grids[j].count;
}
else
{
filterIds[itemId2] += val.grids[j].count;
}
}
}
continue;
}
bool flag = false;
for (int k = 0; k < val.size; k++)
{
if (val.grids[k].itemId == itemId && val.grids[k].count > 0)
{
ref EntityData reference = ref factory.entityPool[val.entityId];
localPos.Add(reference.pos + ((Vector3)(ref reference.pos)).normalized * 0.5f);
planetIds.Add(factory.planetId);
flag = true;
}
if (flag)
{
break;
}
}
}
for (int l = 1; l < factory.factoryStorage.tankCursor; l++)
{
ref TankComponent reference2 = ref factory.factoryStorage.tankPool[l];
if (reference2.id != l)
{
continue;
}
if (itemId == -1)
{
int fluidId = reference2.fluidId;
if (filterIds.ContainsKey(fluidId))
{
filterIds[fluidId] += reference2.fluidCount;
}
else
{
filterIds[fluidId] = reference2.fluidCount;
}
}
else if (itemId == reference2.fluidId)
{
ref EntityData reference3 = ref factory.entityPool[reference2.entityId];
localPos.Add(reference3.pos + ((Vector3)(ref reference3.pos)).normalized * 0.5f);
planetIds.Add(factory.planetId);
}
}
}
}
public void RefreshDispenser(int itemId, int mode = 0)
{
//IL_0071: Unknown result type (might be due to invalid IL or missing references)
//IL_0077: Invalid comparison between Unknown and I4
//IL_0083: Unknown result type (might be due to invalid IL or missing references)
//IL_0089: Invalid comparison between Unknown and I4
//IL_01c7: Unknown result type (might be due to invalid IL or missing references)
//IL_01d3: Unknown result type (might be due to invalid IL or missing references)
//IL_01dd: 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)
filterIds.Clear();
localPos.Clear();
planetIds.Clear();
foreach (PlanetFactory factory in factories)
{
for (int i = 1; i < factory.transport.dispenserCursor; i++)
{
DispenserComponent val = factory.transport.dispenserPool[i];
if (val == null || val.id != i || val.storage == null)
{
continue;
}
switch (mode)
{
case 1:
if ((int)val.storageMode != 2)
{
continue;
}
break;
case 2:
if ((int)val.storageMode != 1)
{
continue;
}
break;
}
if (itemId == -1)
{
if (!filterIds.ContainsKey(val.filter))
{
filterIds[val.filter] = 0;
}
int num = 0;
StorageComponent val2 = val.storage.topStorage;
while (val2 != null)
{
for (int j = 0; j < val2.size; j++)
{
if (val2.grids[j].itemId <= 0)
{
continue;
}
int itemId2 = val2.grids[j].itemId;
if (itemId2 == val.filter)
{
if (!filterIds.ContainsKey(itemId2))
{
filterIds[itemId2] = val2.grids[j].count;
}
else
{
filterIds[itemId2] += val2.grids[j].count;
}
}
}
val2 = val2.previousStorage;
if (num++ > 50)
{
break;
}
}
}
else if (val.filter == itemId)
{
ref EntityData reference = ref factory.entityPool[val.entityId];
localPos.Add(reference.pos + ((Vector3)(ref reference.pos)).normalized * 0.5f);
planetIds.Add(factory.planetId);
}
}
}
}
public void RefreshStation(int itemId, int mode = 0)
{
//IL_0191: Unknown result type (might be due to invalid IL or missing references)
//IL_019d: Unknown result type (might be due to invalid IL or missing references)
//IL_01a7: Unknown result type (might be due to invalid IL or missing references)
//IL_01ac: Unknown result type (might be due to invalid IL or missing references)
filterIds.Clear();
localPos.Clear();
planetIds.Clear();
foreach (PlanetFactory factory in factories)
{
for (int i = 1; i < factory.transport.stationCursor; i++)
{
StationComponent val = factory.transport.stationPool[i];
if (val == null || val.id != i || val.storage == null)
{
continue;
}
switch (mode)
{
case 1:
if (val.gid > 0)
{
continue;
}
break;
case 2:
if (val.gid <= 0)
{
continue;
}
break;
}
if (itemId == -1)
{
for (int j = 0; j < val.storage.Length; j++)
{
if (TestStationStore(in val.storage[j], mode))
{
int itemId2 = val.storage[j].itemId;
if (filterIds.ContainsKey(itemId2))
{
filterIds[itemId2] += val.storage[j].count;
}
else
{
filterIds[itemId2] = val.storage[j].count;
}
}
}
continue;
}
bool flag = false;
for (int k = 0; k < val.storage.Length; k++)
{
if (val.storage[k].itemId == itemId && TestStationStore(in val.storage[k], mode))
{
ref EntityData reference = ref factory.entityPool[val.entityId];
localPos.Add(reference.pos + ((Vector3)(ref reference.pos)).normalized * 0.5f);
planetIds.Add(factory.planetId);
flag = true;
}
if (flag)
{
break;
}
}
}
}
}
public static bool TestStationStore(in StationStore store, int mode)
{
//IL_001b: Unknown result type (might be due to invalid IL or missing references)
//IL_0021: Invalid comparison between Unknown and I4
//IL_0025: Unknown result type (might be due to invalid IL or missing references)
//IL_002b: Invalid comparison between Unknown and I4
//IL_002f: Unknown result type (might be due to invalid IL or missing references)
//IL_0035: Invalid comparison between Unknown and I4
//IL_0039: Unknown result type (might be due to invalid IL or missing references)
//IL_003f: Invalid comparison between Unknown and I4
return mode switch
{
3 => (int)store.localLogic == 2,
4 => (int)store.localLogic == 1,
5 => (int)store.remoteLogic == 2,
6 => (int)store.remoteLogic == 1,
_ => true,
};
}
}
[BepInPlugin("starfi5h.plugin.FactoryLocator", "FactoryLocator", "1.3.8")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[CommonAPISubmoduleDependency(new string[] { "LocalizationModule", "CustomKeyBindSystem", "PickerExtensionsSystem" })]
public class Plugin : BaseUnityPlugin
{
public const string GUID = "starfi5h.plugin.FactoryLocator";
public const string NAME = "FactoryLocator";
public const string VERSION = "1.3.8";
public static UILocatorWindow mainWindow;
public static MainLogic mainLogic;
public static Harmony harmony;
public void Awake()
{
//IL_0010: Unknown result type (might be due to invalid IL or missing references)
//IL_001a: Expected O, but got Unknown
//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_006a: Unknown result type (might be due to invalid IL or missing references)
//IL_008f: Unknown result type (might be due to invalid IL or missing references)
Log.LogSource = ((BaseUnityPlugin)this).Logger;
harmony = new Harmony("starfi5h.plugin.FactoryLocator");
harmony.PatchAll(typeof(WarningSystemPatch));
harmony.PatchAll(typeof(UIentryCount));
harmony.PatchAll(typeof(Plugin));
BuiltinKey val = default(BuiltinKey);
val.key = new CombineKey(102, (byte)2, (ECombineKeyAction)0, false);
val.conflictGroup = 2052;
val.name = "ShowFactoryLocator";
val.canOverride = true;
CustomKeyBindSystem.RegisterKeyBind<PressKeyBind>(val);
RegisterTranslation("KEYShowFactoryLocator", "Show Factory Locator Window", "打开FactoryLocator窗口");
RegisterTranslation("Building", "Building", "建筑");
RegisterTranslation("Vein", "Vein", "矿脉");
RegisterTranslation("Recipe", "Recipe", "配方");
RegisterTranslation("Warning", "Warning", "警报");
RegisterTranslation("Storage", "Storage", "储物仓");
RegisterTranslation("Station", "Station", "物流塔");
RegisterTranslation("Signal Icon", "Signal Icon", "信号图标");
RegisterTranslation("Clear All", "Clear All", "清空");
RegisterTranslation("Display All Warning", "Display All Warning", "显示所有警报提示");
RegisterTranslation("Auto Clear Query", "Auto Clear Query", "自动清除搜寻结果");
RegisterTranslation("Power Network Status", "Power Network Status", "电网状态");
RegisterTranslation("Satisfaction - Consumer Count", "Satisfaction - Consumer Count", "供电率 - 消耗者数量");
RegisterTranslation("All", "All", "全部");
RegisterTranslation("Recording Mode", "Recording Mode", "持续记录模式");
BetterWarningIconsCompat.Preload();
}
[HarmonyPostfix]
[HarmonyPatch(typeof(VFPreload), "InvokeOnLoadWorkEnded")]
internal static void Init()
{
if (mainLogic == null)
{
Log.Debug("Initing...");
mainLogic = new MainLogic();
mainWindow = UILocatorWindow.CreateWindow();
NebulaCompat.Init();
DSPMoreRecipesCompat.Init();
GenesisBookCompat.Init();
BetterWarningIconsCompat.Postload();
try
{
AddUIWindowDrag(((Component)UIRoot.instance.uiGame.signalPicker).gameObject);
AddUIWindowDrag(((Component)UIRoot.instance.uiGame.recipePicker).gameObject);
AddUIWindowDrag(((Component)UIRoot.instance.uiGame.itemPicker).gameObject);
}
catch (Exception ex)
{
Log.Error("Error when adding UIWindowDrag\n" + ex);
}
}
}
private static void AddUIWindowDrag(GameObject gameObject)
{
GameObject val = Object.Instantiate<GameObject>(GameObject.Find("UI Root/Overlay Canvas/In Game/Windows/FactoryLocator Window/panel-bg/drag-trigger"), gameObject.transform.Find("bg"));
UIWindowDrag obj = gameObject.AddComponent<UIWindowDrag>();
obj.dragTrigger = val.GetComponent<EventTrigger>();
obj.screenRect = GameObject.Find("UI Root/Overlay Canvas/In Game/Windows").GetComponent<RectTransform>();
Object.Destroy((Object)(object)val.GetComponent<UIBlockZone>());
}
private static void RegisterTranslation(string key, string enTrans, string cnTrans)
{
LocalizationModule.RegisterTranslation(key, enTrans, cnTrans, enTrans);
}
public void Update()
{
if (CustomKeyBindSystem.GetKeyBind("ShowFactoryLocator").keyValue)
{
if (!((ManualBehaviour)mainWindow).active)
{
mainWindow.OpenWindow();
InspectItemUnderMouse();
}
else
{
((ManualBehaviour)mainWindow)._Close();
}
}
else if ((Object)(object)mainWindow != (Object)null && ((ManualBehaviour)mainWindow).active)
{
((ManualBehaviour)mainWindow)._OnUpdate();
if (VFInput.escape && !UIentryCount.Active)
{
VFInput.UseEscape();
((ManualBehaviour)mainWindow)._Close();
}
}
}
private static void InspectItemUnderMouse()
{
int num = Util.RecipeIdUnderMouse();
if (num > 0)
{
Log.Debug("RecipeIdUnderMouse: " + num);
mainLogic.OnAssemblerPickReturn(((ProtoSet<RecipeProto>)(object)LDB.recipes).Select(num));
return;
}
int num2 = Util.ItemIdHintUnderMouse();
if (num2 > 0)
{
Log.Debug("ItemIdHintUnderMouse: " + num);
mainLogic.OnStoragePickReturn(((ProtoSet<ItemProto>)(object)LDB.items).Select(num2));
mainLogic.OnStationPickReturn(((ProtoSet<ItemProto>)(object)LDB.items).Select(num2));
}
}
public void OnDestroy()
{
harmony.UnpatchSelf();
if ((Object)(object)mainWindow != (Object)null)
{
Object.Destroy((Object)(object)((Component)mainWindow).gameObject);
mainWindow = null;
}
UIentryCount.OnDestory();
}
}
public static class Log
{
public static ManualLogSource LogSource;
public static void Error(object obj)
{
LogSource.LogError(obj);
}
public static void Warn(object obj)
{
LogSource.LogWarning(obj);
}
public static void Info(object obj)
{
LogSource.LogInfo(obj);
}
public static void Debug(object obj)
{
LogSource.LogDebug(obj);
}
}
public class UIentryCount
{
private static Dictionary<int, int> filterIds;
private static Dictionary<int, Color> colorMap;
private static Text[] countArray;
private const int ARRAYLENGTH = 112;
public static int ItemCol { get; set; } = 14;
public static int RecipeCol { get; set; } = 14;
public static int SignalCol { get; set; } = 14;
public static bool Active { get; private set; }
public static void OnOpen(ESignalType signalType, Dictionary<int, int> filters, Dictionary<int, Color> numberColors = null)
{
//IL_002e: Unknown result type (might be due to invalid IL or missing references)
filterIds = filters;
colorMap = numberColors;
if (countArray == null)
{
countArray = (Text[])(object)new Text[112];
}
for (int i = 0; i < 112; i++)
{
Init(ref countArray[i], signalType, i);
}
Active = true;
UIItemPicker.showAll = true;
}
[HarmonyPostfix]
[HarmonyPatch(typeof(UIItemPicker), "_OnClose")]
[HarmonyPatch(typeof(UIRecipePicker), "_OnClose")]
[HarmonyPatch(typeof(UISignalPicker), "_OnClose")]
public static void OnClose()
{
//IL_0027: Unknown result type (might be due to invalid IL or missing references)
//IL_002c: 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)
if (Active && countArray != null)
{
Color color = ((Graphic)UIRoot.instance.uiGame.warningWindow.itemPrefab.countText).color;
for (int i = 0; i < 112; i++)
{
((Component)countArray[i]).gameObject.SetActive(false);
((Graphic)countArray[i]).color = color;
}
}
Active = false;
colorMap = null;
}
public static void OnDestory()
{
if (countArray != null)
{
for (int i = 0; i < 112; i++)
{
Object.DestroyImmediate((Object)(object)countArray[i]);
}
}
}
[HarmonyPostfix]
[HarmonyPatch(typeof(UIItemPicker), "OnTypeButtonClick")]
private static void OnTypeButtonClick1(UIItemPicker __instance)
{
if (Active && countArray != null)
{
for (int i = 0; i < 112; i++)
{
int protoId = ((Proto)(__instance.protoArray[i]?)).ID ?? (-1);
SetNumber(countArray[i], protoId);
}
}
}
[HarmonyPostfix]
[HarmonyPatch(typeof(UIRecipePicker), "OnTypeButtonClick")]
private static void OnTypeButtonClick2(UIRecipePicker __instance)
{
if (Active && countArray != null)
{
for (int i = 0; i < 112; i++)
{
int protoId = ((Proto)(__instance.protoArray[i]?)).ID ?? (-1);
SetNumber(countArray[i], protoId);
}
}
}
[HarmonyPostfix]
[HarmonyPatch(typeof(UISignalPicker), "OnTypeButtonClick")]
private static void OnTypeButtonClick3(UISignalPicker __instance)
{
if (Active && countArray != null)
{
for (int i = 0; i < 112; i++)
{
int protoId = __instance.signalArray[i];
SetNumber(countArray[i], protoId);
}
}
}
[HarmonyTranspiler]
[HarmonyPatch(typeof(UISignalPicker), "_OnUpdate")]
public static IEnumerable<CodeInstruction> UISignalPicker_OnUpdate_Transpiler(IEnumerable<CodeInstruction> instructions)
{
//IL_0002: 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_0027: Expected O, but got Unknown
//IL_0049: Unknown result type (might be due to invalid IL or missing references)
//IL_004f: Expected O, but got Unknown
try
{
return new CodeMatcher(instructions, (ILGenerator)null).End().MatchBack(false, (CodeMatch[])(object)new CodeMatch[2]
{
new CodeMatch((OpCode?)OpCodes.Ldarg_0, (object)null, (string)null),
new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction i) => i.opcode == OpCodes.Call && ((MethodInfo)i.operand).Name == "_Close"), (string)null)
}).SetAndAdvance(OpCodes.Nop, (object)null)
.SetAndAdvance(OpCodes.Nop, (object)null)
.InstructionEnumeration();
}
catch (Exception obj)
{
Log.Warn("Transpiler UISignalPicker._OnUpdate error");
Log.Warn(obj);
return instructions;
}
}
public static void Init(ref Text text, ESignalType signalType, int index)
{
//IL_002a: Unknown result type (might be due to invalid IL or missing references)
//IL_003c: Expected I4, but got Unknown
//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)text == (Object)null)
{
text = Object.Instantiate<Text>(UIRoot.instance.uiGame.warningWindow.itemPrefab.countText);
}
switch ((int)signalType)
{
case 1:
((Component)text).gameObject.transform.SetParent(((Component)UIRoot.instance.uiGame.itemPicker.iconImage).transform);
break;
case 2:
((Component)text).gameObject.transform.SetParent(((Component)UIRoot.instance.uiGame.recipePicker.iconImage).transform);
break;
case 0:
((Component)text).gameObject.transform.SetParent(((Component)UIRoot.instance.uiGame.signalPicker.iconImage).transform);
break;
}
((Component)text).gameObject.transform.localScale = Vector3.one;
text.text = "";
SetPosition(text, index, signalType);
}
private static void SetPosition(Text text, int hoveredIndex, ESignalType signalType)
{
//IL_0003: Unknown result type (might be due to invalid IL or missing references)
//IL_0015: Expected I4, but got Unknown
//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)
int num = 14;
switch ((int)signalType)
{
case 1:
num = ItemCol;
break;
case 2:
num = RecipeCol;
break;
case 0:
num = SignalCol;
break;
}
int num2 = hoveredIndex % num;
int num3 = hoveredIndex / num;
((Transform)((Graphic)text).rectTransform).localPosition = Vector2.op_Implicit(new Vector2((float)(num2 * 46 + 41), (float)(-num3 * 46 - 15)));
}
private static void SetNumber(Text text, int protoId)
{
//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
if (filterIds.TryGetValue(protoId, out var value))
{
((Component)text).gameObject.SetActive(true);
if (value < 10000)
{
text.text = value.ToString();
}
else if (value < 10000000)
{
text.text = $"{(float)value / 1000f:F1}K";
}
else
{
text.text = $"{(float)value / 1000f / 1000f:F1}M";
}
}
else
{
((Component)text).gameObject.SetActive(false);
}
if (colorMap != null && colorMap.TryGetValue(protoId, out var value2))
{
((Graphic)text).color = value2;
}
}
}
public class UIwarningTip
{
private static UIButtonTip tip;
public static void Create(UIWarningItemEntry itemEntry, int signalId)
{
//IL_005d: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)tip != (Object)null)
{
Object.Destroy((Object)(object)((Component)tip).gameObject);
}
int signalId2 = itemEntry.signalId;
string text = ((signalId2 < 20000) ? LDB.ItemName(signalId2) : LDB.RecipeName(signalId2 - 20000));
string text2 = GetText(signalId, signalId2);
Transform transform = ((Component)itemEntry).transform;
tip = UIButtonTip.Create(true, text, text2, 2, new Vector2(0f, -10f), 0, transform, "", "");
}
public static void Destory()
{
if ((Object)(object)tip != (Object)null)
{
Object.Destroy((Object)(object)((Component)tip).gameObject);
}
tip = null;
}
private static string GetText(int signalId, int detailId)
{
Dictionary<int, int> dictionary = new Dictionary<int, int>();
WarningSystem warningSystem = GameMain.data.warningSystem;
if (signalId > 0)
{
for (int i = 1; i < warningSystem.warningCursor; i++)
{
ref WarningData reference = ref warningSystem.warningPool[i];
if (reference.id == i && reference.state > 0 && reference.signalId == signalId && reference.detailId == detailId)
{
if (dictionary.ContainsKey(reference.astroId))
{
int astroId = reference.astroId;
int value = dictionary[astroId] + 1;
dictionary[astroId] = value;
}
else
{
dictionary[reference.astroId] = 1;
}
}
}
}
string text = "";
foreach (KeyValuePair<int, int> item in dictionary)
{
PlanetData val = GameMain.galaxy.PlanetById(item.Key);
if (val != null)
{
text = text + val.displayName + " (" + item.Value + ")\n";
}
}
return text;
}
}
public class WarningSystemPatch
{
private const int INDEXUPPERBOND = -20000;
private static int tmpSigalId = 0;
private static int tick = 3;
private static int currentIndex = 0;
public static bool Enable { get; set; } = true;
[HarmonyPostfix]
[HarmonyPatch(typeof(WarningSystem), "Import")]
internal static void Import(WarningSystem __instance)
{
for (int i = 1; i < __instance.warningCursor; i++)
{
if (__instance.warningPool[i].factoryId <= -20000)
{
__instance.warningPool[i].detailId = -__instance.warningPool[i].factoryId + -20000;
}
}
}
[HarmonyPostfix]
[HarmonyPatch(typeof(WarningSystem), "GameTick")]
internal static void GameTick()
{
Plugin.mainLogic.GameTick();
}
[HarmonyPrefix]
[HarmonyPatch(typeof(UIWarningWindow), "Determine")]
internal static void Determine(ref bool open)
{
open &= Enable;
}
[HarmonyPostfix]
[HarmonyPatch(typeof(UIWarningWindow), "_OnClose")]
internal static void OnClose()
{
UIwarningTip.Destory();
}
[HarmonyPostfix]
[HarmonyPatch(typeof(UIWarningWindow), "_OnLateUpdate")]
internal static void OnLateUpdate(UIWarningWindow __instance)
{
//IL_005e: 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_0068: Unknown result type (might be due to invalid IL or missing references)
//IL_0073: Expected O, but got Unknown
//IL_0090: 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)
if (tmpSigalId != 0)
{
__instance.selectedSignalId = tmpSigalId;
if (--tick <= 0)
{
tmpSigalId = 0;
}
}
if (!Input.GetKeyDown((KeyCode)323) && !Input.GetKeyDown((KeyCode)324))
{
return;
}
Camera worldCamera = UIRoot.instance.overlayCanvas.worldCamera;
if (RectTransformUtility.RectangleContainsScreenPoint((RectTransform)((Component)__instance.itemGroup).transform, Vector2.op_Implicit(Input.mousePosition), worldCamera))
{
for (int i = 0; i < __instance.itemCount; i++)
{
if (!RectTransformUtility.RectangleContainsScreenPoint(__instance.itemEntries[i].rectTrans, Vector2.op_Implicit(Input.mousePosition), worldCamera))
{
continue;
}
if (Input.GetKeyDown((KeyCode)323))
{
if (VFInput.control)
{
SeekNextSignal(__instance.selectedSignalId, __instance.itemEntries[i].signalId);
}
else
{
UIwarningTip.Create(__instance.itemEntries[i], __instance.selectedSignalId);
}
}
else if (Input.GetKeyDown((KeyCode)324))
{
HideGroup(__instance.selectedSignalId, __instance.itemEntries[i].signalId);
}
break;
}
}
else
{
UIwarningTip.Destory();
}
}
[HarmonyPrefix]
[HarmonyPatch(typeof(PlanetFactory), "RemoveEntityWithComponents")]
internal static void RemoveWarningByEntity(PlanetFactory __instance, int id)
{
//IL_003a: 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_0050: Unknown result type (might be due to invalid IL or missing references)
//IL_0055: Unknown result type (might be due to invalid IL or missing references)
int planetId = __instance.planetId;
WarningSystem warningSystem = GameMain.data.warningSystem;
for (int i = 1; i < warningSystem.warningCursor; i++)
{
ref WarningData reference = ref warningSystem.warningPool[i];
if (reference.factoryId <= -20000 && reference.astroId == planetId)
{
Vector3 val = reference.localPos - __instance.entityPool[id].pos;
if (((Vector3)(ref val)).sqrMagnitude < 1f)
{
warningSystem.RemoveWarningData(i);
Log.Debug($"Remove {i} on {planetId}");
}
}
}
}
public static void AddWarningData(int signalId, int detailId, List<int> planetIds, List<Vector3> localPos, List<int> detailIds = null)
{
//IL_014a: 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)
if (planetIds.Count != localPos.Count || (detailIds != null && detailIds.Count != localPos.Count))
{
Log.Warn($"Length mismatch! planetIds:{planetIds.Count} pos:{localPos.Count}");
return;
}
WarningSystem warningSystem = GameMain.data.warningSystem;
int num = warningSystem.warningTotalCount + localPos.Count;
int num2 = warningSystem.warningCapacity;
while (num >= num2)
{
num2 *= 2;
}
if (num2 > warningSystem.warningCapacity)
{
warningSystem.SetWarningCapacity(num2);
}
for (int i = 0; i < localPos.Count; i++)
{
int num3 = warningSystem.warningCursor;
if (warningSystem.warningRecycleCursor > 0)
{
num3 = warningSystem.warningRecycle[--warningSystem.warningRecycleCursor];
}
else
{
warningSystem.warningCursor++;
}
int num4 = detailIds?[i] ?? detailId;
if (num4 < 0)
{
Log.Warn($"warningDetailId {num4} < 0");
return;
}
ref WarningData reference = ref warningSystem.warningPool[num3];
reference.id = num3;
reference.state = 1;
reference.signalId = signalId;
reference.detailId = num4;
reference.factoryId = -20000 - reference.detailId;
reference.astroId = planetIds[i];
reference.localPos = localPos[i];
}
UIRoot.instance.uiGame.warningWindow.selectedSignalId = signalId;
tmpSigalId = signalId;
tick = 3;
Log.Debug($"Add {localPos.Count}. Cursor = {warningSystem.warningCursor} RecycleCursor = {warningSystem.warningRecycleCursor} Capacity = {warningSystem.warningCapacity}");
}
public static void ClearAll()
{
int num = 0;
WarningSystem warningSystem = GameMain.data.warningSystem;
for (int num2 = warningSystem.warningCursor - 1; num2 > 0; num2--)
{
ref WarningData reference = ref warningSystem.warningPool[num2];
if (reference.factoryId <= -20000)
{
((WarningData)(ref reference)).SetEmpty();
if (num2 == warningSystem.warningCursor - 1)
{
warningSystem.warningCursor--;
}
else
{
int[] warningRecycle = warningSystem.warningRecycle;
int warningRecycleCursor = warningSystem.warningRecycleCursor;
warningSystem.warningRecycleCursor = warningRecycleCursor + 1;
warningRecycle[warningRecycleCursor] = num2;
}
num++;
}
int num3 = warningSystem.warningCapacity;
while (num3 / 2 > warningSystem.warningCursor)
{
num3 /= 2;
}
if (num3 != warningSystem.warningCapacity)
{
warningSystem.SetWarningCapacity(num3);
}
}
if (num > 0)
{
Log.Debug($"Remove {num}. Cursor = {warningSystem.warningCursor} RecycleCursor = {warningSystem.warningRecycleCursor} Capacity = {warningSystem.warningCapacity}");
}
}
public static void HideGroup(int signalId, int detailId)
{
WarningSystem warningSystem = GameMain.data.warningSystem;
if (signalId <= 0)
{
return;
}
for (int i = 1; i < warningSystem.warningCursor; i++)
{
ref WarningData reference = ref warningSystem.warningPool[i];
if (reference.id == i && reference.state > 0 && reference.signalId == signalId && reference.detailId == detailId && reference.factoryId <= -20000)
{
int factoryId = reference.factoryId;
((WarningData)(ref reference)).SetEmpty();
reference.factoryId = factoryId;
}
}
}
public static void SeekNextSignal(int signalId, int detailId)
{
//IL_00da: 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)
int num = GameMain.localPlanet?.id ?? 0;
WarningSystem warningSystem = GameMain.data.warningSystem;
if (signalId <= 0 || detailId <= 0 || warningSystem.warningCursor <= 0 || num == 0)
{
return;
}
currentIndex %= warningSystem.warningCursor;
int num2 = currentIndex;
int num3 = 0;
do
{
currentIndex = (currentIndex + 1) % warningSystem.warningCursor;
ref WarningData reference = ref warningSystem.warningPool[currentIndex];
if (reference.signalId == signalId && reference.detailId == detailId && reference.id == currentIndex && reference.state > 0 && reference.astroId == num)
{
Log.Debug($"SeekNextSignal[{currentIndex}]: ({signalId},{detailId}) {reference.localPos}");
UIRoot.instance.uiGame.globemap.MoveToViewTargetTwoStep(reference.localPos, 200f);
break;
}
}
while (num3++ <= 999 && currentIndex != num2);
}
public static void Debug()
{
//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)
Log.Info(UIRoot.instance.uiGame.warningWindow.selectedSignalId);
WarningSystem warningSystem = GameMain.data.warningSystem;
for (int i = 1; i < warningSystem.warningCursor; i++)
{
ref WarningData reference = ref warningSystem.warningPool[i];
if (reference.factoryId < -20000)
{
string text = $"[{i}] {reference.signalId} - {reference.factoryId}:";
Vector3 localPos = reference.localPos;
Log.Debug(text + ((object)(Vector3)(ref localPos)).ToString());
}
}
}
}
}
namespace FactoryLocator.UI
{
public class MyCheckBox : MonoBehaviour
{
public UIButton uiButton;
public Image checkImage;
public RectTransform rectTrans;
public Text labelText;
public bool enable;
public static MyCheckBox CreateCheckBox(bool startingState, string label = "", int fontSize = 17)
{
//IL_004c: Unknown result type (might be due to invalid IL or missing references)
//IL_0057: Unknown result type (might be due to invalid IL or missing references)
//IL_0071: Unknown result type (might be due to invalid IL or missing references)
GameObject val = Object.Instantiate<GameObject>(((Component)UIRoot.instance.uiGame.buildMenu.uxFacilityCheck).gameObject);
((Object)val).name = "my-checkbox";
MyCheckBox myCheckBox = val.AddComponent<MyCheckBox>();
myCheckBox.enable = startingState;
ref RectTransform reference = ref myCheckBox.rectTrans;
Transform transform = val.transform;
RectTransform val2 = (reference = (RectTransform)(object)((transform is RectTransform) ? transform : null));
val2.anchorMax = Vector2.zero;
val2.anchorMin = Vector2.zero;
val2.anchoredPosition3D = new Vector3(0f, 0f, 0f);
myCheckBox.uiButton = val.GetComponent<UIButton>();
Transform obj = val.transform.Find("checked");
myCheckBox.checkImage = ((obj != null) ? ((Component)obj).GetComponent<Image>() : null);
Transform val3 = val.transform.Find("text");
if ((Object)(object)val3 != (Object)null)
{
Object.DestroyImmediate((Object)(object)((Component)val3).GetComponent<Localizer>());
myCheckBox.labelText = ((Component)val3).GetComponent<Text>();
myCheckBox.labelText.fontSize = fontSize;
myCheckBox.SetLabelText(label);
}
myCheckBox.uiButton.onClick += myCheckBox.OnClick;
((Behaviour)myCheckBox.checkImage).enabled = myCheckBox.enable;
return myCheckBox;
}
public void SetLabelText(string val)
{
if ((Object)(object)labelText != (Object)null)
{
labelText.text = val;
}
}
public void OnClick(int obj)
{
enable = !enable;
((Behaviour)checkImage).enabled = enable;
}
}
public static class MyWindowCtl
{
public static List<ManualBehaviour> _windows = new List<ManualBehaviour>(2);
internal static bool _created = false;
public static T CreateWindow<T>(string name, string title = "") where T : Component
{
//IL_009f: Unknown result type (might be due to invalid IL or missing references)
//IL_00a9: Expected O, but got Unknown
UITankWindow tankWindow = UIRoot.instance.uiGame.tankWindow;
GameObject val = Object.Instantiate<GameObject>(((Component)tankWindow).gameObject, ((Component)tankWindow).transform.parent);
((Object)val).name = name;
val.SetActive(false);
Object.Destroy((Object)(object)val.GetComponent<UITankWindow>());
object obj = val.AddComponent<T>();
ManualBehaviour val2 = (ManualBehaviour)((obj is ManualBehaviour) ? obj : null);
for (int i = 0; i < val.transform.childCount; i++)
{
GameObject gameObject = ((Component)val.transform.GetChild(i)).gameObject;
if (((Object)gameObject).name == "panel-bg")
{
Button componentInChildren = gameObject.GetComponentInChildren<Button>();
if ((Object)(object)componentInChildren != (Object)null)
{
((UnityEvent)componentInChildren.onClick).AddListener(new UnityAction(val2._Close));
}
}
else if (((Object)gameObject).name != "shadow" && ((Object)gameObject).name != "panel-bg")
{
Object.Destroy((Object)(object)gameObject);
}
}
SetTitle(val2, title);
val2._Create();
val2._Init(val2.data);
_windows.Add(val2);
return (T)(object)((val2 is T) ? val2 : null);
}
public static void SetTitle(ManualBehaviour win, string title)
{
Text titleText = GetTitleText(win);
if (Object.op_Implicit((Object)(object)titleText))
{
titleText.text = title;
}
}
public static Text GetTitleText(ManualBehaviour win)
{
Transform obj = ((Component)win).gameObject.transform.Find("panel-bg/title-text");
if (obj == null)
{
return null;
}
return ((Component)obj).gameObject.GetComponent<Text>();
}
public static RectTransform GetRectTransform(ManualBehaviour win)
{
return ((Component)win).GetComponent<RectTransform>();
}
public static void OpenWindow(ManualBehaviour win)
{
win._Open();
((Component)win).transform.SetAsLastSibling();
}
public static void CloseWindow(ManualBehaviour win)
{
win._Close();
}
}
public class UILocatorWindow : ManualBehaviour
{
public RectTransform windowTrans;
private RectTransform tab1;
private Text nameText;
private UIButton[] queryBtns;
private UIButton clearAllBtn;
private Text iconText;
private UIButton iconBtn;
private Image iconImage;
private MyCheckBox warningCheckBox;
private MyCheckBox autoclearCheckBox;
private PlanetData veiwPlanet;
private StarData veiwStar;
private bool initialized;
private UIButtonTip statusTip;
private string statusText = "";
private bool autoclear_enable = true;
private int currentLanguageLCID;
private static UIComboBox comboBox;
private static List<int> networkIds;
private static int queryingType;
private static int buildingIndex;
private static int veinIndex;
private static int assemblerIndex;
private static int warningIndex;
private static int storageIndex;
private static int stationIndex;
public static UILocatorWindow CreateWindow()
{
return MyWindowCtl.CreateWindow<UILocatorWindow>("FactoryLocator Window", "Factory Locator");
}
public void OpenWindow()
{
MyWindowCtl.OpenWindow((ManualBehaviour)(object)this);
}
public override void _OnCreate()
{
//IL_001c: Unknown result type (might be due to invalid IL or missing references)
windowTrans = MyWindowCtl.GetRectTransform((ManualBehaviour)(object)this);
windowTrans.sizeDelta = new Vector2(260f, 290f);
CreateUI();
}
public override void _OnDestroy()
{
if ((Object)(object)comboBox != (Object)null)
{
Object.Destroy((Object)(object)((Component)comboBox).gameObject);
comboBox = null;
Log.Debug("_OnDestroy");
}
}
internal void CreateUI()
{
//IL_0091: Unknown result type (might be due to invalid IL or missing references)
RectTransform base_ = windowTrans;
float y_ = 54f;
float x_ = 36f;
int tabIndex_ = 1;
tab1 = AddTab("General");
base_ = tab1;
y_ = 0f;
x_ = 0f;
nameText = Util.CreateText("Name", 16, (TextAnchor)4);
((Graphic)nameText).rectTransform.sizeDelta = new Vector2(180f, 20f);
Transform transform = ((Component)nameText).transform;
AddElement((RectTransform)(object)((transform is RectTransform) ? transform : null), 0f, 0f);
x_ = 0f;
queryBtns = (UIButton[])(object)new UIButton[6];
queryBtns[0] = Util.CreateButton("Building", 90f, 24f);
Transform transform2 = ((Component)queryBtns[0]).transform;
AddElement((RectTransform)(object)((transform2 is RectTransform) ? transform2 : null), 0f, 30f);
queryBtns[0].onClick += delegate
{
OnQueryClick(0);
};
queryBtns[1] = Util.CreateButton("Vein", 90f, 24f);
Transform transform3 = ((Component)queryBtns[1]).transform;
AddElement((RectTransform)(object)((transform3 is RectTransform) ? transform3 : null), 98f, 0f);
queryBtns[1].onClick += delegate
{
OnQueryClick(1);
};
queryBtns[2] = Util.CreateButton("Recipe", 90f, 24f);
Transform transform4 = ((Component)queryBtns[2]).transform;
AddElement((RectTransform)(object)((transform4 is RectTransform) ? transform4 : null), -98f, 32f);
queryBtns[2].onClick += delegate
{
OnQueryClick(2);
};
queryBtns[3] = Util.CreateButton("Warning", 90f, 24f);
Transform transform5 = ((Component)queryBtns[3]).transform;
AddElement((RectTransform)(object)((transform5 is RectTransform) ? transform5 : null), 98f, 0f);
queryBtns[3].onClick += delegate
{
OnQueryClick(3);
};
queryBtns[4] = Util.CreateButton("Storage", 90f, 24f);
Transform transform6 = ((Component)queryBtns[4]).transform;
AddElement((RectTransform)(object)((transform6 is RectTransform) ? transform6 : null), -98f, 32f);
queryBtns[4].onClick += delegate
{
OnQueryClick(4);
};
queryBtns[5] = Util.CreateButton("Station", 90f, 24f);
Transform transform7 = ((Component)queryBtns[5]).transform;
AddElement((RectTransform)(object)((transform7 is RectTransform) ? transform7 : null), 98f, 0f);
queryBtns[5].onClick += delegate
{
OnQueryClick(5);
};
x_ = 0f;
iconText = CreateTitleText("Signal Icon");
Transform transform8 = ((Component)iconText).transform;
AddElement((RectTransform)(object)((transform8 is RectTransform) ? transform8 : null), 0f, 34f);
Util.CreateSignalIcon(out iconBtn, out iconImage);
Transform transform9 = ((Component)iconBtn).transform;
AddElement((RectTransform)(object)((transform9 is RectTransform) ? transform9 : null), 70f, -3f);
iconBtn.onClick += OnIconBtnClick;
clearAllBtn = Util.CreateButton("Clear All", 70f, 24f);
Transform transform10 = ((Component)clearAllBtn).transform;
AddElement((RectTransform)(object)((transform10 is RectTransform) ? transform10 : null), 48f, 7f);
clearAllBtn.onClick += delegate
{
WarningSystemPatch.ClearAll();
};
x_ = 0f;
warningCheckBox = MyCheckBox.CreateCheckBox(WarningSystemPatch.Enable, "Display All Warning");
AddElement(warningCheckBox.rectTrans, 0f, 30f);
warningCheckBox.uiButton.onClick += OnWarningCheckboxClick;
x_ = 0f;
autoclearCheckBox = MyCheckBox.CreateCheckBox(autoclear_enable, "Auto Clear Query");
AddElement(autoclearCheckBox.rectTrans, 0f, 26f);
autoclearCheckBox.uiButton.onClick += OnAutoClearCheckoxClick;
void AddElement(RectTransform rect_, float deltaX, float deltaY)
{
x_ += deltaX;
y_ += deltaY;
if ((Object)(object)rect_ != (Object)null)
{
Util.NormalizeRectWithTopLeft((Component)(object)rect_, x_, y_, (Transform)(object)base_);
}
}
RectTransform AddTab(string label)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
GameObject val2 = new GameObject();
RectTransform val3 = val2.AddComponent<RectTransform>();
Util.NormalizeRectWithMargin((Component)(object)val3, 52f, 36f, 0f, 0f, (Transform)(object)windowTrans);
((Object)val2).name = "tab-" + tabIndex_;
return val3;
}
Text CreateTitleText(string label_)
{
//IL_003d: 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)
Text val = Object.Instantiate<Text>(MyWindowCtl.GetTitleText((ManualBehaviour)(object)this));
((Object)((Component)val).gameObject).name = "label";
val.text = label_;
((Graphic)val).color = new Color(1f, 1f, 1f, 0.5f);
Transform transform11 = ((Component)val).transform;
((RectTransform)((transform11 is RectTransform) ? transform11 : null)).sizeDelta = new Vector2(val.preferredWidth + 40f, 30f);
return val;
}
}
public override void _OnOpen()
{
if (!initialized)
{
OnSignalPickReturn(401);
initialized = true;
}
SetText();
SetViewingTarget();
NebulaCompat.OnOpen();
}
public override void _OnClose()
{
if ((Object)(object)statusTip != (Object)null)
{
Object.Destroy((Object)(object)((Component)statusTip).gameObject);
}
if (autoclear_enable)
{
WarningSystemPatch.ClearAll();
}
UIentryCount.OnClose();
NebulaCompat.OnClose();
UIComboBox obj = comboBox;
if (obj != null)
{
((Component)obj).gameObject.SetActive(false);
}
}
public void SetText()
{
if (currentLanguageLCID != Localization.CurrentLanguageLCID)
{
currentLanguageLCID = Localization.CurrentLanguageLCID;
((Component)((Component)queryBtns[0]).transform.Find("Text")).GetComponent<Text>().text = Localization.Translate("Building");
((Component)((Component)queryBtns[1]).transform.Find("Text")).GetComponent<Text>().text = Localization.Translate("Vein");
((Component)((Component)queryBtns[2]).transform.Find("Text")).GetComponent<Text>().text = Localization.Translate("Recipe");
((Component)((Component)queryBtns[3]).transform.Find("Text")).GetComponent<Text>().text = Localization.Translate("Warning");
((Component)((Component)queryBtns[4]).transform.Find("Text")).GetComponent<Text>().text = Localization.Translate("Storage");
((Component)((Component)queryBtns[5]).transform.Find("Text")).GetComponent<Text>().text = Localization.Translate("Station");
iconText.text = Localization.Translate("Signal Icon");
((Component)((Component)clearAllBtn).transform.Find("Text")).GetComponent<Text>().text = Localization.Translate("Clear All");
warningCheckBox.labelText.text = Localization.Translate("Display All Warning");
autoclearCheckBox.labelText.text = Localization.Translate("Auto Clear Query");
}
}
public void SetViewingTarget()
{
veiwStar = null;
veiwPlanet = null;
if (((ManualBehaviour)UIRoot.instance.uiGame.planetDetail).active)
{
veiwPlanet = UIRoot.instance.uiGame.planetDetail.planet;
}
else if (((ManualBehaviour)UIRoot.instance.uiGame.starDetail).active)
{
veiwStar = UIRoot.instance.uiGame.starDetail.star;
}
else
{
veiwPlanet = GameMain.localPlanet;
}
if (veiwStar != null)
{
nameText.text = veiwStar.displayName + Localization.Translate("空格行星系");
}
else
{
Text obj = nameText;
PlanetData obj2 = veiwPlanet;
obj.text = ((obj2 != null) ? obj2.displayName : null) ?? Localization.Translate("外太空");
}
int num = Plugin.mainLogic.SetFactories(veiwStar, veiwPlanet);
for (int i = 0; i < queryBtns.Length; i++)
{
((Behaviour)queryBtns[i].button).enabled = num > 0;
}
}
public void SetStatusTipText(float[] consumerRatio, int[] consumerCount)
{
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.AppendLine(Localization.Translate("Satisfaction - Consumer Count"));
for (int i = 0; i < consumerCount.Length; i++)
{
stringBuilder.AppendLine($"{consumerRatio[i],-3:P0} - {consumerCount[i]}");
}
statusText = stringBuilder.ToString();
if ((Object)(object)statusTip != (Object)null)
{
statusTip.subTextComp.text = statusText;
}
}
public override void _OnUpdate()
{
//IL_0094: Unknown result type (might be due to invalid IL or missing references)
//IL_0099: Unknown result type (might be due to invalid IL or missing references)
//IL_009e: Unknown result type (might be due to invalid IL or missing references)
//IL_00b7: Expected O, but got Unknown
//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
if (((ManualBehaviour)UIRoot.instance.uiGame.starDetail).active)
{
if (UIRoot.instance.uiGame.starDetail.star != veiwStar)
{
SetViewingTarget();
}
}
else if (((ManualBehaviour)UIRoot.instance.uiGame.planetDetail).active)
{
if (UIRoot.instance.uiGame.planetDetail.planet != veiwPlanet)
{
SetViewingTarget();
}
}
else if (GameMain.localPlanet != veiwPlanet)
{
SetViewingTarget();
}
Transform transform = ((Component)nameText).transform;
if (RectTransformUtility.RectangleContainsScreenPoint((RectTransform)transform, Vector2.op_Implicit(Input.mousePosition), UIRoot.instance.overlayCanvas.worldCamera))
{
if ((Object)(object)statusTip == (Object)null)
{
SetViewingTarget();
statusTip = UIButtonTip.Create(true, Localization.Translate("Power Network Status"), statusText, 1, new Vector2(0f, -10f), 0, transform, "", "");
}
}
else if ((Object)(object)statusTip != (Object)null)
{
Object.Destroy((Object)(object)((Component)statusTip).gameObject);
statusTip = null;
}
NebulaCompat.OnUpdate();
}
private void OnQueryClick(int queryType)
{
if (autoclear_enable)
{
WarningSystemPatch.ClearAll();
}
SetSubcategory(queryType);
switch (queryType)
{
case 0:
Plugin.mainLogic.PickBuilding(buildingIndex);
break;
case 1:
Plugin.mainLogic.PickVein(veinIndex);
break;
case 2:
Plugin.mainLogic.PickAssembler(assemblerIndex);
break;
case 3:
Plugin.mainLogic.PickWarning(warningIndex);
break;
case 4:
Plugin.mainLogic.PickStorage(storageIndex);
break;
case 5:
Plugin.mainLogic.PickStation(stationIndex);
break;
}
}
public void SetPowerNetworkDropdownList(List<int> ids)
{
networkIds = ids;
}
public void SetSubcategory(int queryType)
{
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
//IL_0028: Expected O, but got Unknown
if ((Object)(object)comboBox == (Object)null)
{
comboBox = Util.CreateComboBox(new UnityAction(OnComboBoxIndexChange), 200f);
}
switch (queryType)
{
case 2:
Util.NormalizeRectWithTopLeft((Component)(object)comboBox, 153f, 7f, ((Component)UIRoot.instance.uiGame.recipePicker).transform);
break;
case 3:
Util.NormalizeRectWithTopLeft((Component)(object)comboBox, 153f, 7f, ((Component)UIRoot.instance.uiGame.signalPicker).transform);
break;
default:
Util.NormalizeRectWithTopLeft((Component)(object)comboBox, 153f, 7f, ((Component)UIRoot.instance.uiGame.itemPicker).transform);
break;
}
queryingType = queryType;
comboBox.Items.Clear();
comboBox.ItemsData.Clear();
switch (queryType)
{
case 0:
{
buildingIndex = 0;
if (networkIds == null)
{
comboBox.Items.Add(Localization.Translate("All"));
comboBox.ItemsData.Add(0);
comboBox.itemIndex = 0;
((Component)comboBox).gameObject.SetActive(false);
return;
}
comboBox.Items.Add(Localization.Translate("All") + $" ({networkIds.Count})");
comboBox.ItemsData.Add(0);
for (int i = 0; i < networkIds.Count; i++)
{
comboBox.Items.Add(Localization.Translate("电网号") + networkIds[i]);
comboBox.ItemsData.Add(i + 1);
}
comboBox.itemIndex = 0;
break;
}
case 1:
comboBox.Items.Add(Localization.Translate("All"));
comboBox.ItemsData.Add(0);
comboBox.Items.Add(Localization.Translate("显示正在采集"));
comboBox.ItemsData.Add(1);
comboBox.Items.Add(Localization.Translate("显示尚未采集"));
comboBox.ItemsData.Add(2);
comboBox.itemIndex = veinIndex;
break;
case 2:
comboBox.Items.Add(Localization.Translate("All"));
comboBox.ItemsData.Add(0);
comboBox.Items.Add(Localization.Translate("额外产出"));
comboBox.ItemsData.Add(1);
comboBox.Items.Add(Localization.Translate("加速生产"));
comboBox.ItemsData.Add(2);
comboBox.Items.Add(Localization.Translate("缺少原材料"));
comboBox.ItemsData.Add(3);
comboBox.Items.Add(Localization.Translate("产物堆积"));
comboBox.ItemsData.Add(4);
comboBox.itemIndex = assemblerIndex;
break;
case 3:
comboBox.Items.Add(Localization.Translate("All"));
comboBox.ItemsData.Add(0);
comboBox.Items.Add(Localization.Translate("Recording Mode"));
comboBox.ItemsData.Add(1);
comboBox.itemIndex = warningIndex;
break;
case 4:
comboBox.Items.Add(Localization.Translate("All"));
comboBox.ItemsData.Add(0);
comboBox.Items.Add(Localization.Translate("需求"));
comboBox.ItemsData.Add(1);
comboBox.Items.Add(Localization.Translate("供应"));
comboBox.ItemsData.Add(2);
comboBox.itemIndex = storageIndex;
break;
case 5:
comboBox.Items.Add(Localization.Translate("All"));
comboBox.ItemsData.Add(0);
comboBox.Items.Add(Localization.Translate("本地站点号"));
comboBox.ItemsData.Add(1);
comboBox.Items.Add(Localization.Translate("星际站点号"));
comboBox.ItemsData.Add(2);
comboBox.Items.Add(Localization.Translate("本地需求"));
comboBox.ItemsData.Add(3);
comboBox.Items.Add(Localization.Translate("本地供应"));
comboBox.ItemsData.Add(4);
comboBox.Items.Add(Localization.Translate("星际需求"));
comboBox.ItemsData.Add(5);
comboBox.Items.Add(Localization.Translate("星际供应"));
comboBox.ItemsData.Add(6);
comboBox.itemIndex = stationIndex;
break;
default:
((Component)comboBox).gameObject.SetActive(false);
return;
}
((Component)comboBox).gameObject.SetActive(true);
}
private void OnComboBoxIndexChange()
{
bool active = ((ManualBehaviour)UIRoot.instance.uiGame.itemPicker).active;
bool active2 = ((ManualBehaviour)UIRoot.instance.uiGame.recipePicker).active;
bool active3 = ((ManualBehaviour)UIRoot.instance.uiGame.signalPicker).active;
switch (queryingType)
{
case 0:
buildingIndex = comboBox.itemIndex;
if (active)
{
Plugin.mainLogic.OnBuildingPickReturn(null);
UIItemPicker.Close();
Plugin.mainLogic.PickBuilding(buildingIndex);
}
break;
case 1:
veinIndex = comboBox.itemIndex;
if (active)
{
Plugin.mainLogic.OnVeinPickReturn(null);
UIItemPicker.Close();
Plugin.mainLogic.PickVein(veinIndex);
}
break;
case 2:
assemblerIndex = comboBox.itemIndex;
if (active2)
{
Plugin.mainLogic.OnAssemblerPickReturn(null);
UIRecipePicker.Close();
Plugin.mainLogic.PickAssembler(assemblerIndex);
}
break;
case 3:
warningIndex = comboBox.itemIndex;
if (active3)
{
Plugin.mainLogic.OnWarningPickReturn(0);
UISignalPicker.Close();
Plugin.mainLogic.PickWarning(warningIndex);
}
break;
case 4:
storageIndex = comboBox.itemIndex;
if (active)
{
Plugin.mainLogic.OnStoragePickReturn(null);
UIItemPicker.Close();
Plugin.mainLogic.PickStorage(storageIndex);
}
break;
case 5:
stationIndex = comboBox.itemIndex;
if (active)
{
Plugin.mainLogic.OnStationPickReturn(null);
UIItemPicker.Close();
Plugin.mainLogic.PickStation(stationIndex);
}
break;
}
}
private void OnIconBtnClick(int _)
{
//IL_000a: Unknown result type (might be due to invalid IL or missing references)
UISignalPicker.Popup(new Vector2(-300f, 250f), (Action<int>)OnSignalPickReturn);
}
private void OnSignalPickReturn(int signalId)
{
Sprite val = LDB.signals.IconSprite(signalId);
if ((Object)(object)val != (Object)null)
{
Plugin.mainLogic.SignalId = signalId;
iconImage.sprite = val;
}
}
private void OnWarningCheckboxClick(int _)
{
WarningSystemPatch.Enable = !WarningSystemPatch.Enable;
}
private void OnAutoClearCheckoxClick(int _)
{
autoclear_enable = !autoclear_enable;
}
}
public class Util
{
public static RectTransform NormalizeRectWithTopLeft(Component cmp, float left, float top, Transform parent = null)
{
//IL_0028: 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_0052: 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)
Transform transform = cmp.transform;
RectTransform val = (RectTransform)(object)((transform is RectTransform) ? transform : null);
if ((Object)(object)parent != (Object)null)
{
((Transform)val).SetParent(parent, false);
}
val.anchorMax = new Vector2(0f, 1f);
val.anchorMin = new Vector2(0f, 1f);
val.pivot = new Vector2(0f, 1f);
val.anchoredPosition3D = new Vector3(left, 0f - top, 0f);
return val;
}
public static RectTransform NormalizeRectWithMargin(Component cmp, float top, float left, float bottom, float right, Transform parent = null)
{
//IL_0020: 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_0036: Unknown result type (might be due to invalid IL or missing references)
//IL_0041: Unknown result type (might be due to invalid IL or missing references)
//IL_0056: 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_0073: Unknown result type (might be due to invalid IL or missing references)
Transform transform = cmp.transform;
RectTransform val = (RectTransform)(object)((transform is RectTransform) ? transform : null);
if ((Object)(object)parent != (Object)null)
{
((Transform)val).SetParent(parent, false);
}
val.anchoredPosition3D = Vector3.zero;
((Transform)val).localScale = Vector3.one;
val.anchorMax = Vector2.one;
val.anchorMin = Vector2.zero;
val.pivot = new Vector2(0.5f, 0.5f);
val.offsetMax = new Vector2(0f - right, 0f - top);
val.offsetMin = new Vector2(left, bottom);
return val;
}
public static Text CreateText(string label, int fontSize = 14, TextAnchor anchor = 3)
{
//IL_004b: Unknown result type (might be due to invalid IL or missing references)
//IL_0056: Unknown result type (might be due to invalid IL or missing references)
Text obj = Object.Instantiate<Text>(UIRoot.instance.uiGame.assemblerWindow.stateText);
((Object)((Component)obj).gameObject).name = "txt_" + label;
obj.text = label;
((Graphic)obj).color = new Color(1f, 1f, 1f, 0.4f);
obj.alignment = anchor;
obj.fontSize = fontSize;
return obj;
}
public static UIButton CreateButton(string label, float width = 0f, float height = 0f)
{
//IL_0066: 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_00dd: Unknown result type (might be due to invalid IL or missing references)
//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
UIButton val = Object.Instantiate<UIButton>(UIRoot.instance.uiGame.dysonEditor.controlPanel.hierarchy.swarmPanel.orbitAddButton);
((Object)((Component)val).gameObject).name = "btn_" + label;
if (val.transitions.Length >= 1)
{
val.transitions[0].normalColor = new Color(0.2392f, 0.6f, 0.9f, 0.078f);
}
Text component = ((Component)((Component)val).transform.Find("Text")).GetComponent<Text>();
component.text = label;
component.fontSize = 17;
Object.Destroy((Object)(object)((Component)((Component)val).transform.Find("Text")).GetComponent<Localizer>());
Transform transform = ((Component)val).transform;
RectTransform val2 = (RectTransform)(object)((transform is RectTransform) ? transform : null);
if (width == 0f || height == 0f)
{
val2.sizeDelta = new Vector2(component.preferredWidth + 14f, 24f);
}
else
{
val2.sizeDelta = new Vector2(width, height);
}
return val;
}
public static void CreateSignalIcon(out UIButton iconButton, out Image iconImage)
{
//IL_003a: Unknown result type (might be due to invalid IL or missing references)
//IL_0040: Expected O, but got Unknown
GameObject obj = Object.Instantiate<GameObject>(((Component)((Component)UIRoot.instance.uiGame.beltWindow.iconTagButton).transform).gameObject);
((Object)obj).name = "signal-button";
obj.SetActive(true);
RectTransform val = (RectTransform)obj.transform;
for (int num = ((Transform)val).childCount - 1; num >= 0; num--)
{
Object.Destroy((Object)(object)((Component)((Transform)val).GetChild(num)).gameObject);
}
iconButton = ((Component)val).GetComponent<UIButton>();
iconButton.tips.tipTitle = Localization.Translate("Signal Icon");
iconButton.tips.tipText = Localization.Translate("Select a signal to display.");
iconImage = ((Component)val).GetComponent<Image>();
}
public static UIComboBox CreateComboBox(UnityAction OnComboBoxIndexChange, float width, float height = 30f)
{
//IL_0078: 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)
UIComboBox val = Object.Instantiate<UIComboBox>(UIRoot.instance.uiGame.statWindow.productSortBox);
((Object)val).name = "FactoryLocator comboBox";
Transform val2 = ((Component)val).transform.Find("Dropdown List ScrollBox/Mask/Content Panel/");
for (int num = val2.childCount - 1; num >= 0; num--)
{
if (((Object)val2.GetChild(num)).name == "Item Button(Clone)")
{
Object.Destroy((Object)(object)((Component)val2.GetChild(num)).gameObject);
}
}
((RectTransform)((Component)val).transform).sizeDelta = new Vector2(width, height);
UIComboBox componentInChildren = ((Component)val).GetComponentInChildren<UIComboBox>();
((UnityEventBase)componentInChildren.onItemIndexChange).RemoveAllListeners();
componentInChildren.itemIndex = 0;
componentInChildren.m_Input.text = "";
((UnityEvent)componentInChildren.onItemIndexChange).AddListener(OnComboBoxIndexChange);
return componentInChildren;
}
public static int RecipeIdUnderMouse()
{
if (((ManualBehaviour)UIRoot.instance.uiGame.replicator).active)
{
UIReplicatorWindow replicator = UIRoot.instance.uiGame.replicator;
if (replicator.mouseRecipeIndex >= 0)
{
RecipeProto val = replicator.recipeProtoArray[replicator.mouseRecipeIndex];
if (val != null)
{
return ((Proto)val).ID;
}
}
}
return 0;
}
public static int ItemIdHintUnderMouse()
{
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
//IL_0010: Unknown result type (might be due to invalid IL or missing references)
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
//IL_0021: Expected O, but got Unknown
//IL_003b: Unknown result type (might be due to invalid IL or missing references)
//IL_0040: Unknown result type (might be due to invalid IL or missing references)
//IL_0055: Unknown result type (might be due to invalid IL or missing references)
List<RaycastResult> list = new List<RaycastResult>();
PointerEventData val = new PointerEventData(EventSystem.current)
{
position = Vector2.op_Implicit(Input.mousePosition)
};
EventSystem.current.RaycastAll(val, list);
foreach (RaycastResult item in list)
{
RaycastResult current = item;
UIButton componentInParent = ((RaycastResult)(ref current)).gameObject.GetComponentInParent<UIButton>();
if (componentInParent != null)
{
_ = componentInParent.tips;
if (componentInParent.tips.itemId > 0)
{
return componentInParent.tips.itemId;
}
}
UIStorageGrid componentInParent2 = ((RaycastResult)(ref current)).gameObject.GetComponentInParent<UIStorageGrid>();
if ((Object)(object)componentInParent2 != (Object)null)
{
StorageComponent storage = componentInParent2.storage;
int mouseOnX = componentInParent2.mouseOnX;
int mouseOnY = componentInParent2.mouseOnY;
if (mouseOnX >= 0 && mouseOnY >= 0 && storage != null)
{
int num = mouseOnX + mouseOnY * componentInParent2.colCount;
return storage.grids[num].itemId;
}
return 0;
}
UIPlayerDeliveryPanel componentInParent3 = ((RaycastResult)(ref current)).gameObject.GetComponentInParent<UIPlayerDeliveryPanel>();
if ((Object)(object)componentInParent3 != (Object)null && componentInParent3.hoverIndexAbsolute >= 0)
{
return componentInParent3.deliveryPackage.grids[componentInParent3.hoverIndexAbsolute].itemId;
}
UIProductEntry componentInParent4 = ((RaycastResult)(ref current)).gameObject.GetComponentInParent<UIProductEntry>();
if ((Object)(object)componentInParent4 != (Object)null)
{
if (componentInParent4.productionStatWindow.isProductionTab)
{
return componentInParent4.entryData?.itemId ?? 0;
}
return 0;
}
}
return 0;
}
}
}
namespace FactoryLocator.Compat
{
public static class BetterWarningIconsCompat
{
private const string GUID = "dev.raptor.dsp.BetterWarningIcons";
private const int InsufficientInputSignalId = 531;
public static void Preload()
{
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
//IL_0019: 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_002f: 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_0045: Unknown result type (might be due to invalid IL or missing references)
//IL_0055: Expected O, but got Unknown
if (Chainloader.PluginInfos.TryGetValue("dev.raptor.dsp.BetterWarningIcons", out var _))
{
LDBTool.PreAddProto((Proto)new SignalProto
{
ID = 531,
IconPath = "",
Name = "Insufficient Input",
GridIndex = 3601,
description = "Building does not have sufficient inputs to work"
});
}
}
public static void Postload()
{
if (!Chainloader.PluginInfos.TryGetValue("dev.raptor.dsp.BetterWarningIcons", out var _))
{
return;
}
try
{
SetIcon();
}
catch (Exception obj)
{
Log.Warn("BetterWarningIcons compat fail! Last target version: 0.0.5");
Log.Debug(obj);
}
}
private static void SetIcon()
{
//IL_002a: Unknown result type (might be due to invalid IL or missing references)
//IL_0034: Expected O, but got Unknown
SignalProto obj = ((ProtoSet<SignalProto>)(object)LDB.signals).Select(531);
obj._iconSprite = (Sprite)AccessTools.TypeByName("DysonSphereProgram.Modding.BetterWarningIcons.InsufficientInputIconPatch").GetField("iconSprite").GetValue(null);
((Proto)obj).Name = "Insufficient Input";
((Proto)obj).name = Localization.Translate("Insufficient Input");
Log.Debug(((Proto)obj).name);
}
}
public static class DSPMoreRecipesCompat
{
private const string GUID = "Appun.DSP.plugin.MoreRecipes";
public static void Init()
{
if (!Chainloader.PluginInfos.TryGetValue("Appun.DSP.plugin.MoreRecipes", out var _))
{
return;
}
try
{
UIentryCount.RecipeCol = 17;
Log.Debug("DSPMoreRecipes compat - OK");
}
catch (Exception obj)
{
Log.Warn("DSPMoreRecipesCompat fail! Last target version: 1.0.3");
Log.Debug(obj);
}
}
}
public static class GenesisBookCompat
{
private const string GUID = "org.LoShin.GenesisBook";
public static void Init()
{
if (!Chainloader.PluginInfos.TryGetValue("org.LoShin.GenesisBook", out var _))
{
return;
}
try
{
UIentryCount.ItemCol = 17;
UIentryCount.RecipeCol = 17;
UIentryCount.SignalCol = 17;
Log.Debug("GenesisBook compat - OK");
}
catch (Exception obj)
{
Log.Warn("GenesisBook compat fail! Last target version: 2.9.12");
Log.Debug(obj);
}
}
}
public static class NebulaCompat
{
private const string GUID = "dsp.nebula-multiplayer";
private static bool isPatched;
public static bool IsClient { get; private set; }
public static bool SyncWarning { get; set; } = true;
public static void Init()
{
if (!Chainloader.PluginInfos.TryGetValue("dsp.nebula-multiplayer", out var value))
{
return;
}
try
{
Patch();
Log.Debug("Nebula compat - OK");
}
catch (Exception obj)
{
Log.Warn("Nebula hotfix patch fail! Current version: " + value.Metadata.Version);
Log.Debug(obj);
}
}
public static void OnOpen()
{
if (!IsClient)
{
return;
}
SyncWarning = false;
WarningSystem warningSystem = GameMain.data.warningSystem;
warningSystem.warningRecycleCursor = 0;
for (int i = 1; i < warningSystem.warningCursor; i++)
{
if (warningSystem.warningPool[i].id != i)
{
int[] warningRecycle = warningSystem.warningRecycle;
int warningRecycleCursor = warningSystem.warningRecycleCursor;
warningSystem.warningRecycleCursor = warningRecycleCursor + 1;
warningRecycle[warningRecycleCursor] = i;
}
}
}
public static void OnClose()
{
if (IsClient)
{
SyncWarning = true;
SendUpdateRequest();
}
}
[MethodImpl(MethodImplOptions.NoInlining)]
public static void SendUpdateRequest()
{
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
//IL_0015: Expected O, but got Unknown
NebulaModAPI.MultiplayerSession.Network.SendPacket<WarningDataRequest>(new WarningDataRequest((WarningRequestEvent)0));
}
public static void OnUpdate()
{
if (!IsClient)
{
return;
}
WarningSystem warningSystem = GameMain.data.warningSystem;
Array.Clear(warningSystem.warningCounts, 0, warningSystem.warningCounts.Length);
Array.Clear(warningSystem.warningSignals, 0, warningSystem.warningSignals.Length);
warningSystem.warningSignalCount = 0;
for (int i = 1; i < warningSystem.warningCursor; i++)
{
if (warningSystem.warningPool[i].id == i && warningSystem.warningPool[i].state > 0)
{
int signalId = warningSystem.warningPool[i].signalId;
if (warningSystem.warningCounts[signalId] == 0)
{
int[] warningSignals = warningSystem.warningSignals;
int warningSignalCount = warningSystem.warningSignalCount;
warningSystem.warningSignalCount = warningSignalCount + 1;
warningSignals[warningSignalCount] = signalId;
}
warningSystem.warningCounts[signalId]++;
}
}
for (int j = 0; j < warningSystem.warningSignalCount - 1; j++)
{
for (int k = j + 1; k < warningSystem.warningSignalCount; k++)
{
if (warningSystem.warningSignals[j] > warningSystem.warningSignals[k])
{
int num = warningSystem.warningSignals[k];
warningSystem.warningSignals[k] = warningSystem.warningSignals[j];
warningSystem.warningSignals[j] = num;
}
}
}
}
public static void Patch()
{
//IL_0031: Unknown result type (might be due to invalid IL or missing references)
//IL_003f: Expected O, but got Unknown
//IL_0066: Unknown result type (might be due to invalid IL or missing references)
//IL_0074: Expected O, but got Unknown
//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
//IL_00bf: Expected O, but got Unknown
Type type = AccessTools.TypeByName("NebulaWorld.Multiplayer");
Plugin.harmony.Patch((MethodBase)AccessTools.Method(type, "JoinGame", (Type[])null, (Type[])null), new HarmonyMethod(typeof(NebulaCompat).GetMethod("BeforeJoinGame")), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
Plugin.harmony.Patch((MethodBase)AccessTools.Method(type, "LeaveGame", (Type[])null, (Type[])null), new HarmonyMethod(typeof(NebulaCompat).GetMethod("BeforeLeaveGame")), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
type = AccessTools.TypeByName("NebulaPatcher.Patches.Dynamic.WarningSystem_Patch");
MethodInfo methodInfo = AccessTools.Method(type, "CalcFocusDetail_Prefix", (Type[])null, (Type[])null);
if (methodInfo != null)
{
Plugin.harmony.Patch((MethodBase)methodInfo, new HarmonyMethod(typeof(NebulaCompat).GetMethod("Guard")), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
}
}
public static void BeforeJoinGame()
{
//IL_0088: Unknown result type (might be due to invalid IL or missing references)
//IL_0096: Expected O, but got Unknown
//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
//IL_00f5: Expected O, but got Unknown
if (!isPatched)
{
isPatched = true;
try
{
foreach (Assembly item in AccessTools.AllAssemblies())
{
_ = item;
}
MethodInfo methodInfo = AccessTools.Method(AccessTools.TypeByName("NebulaNetwork.PacketProcessors.Warning.WarningDataProcessor"), "ProcessPacket", new Type[2]
{
typeof(WarningDataPacket),
typeof(NebulaConnection)
}, (Type[])null);
Plugin.harmony.Patch((MethodBase)methodInfo, new HarmonyMethod(typeof(NebulaCompat).GetMethod("Guard")), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
methodInfo = AccessTools.Method(AccessTools.TypeByName("NebulaNetwork.PacketProcessors.Warning.WarningSignalProcessor"), "ProcessPacket", new Type[2]
{
typeof(WarningSignalPacket),
typeof(NebulaConnection)
}, (Type[])null);
Plugin.harmony.Patch((MethodBase)methodInfo, new HarmonyMethod(typeof(NebulaCompat).GetMethod("Guard")), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
Log.Info("PacketProcessors patch success!");
}
catch (Exception obj)
{
Log.Warn("PacketProcessors patch fail!");
Log.Warn(obj);
}
}
IsClient = true;
}
public static void BeforeLeaveGame()
{
IsClient = false;
}
public static bool Guard()
{
return SyncWarning;
}
}
}