using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Diagnostics;
using System.Linq;
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.Configuration;
using BepInEx.Logging;
using CommonAPI.Systems;
using FactoryLocator;
using FactoryLocator.UI;
using HarmonyLib;
using NebulaAPI;
using NebulaAPI.DataStructures;
using NebulaAPI.GameState;
using NebulaAPI.Interfaces;
using NebulaAPI.Networking;
using NebulaAPI.Packets;
using NebulaCompatibilityAssist.Analysis;
using NebulaCompatibilityAssist.Hotfix;
using NebulaCompatibilityAssist.Packets;
using NebulaCompatibilityAssist.Patches;
using NebulaModel.DataStructures.Chat;
using NebulaModel.Logger;
using NebulaModel.Packets.Factory.Assembler;
using NebulaModel.Packets.Factory.PowerGenerator;
using NebulaWorld;
using NebulaWorld.Chat.Commands;
using NebulaWorld.MonoBehaviours.Local.Chat;
using PlanetFinderMod;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.UI;
using crecheng.DSPModSave;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyFileVersion("0.4.8")]
[assembly: AssemblyInformationalVersion("0.4.8")]
[assembly: AssemblyProduct("NebulaCompatibilityAssist")]
[assembly: AssemblyTitle("NebulaCompatibilityAssist")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.4.8.0")]
[module: UnverifiableCode]
namespace NebulaCompatibilityAssist
{
[BepInPlugin("NebulaCompatibilityAssist", "NebulaCompatibilityAssist", "0.4.8")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class Plugin : BaseUnityPlugin, IMultiplayerMod
{
public const string GUID = "NebulaCompatibilityAssist";
public const string NAME = "NebulaCompatibilityAssist";
public const string VERSION = "0.4.8";
public static Plugin Instance { get; private set; }
public Harmony Harmony { get; private set; }
public string Version { get; set; }
public void Awake()
{
//IL_0017: Unknown result type (might be due to invalid IL or missing references)
//IL_0021: Expected O, but got Unknown
Instance = this;
Log.LogSource = ((BaseUnityPlugin)this).Logger;
Harmony = new Harmony("NebulaCompatibilityAssist");
NC_Patch.OnAwake();
}
[Conditional("DEBUG")]
public void OnDestroy()
{
NC_Patch.OnDestory();
Harmony.UnpatchSelf();
Harmony = null;
}
public bool CheckVersion(string hostVersion, string clientVersion)
{
return hostVersion.Equals(clientVersion);
}
}
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);
}
[Conditional("DEBUG")]
public static void Dev(object obj)
{
LogSource.LogDebug(obj);
}
[Conditional("DEBUG")]
public static void SlowLog(object obj)
{
if (GameMain.gameTick % 30 == 0L)
{
LogSource.LogDebug(obj);
}
}
}
}
namespace NebulaCompatibilityAssist.Packets
{
public class NC_AllModList
{
public string[] GUIDs { get; set; }
public string[] Names { get; set; }
public string[] Versions { get; set; }
public bool SandboxToolsEnabled { get; set; }
public NC_AllModList()
{
}
public NC_AllModList(int _)
{
int count = Chainloader.PluginInfos.Count;
GUIDs = new string[count];
Names = new string[count];
Versions = new string[count];
int num = 0;
foreach (KeyValuePair<string, PluginInfo> pluginInfo in Chainloader.PluginInfos)
{
GUIDs[num] = pluginInfo.Key;
Names[num] = pluginInfo.Value.Metadata.Name;
Versions[num] = pluginInfo.Value.Metadata.Version.ToString();
num++;
}
SandboxToolsEnabled = GameMain.sandboxToolsEnabled;
}
}
[RegisterPacketProcessor]
internal class NC_AllModListProcessor : BasePacketProcessor<NC_AllModList>
{
public override void ProcessPacket(NC_AllModList packet, INebulaConnection conn)
{
if (base.IsClient)
{
ChatManager.ServerModList = packet;
string report;
int num = ChatManager.CheckModsVersion(out report);
if (num > 0)
{
ChatManager.ShowMessageInChat($"Server mods diff = {num}. Type /info full to see details.");
}
GameMain.sandboxToolsEnabled = packet.SandboxToolsEnabled;
}
}
}
public class NC_LocatorFilter
{
public int AstroId { get; set; }
public int QueryType { get; set; }
public int[] Ids { get; set; }
public int[] Counts { get; set; }
public NC_LocatorFilter()
{
}
public NC_LocatorFilter(int astroId, int queryType, Dictionary<int, int> filter)
{
AstroId = astroId;
QueryType = queryType;
if (filter == null)
{
return;
}
Ids = new int[filter.Count];
Counts = new int[filter.Count];
int num = 0;
foreach (KeyValuePair<int, int> item in filter)
{
Ids[num] = item.Key;
Counts[num++] = item.Value;
}
}
}
[RegisterPacketProcessor]
internal class NC_LocatorFilterProcessor : BasePacketProcessor<NC_LocatorFilter>
{
public override void ProcessPacket(NC_LocatorFilter packet, INebulaConnection conn)
{
FactoryLocator_Patch.OnReceive(packet, conn);
}
}
public class NC_LocatorResult
{
public int AstroId { get; set; }
public int QueryType { get; set; }
public int ProtoId { get; set; }
public int[] PlanetIds { get; set; }
public Float3[] LocalPos { get; set; }
public int[] DetailIds { get; set; }
public NC_LocatorResult()
{
}
public NC_LocatorResult(int astroId, int queryType, int protoId)
{
AstroId = astroId;
QueryType = queryType;
ProtoId = protoId;
PlanetIds = Array.Empty<int>();
LocalPos = Array.Empty<Float3>();
DetailIds = Array.Empty<int>();
}
public NC_LocatorResult(int queryType, List<int> planetIds, List<Vector3> localPos, List<int> detailIds)
{
//IL_0044: Unknown result type (might be due to invalid IL or missing references)
//IL_0049: Unknown result type (might be due to invalid IL or missing references)
//IL_004e: Unknown result type (might be due to invalid IL or missing references)
QueryType = queryType;
PlanetIds = planetIds.ToArray();
DetailIds = detailIds.ToArray();
LocalPos = (Float3[])(object)new Float3[localPos.Count];
for (int i = 0; i < localPos.Count; i++)
{
LocalPos[i] = DataStructureExtensions.ToFloat3(localPos[i]);
}
}
}
[RegisterPacketProcessor]
internal class NC_LocatorResultProcessor : BasePacketProcessor<NC_LocatorResult>
{
public override void ProcessPacket(NC_LocatorResult packet, INebulaConnection conn)
{
FactoryLocator_Patch.OnReceive(packet, conn);
}
}
public class NC_ModSaveData
{
public static Action<string, byte[]> OnReceive;
public string Guid { get; set; }
public byte[] Bytes { get; set; }
public NC_ModSaveData()
{
}
public NC_ModSaveData(string guid, byte[] bytes)
{
Guid = guid;
Bytes = bytes;
}
}
[RegisterPacketProcessor]
internal class NC_ModSaveDataProcessor : BasePacketProcessor<NC_ModSaveData>
{
public override void ProcessPacket(NC_ModSaveData packet, INebulaConnection conn)
{
if (base.IsHost)
{
NebulaModAPI.MultiplayerSession.Network.SendPacketExclude<NC_ModSaveData>(packet, conn);
}
Log.Debug("Receive ModSave Data Packet - " + packet.Guid);
NC_ModSaveData.OnReceive?.Invoke(packet.Guid, packet.Bytes);
}
}
public class NC_ModSaveRequest
{
public static Action<string, INebulaConnection> OnReceive;
public string Guid { get; set; }
public NC_ModSaveRequest()
{
}
public NC_ModSaveRequest(string guid)
{
Guid = guid;
}
}
[RegisterPacketProcessor]
internal class NC_ModSaveRequestProcessor : BasePacketProcessor<NC_ModSaveRequest>
{
public override void ProcessPacket(NC_ModSaveRequest packet, INebulaConnection conn)
{
NC_ModSaveRequest.OnReceive?.Invoke(packet.Guid, conn);
}
}
public class NC_PlanetInfoData
{
public int StarId { get; set; }
public int PlanetId { get; set; }
public long EnergyCapacity { get; set; }
public long EnergyRequired { get; set; }
public long EnergyExchanged { get; set; }
public int NetworkCount { get; set; }
public float[] ConsumerRatios { get; set; }
public int[] ConsumerCounts { get; set; }
public NC_PlanetInfoData()
{
}
public NC_PlanetInfoData(in PlanetData planet)
{
PlanetId = planet.id;
List<float> list = new List<float>();
List<int> list2 = new List<int>();
if (planet.factory?.powerSystem != null)
{
for (int i = 1; i < planet.factory.powerSystem.netCursor; i++)
{
PowerNetwork val = planet.factory.powerSystem.netPool[i];
if (val != null && val.id == i)
{
NetworkCount++;
EnergyCapacity += val.energyCapacity;
EnergyRequired += val.energyRequired;
EnergyExchanged += val.energyExchanged;
list.Add((float)val.consumerRatio);
list2.Add(val.consumers.Count);
}
}
}
ConsumerRatios = list.ToArray();
ConsumerCounts = list2.ToArray();
}
public NC_PlanetInfoData(in StarData star)
{
StarId = star.id;
List<float> list = new List<float>();
List<int> list2 = new List<int>();
for (int i = 0; i < star.planetCount; i++)
{
PlanetData val = star.planets[i];
if (val.factory?.powerSystem == null)
{
continue;
}
for (int j = 1; j < val.factory.powerSystem.netCursor; j++)
{
PowerNetwork val2 = val.factory.powerSystem.netPool[j];
if (val2 != null && val2.id == j)
{
NetworkCount++;
EnergyCapacity += val2.energyCapacity;
EnergyRequired += val2.energyRequired;
EnergyExchanged += val2.energyExchanged;
list.Add((float)val2.consumerRatio);
list2.Add(val2.consumers.Count);
}
}
}
ConsumerRatios = list.ToArray();
ConsumerCounts = list2.ToArray();
}
}
[RegisterPacketProcessor]
internal class NC_PlanetInfoDataProcessor : BasePacketProcessor<NC_PlanetInfoData>
{
public override void ProcessPacket(NC_PlanetInfoData packet, INebulaConnection conn)
{
if (!base.IsHost)
{
if (PlanetFinder_Patch.Enable)
{
PlanetFinder_Patch.OnReceive(packet);
}
if (FactoryLocator_Patch.Enable)
{
FactoryLocator_Patch.OnReceive(packet);
}
}
}
}
public class NC_PlanetInfoRequest
{
public int AstroId { get; set; }
public NC_PlanetInfoRequest()
{
}
public NC_PlanetInfoRequest(int astroId)
{
AstroId = astroId;
}
}
[RegisterPacketProcessor]
internal class NC_PlanetInfoRequestProcessor : BasePacketProcessor<NC_PlanetInfoRequest>
{
public override void ProcessPacket(NC_PlanetInfoRequest packet, INebulaConnection conn)
{
if (base.IsClient)
{
return;
}
if (packet.AstroId == -1)
{
for (int i = 0; i < GameMain.data.factoryCount; i++)
{
PlanetData planet = GameMain.data.factories[i].planet;
conn.SendPacket<NC_PlanetInfoData>(new NC_PlanetInfoData(in planet));
}
}
else
{
if (packet.AstroId <= 0)
{
return;
}
if (packet.AstroId % 100 == 0)
{
StarData star = GameMain.data.galaxy.StarById(packet.AstroId / 100);
Log.Debug(packet.AstroId / 100);
Log.Debug(star);
if (star != null)
{
conn.SendPacket<NC_PlanetInfoData>(new NC_PlanetInfoData(in star));
}
}
else
{
PlanetData planet2 = GameMain.data.galaxy.PlanetById(packet.AstroId);
if (planet2 != null)
{
conn.SendPacket<NC_PlanetInfoData>(new NC_PlanetInfoData(in planet2));
}
}
}
}
}
public class NC_StationConfig
{
public int PlanetId { get; set; }
public int[] StationIds { get; set; }
public long[] MaxChargePower { get; set; }
public double[] MaxTripDrones { get; set; }
public double[] MaxTripVessel { get; set; }
public int[] MinDeliverDrone { get; set; }
public int[] MinDeliverVessel { get; set; }
public double[] WarpDistance { get; set; }
public bool[] WarperNeeded { get; set; }
public bool[] IncludeCollectors { get; set; }
public int[] PilerCount { get; set; }
public int[] MaxMiningSpeed { get; set; }
public NC_StationConfig()
{
}
public NC_StationConfig(in StationComponent station, in PlanetFactory factory)
{
StationComponent[] stations = (StationComponent[])(object)new StationComponent[1] { station };
this..ctor(in stations, in factory);
}
public NC_StationConfig(in StationComponent[] stations, in PlanetFactory factory)
{
int num = ((stations.Length < factory.transport.stationCursor) ? stations.Length : factory.transport.stationCursor);
PlanetId = factory.planetId;
StationIds = new int[num];
MaxChargePower = new long[num];
MaxTripDrones = new double[num];
MaxTripVessel = new double[num];
MinDeliverDrone = new int[num];
MinDeliverVessel = new int[num];
WarpDistance = new double[num];
WarperNeeded = new bool[num];
IncludeCollectors = new bool[num];
PilerCount = new int[num];
MaxMiningSpeed = new int[num];
for (int i = 0; i < num; i++)
{
if (stations[i] != null)
{
StationComponent val = stations[i];
StationIds[i] = val.id;
if (!val.isCollector && !val.isVeinCollector)
{
MaxChargePower[i] = factory.powerSystem.consumerPool[val.pcId].workEnergyPerTick;
}
MaxTripDrones[i] = val.tripRangeDrones;
MaxTripVessel[i] = val.tripRangeShips;
MinDeliverDrone[i] = val.deliveryDrones;
MinDeliverVessel[i] = val.deliveryShips;
WarpDistance[i] = val.warpEnableDist;
WarperNeeded[i] = val.warperNecessary;
IncludeCollectors[i] = val.includeOrbitCollector;
PilerCount[i] = val.pilerCount;
if (val.isVeinCollector)
{
MaxMiningSpeed[i] = factory.factorySystem.minerPool[val.minerId].speed;
}
}
}
}
}
[RegisterPacketProcessor]
internal class NC_StationConfigProcessor : BasePacketProcessor<NC_StationConfig>
{
public override void ProcessPacket(NC_StationConfig packet, INebulaConnection conn)
{
PlanetFactory val = GameMain.galaxy.PlanetById(packet.PlanetId)?.factory;
if (val == null)
{
return;
}
Log.Debug($"Update stations config on {packet.PlanetId}: {packet.StationIds.Length}");
StationComponent[] stationPool = val.transport.stationPool;
for (int i = 0; i < packet.StationIds.Length; i++)
{
if (packet.StationIds[i] == 0)
{
continue;
}
StationComponent val2 = stationPool[packet.StationIds[i]];
if (val2 == null)
{
Log.Warn($"Station {i} doesn't exist!");
continue;
}
if (!val2.isCollector && !val2.isVeinCollector)
{
val.powerSystem.consumerPool[val2.pcId].workEnergyPerTick = packet.MaxChargePower[i];
}
val2.tripRangeDrones = packet.MaxTripDrones[i];
val2.tripRangeShips = packet.MaxTripVessel[i];
val2.deliveryDrones = packet.MinDeliverDrone[i];
val2.deliveryShips = packet.MinDeliverVessel[i];
val2.warpEnableDist = packet.WarpDistance[i];
val2.warperNecessary = packet.WarperNeeded[i];
val2.includeOrbitCollector = packet.IncludeCollectors[i];
val2.pilerCount = packet.PilerCount[i];
if (val2.isVeinCollector)
{
val.factorySystem.minerPool[val2.minerId].speed = packet.MaxMiningSpeed[i];
}
}
UIStationWindow stationWindow = UIRoot.instance.uiGame.stationWindow;
if ((Object)(object)stationWindow != (Object)null && ((ManualBehaviour)stationWindow).active && stationWindow.factory == val)
{
stationWindow.OnStationIdChange();
}
}
}
public class NC_StationShipCount
{
public int PlanetId { get; set; }
public int[] StationIds { get; set; }
public int[] WarperCount { get; set; }
public int[] DroneCount { get; set; }
public int[] ShipCount { get; set; }
public NC_StationShipCount()
{
}
public NC_StationShipCount(StationComponent station, int planetId)
: this((StationComponent[])(object)new StationComponent[1] { station }, planetId)
{
}
public NC_StationShipCount(StationComponent[] stations, int planetId)
{
PlanetId = planetId;
StationIds = new int[stations.Length];
WarperCount = new int[stations.Length];
DroneCount = new int[stations.Length];
ShipCount = new int[stations.Length];
for (int i = 0; i < stations.Length; i++)
{
if (stations[i] != null)
{
StationComponent val = stations[i];
StationIds[i] = val.id;
WarperCount[i] = val.warperCount;
DroneCount[i] = val.idleDroneCount + val.workDroneCount;
ShipCount[i] = val.idleShipCount + val.workShipCount;
}
}
}
}
[RegisterPacketProcessor]
internal class NC_StationItemCountProcessor : BasePacketProcessor<NC_StationShipCount>
{
public override void ProcessPacket(NC_StationShipCount packet, INebulaConnection conn)
{
PlanetFactory val = GameMain.galaxy.PlanetById(packet.PlanetId)?.factory;
if (val == null)
{
return;
}
Log.Debug($"Update stations ship count on {packet.PlanetId}: {packet.StationIds.Length}");
StationComponent[] stationPool = val.transport.stationPool;
for (int i = 0; i < packet.StationIds.Length; i++)
{
if (packet.StationIds[i] != 0)
{
StationComponent val2 = stationPool[packet.StationIds[i]];
if (val2 == null)
{
Log.Warn($"Station {i} doesn't exist!");
continue;
}
val2.warperCount = packet.WarperCount[i];
val2.idleDroneCount = packet.DroneCount[i] - val2.workDroneCount;
val2.idleShipCount = packet.ShipCount[i] - val2.workShipCount;
}
}
UIStationWindow stationWindow = UIRoot.instance.uiGame.stationWindow;
if ((Object)(object)stationWindow != (Object)null && ((ManualBehaviour)stationWindow).active && stationWindow.factory == val)
{
stationWindow.OnStationIdChange();
}
}
}
public class NC_StationStorageData
{
public static Action OnReceive;
public int[] StationGId { get; set; }
public int[] StorageLength { get; set; }
public bool[] IsCollector { get; set; }
public int[] ItemId { get; set; }
public int[] Max { get; set; }
public int[] Count { get; set; }
public int[] Inc { get; set; }
public int[] RemoteOrder { get; set; }
public byte[] Logic { get; set; }
public NC_StationStorageData()
{
//IL_011d: Unknown result type (might be due to invalid IL or missing references)
//IL_0122: Unknown result type (might be due to invalid IL or missing references)
//IL_012f: Unknown result type (might be due to invalid IL or missing references)
//IL_0142: 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_0168: Unknown result type (might be due to invalid IL or missing references)
//IL_017b: 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)
//IL_0190: Unknown result type (might be due to invalid IL or missing references)
StationComponent[] stationPool = GameMain.data.galacticTransport.stationPool;
List<int> list = new List<int>();
List<int> list2 = new List<int>();
List<bool> list3 = new List<bool>();
int num = 0;
int num2 = 0;
StationComponent[] array = stationPool;
foreach (StationComponent val in array)
{
if (val != null)
{
list.Add(val.gid);
list2.Add(val.storage.Length);
list3.Add(val.isCollector);
num += val.storage.Length;
}
}
StationGId = list.ToArray();
StorageLength = list2.ToArray();
IsCollector = list3.ToArray();
ItemId = new int[num];
Max = new int[num];
Count = new int[num];
Inc = new int[num];
RemoteOrder = new int[num];
Logic = new byte[num];
for (int j = 0; j < list.Count; j++)
{
StationComponent val2 = stationPool[list[j]];
for (int k = 0; k < list2[j]; k++)
{
StationStore val3 = val2.storage[k];
ItemId[num2 + k] = val3.itemId;
Max[num2 + k] = val3.max;
Count[num2 + k] = val3.count;
Inc[num2 + k] = val3.inc;
RemoteOrder[num2 + k] = val3.remoteOrder;
Logic[num2 + k] = (byte)val3.remoteLogic;
}
num2 += list2[j];
}
}
}
[RegisterPacketProcessor]
internal class NC_StationStorageReponseProcessor : BasePacketProcessor<NC_StationStorageData>
{
public override void ProcessPacket(NC_StationStorageData packet, INebulaConnection conn)
{
//IL_013d: Unknown result type (might be due to invalid IL or missing references)
if (base.IsHost)
{
return;
}
int num = 0;
StationComponent[] stationPool = GameMain.data.galacticTransport.stationPool;
for (int i = 0; i < packet.StationGId.Length; i++)
{
StationComponent val = stationPool[packet.StationGId[i]];
if (val == null)
{
Log.Warn($"Gid {packet.StationGId[i]} does not in client");
continue;
}
if (val.storage == null || val.storage.Length < packet.StorageLength[i])
{
val.storage = (StationStore[])(object)new StationStore[packet.StorageLength[i]];
}
val.isCollector = packet.IsCollector[i];
for (int j = 0; j < packet.StorageLength[i]; j++)
{
val.storage[j].itemId = packet.ItemId[num + j];
val.storage[j].max = packet.Max[num + j];
val.storage[j].count = packet.Count[num + j];
val.storage[j].inc = packet.Inc[num + j];
val.storage[j].remoteOrder = packet.RemoteOrder[num + j];
val.storage[j].remoteLogic = (ELogisticStorage)packet.Logic[num + j];
}
num += packet.StorageLength[i];
}
StationComponent[] array = stationPool;
foreach (StationComponent val2 in array)
{
if (val2 != null && val2.storage == null)
{
Log.Warn($"Gid {val2.gid} does not in server");
}
}
NC_StationStorageData.OnReceive?.Invoke();
}
}
public class NC_StationStorageRequest
{
}
[RegisterPacketProcessor]
internal class NC_StationStorageRequestProcessor : BasePacketProcessor<NC_StationStorageRequest>
{
public override void ProcessPacket(NC_StationStorageRequest packet, INebulaConnection conn)
{
if (base.IsHost)
{
conn.SendPacket<NC_StationStorageData>(new NC_StationStorageData());
}
}
}
}
namespace NebulaCompatibilityAssist.Patches
{
public static class NC_Patch
{
public static bool IsClient;
public static Action OnLogin;
public static string RequriedPlugins = "";
public static string ErrorMessage = "";
public static bool initialized = false;
public static void OnAwake()
{
NebulaModAPI.RegisterPackets(Assembly.GetExecutingAssembly());
Plugin.Instance.Harmony.PatchAll(typeof(NC_Patch));
}
[HarmonyPostfix]
[HarmonyPatch(typeof(VFPreload), "InvokeOnLoadWorkEnded")]
public static void Init()
{
if (!initialized)
{
Harmony harmony = Plugin.Instance.Harmony;
ConfigFile config = ((BaseUnityPlugin)Plugin.Instance).Config;
LSTM.Init(harmony);
if (config.Bind<bool>("Sync Patch", "DSPStarMapMemo", true, "Enable patching DSPStarMapMemo").Value)
{
DSPStarMapMemo.Init(harmony);
}
PlanetFinder_Patch.Init(harmony);
DSPFreeMechaCustom.Init(harmony);
AutoStationConfig.Init(harmony);
Auxilaryfunction.Init(harmony);
DSPOptimizations.Init(harmony);
FactoryLocator_Patch.Init(harmony);
SplitterOverBelt.Init(harmony);
if (config.Bind<bool>("Sync Patch", "MoreMegaStructure", true, "Enable patching MoreMegaStructure").Value)
{
MoreMegaStructure.Init(harmony);
}
BlueprintTweaks.Init(harmony);
DSPAutoSorter.Init(harmony);
if (config.Bind<bool>("Sync Patch", "AssemblerVerticalConstruction", true, "Enable patching AssemblerVerticalConstruction").Value)
{
AssemblerVerticalConstruction.Init(harmony);
}
if (config.Bind<bool>("Sync Patch", "DSP_Battle", true, "Enable patching TheyComeFromVoid").Value)
{
DSP_Battle_Patch.Init(harmony);
}
NebulaHotfix.Init(harmony);
string text = (Localization.isZHCN ? "联机补丁提示" : "Nebula Compatibility Assist Report");
string text2 = (Localization.isZHCN ? "修改以下mod时出错, 在联机模式中可能无法正常运行" : "Error occurred when patching the following mods:");
string incompatMessage = (Localization.isZHCN ? "以下mod和联机mod不相容, 可能将导致错误或不同步\n" : "The following mods are not compatible with multiplayer mod:\n");
string warnMessage = (Localization.isZHCN ? "以下mod的部分功能可能导致联机不同步\n" : "The following mods have some functions that don't sync in multiplayer game:\n");
string text3 = "";
if (ErrorMessage != "")
{
text2 += ErrorMessage;
text3 = text3 + text2 + "\n";
}
if (TestIncompatMods(ref incompatMessage))
{
text3 += incompatMessage;
}
if (TestWarnMods(ref warnMessage))
{
text3 += warnMessage;
}
if (!string.IsNullOrEmpty(text3))
{
UIMessageBox.Show(text, text3, Localization.Translate("确定"), 3);
}
initialized = true;
Plugin.Instance.Version = "0.4.8" + RequriedPlugins;
Log.Debug("Version: " + Plugin.Instance.Version);
}
}
public static void OnDestory()
{
ChatManager.OnDestory();
}
[HarmonyPostfix]
[HarmonyPatch(typeof(GameMain), "Begin")]
public static void OnGameBegin()
{
if (NebulaModAPI.IsMultiplayerActive && NebulaModAPI.MultiplayerSession.LocalPlayer.IsClient)
{
Log.Debug("OnLogin");
IsClient = true;
OnLogin?.Invoke();
}
else
{
IsClient = false;
}
}
private static bool TestIncompatMods(ref string incompatMessage)
{
int num = 0;
if (Chainloader.PluginInfos.ContainsKey("semarware.dysonsphereprogram.LongArm"))
{
incompatMessage += "LongArm\n";
num++;
}
if (Chainloader.PluginInfos.ContainsKey("greyhak.dysonsphereprogram.droneclearing"))
{
incompatMessage += "DSP Drone Clearing\n";
num++;
}
if (Chainloader.PluginInfos.ContainsKey("com.small.dsp.transferInfo"))
{
incompatMessage += "TransferInfo\n";
num++;
}
if (Chainloader.PluginInfos.ContainsKey("greyhak.dysonsphereprogram.beltreversedirection"))
{
incompatMessage += "DSP Belt Reverse\n";
num++;
}
return num > 0;
}
private static bool TestWarnMods(ref string warnMessage)
{
int num = 0;
if (Chainloader.PluginInfos.ContainsKey("cn.blacksnipe.dsp.Multfuntion_mod"))
{
warnMessage += "Multfuntion mod\n";
num++;
}
if (Chainloader.PluginInfos.ContainsKey("org.soardev.cheatenabler"))
{
warnMessage += "CheatEnabler\n";
num++;
}
return num > 0;
}
}
public static class AssemblerVerticalConstruction
{
private const string NAME = "AssemblerVerticalConstruction";
private const string GUID = "lltcggie.DSP.plugin.AssemblerVerticalConstruction";
private const string VERSION = "1.1.4";
private static IModCanSave Save;
public static void Init(Harmony harmony)
{
//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
//IL_00f7: Expected O, but got Unknown
//IL_0126: Unknown result type (might be due to invalid IL or missing references)
//IL_0134: Expected O, but got Unknown
if (!Chainloader.PluginInfos.TryGetValue("lltcggie.DSP.plugin.AssemblerVerticalConstruction", out var value))
{
return;
}
Assembly assembly = ((object)value.Instance).GetType().Assembly;
try
{
BaseUnityPlugin instance = value.Instance;
Save = (IModCanSave)(object)((instance is IModCanSave) ? instance : null);
NC_Patch.OnLogin = (Action)Delegate.Combine(NC_Patch.OnLogin, new Action(SendRequest));
NC_ModSaveRequest.OnReceive = (Action<string, INebulaConnection>)Delegate.Combine(NC_ModSaveRequest.OnReceive, (Action<string, INebulaConnection>)delegate(string guid, INebulaConnection conn)
{
if (!(guid != "lltcggie.DSP.plugin.AssemblerVerticalConstruction"))
{
conn.SendPacket<NC_ModSaveData>(new NC_ModSaveData("lltcggie.DSP.plugin.AssemblerVerticalConstruction", Export()));
}
});
NC_ModSaveData.OnReceive = (Action<string, byte[]>)Delegate.Combine(NC_ModSaveData.OnReceive, (Action<string, byte[]>)delegate(string guid, byte[] bytes)
{
if (!(guid != "lltcggie.DSP.plugin.AssemblerVerticalConstruction"))
{
Import(bytes);
}
});
Type type = assembly.GetType("AssemblerVerticalConstruction.AssemblerPatches");
harmony.Patch((MethodBase)AccessTools.Method(type, "SyncAssemblerFunctions", (Type[])null, (Type[])null), new HarmonyMethod(typeof(AssemblerVerticalConstruction).GetMethod("SyncAssemblerFunctions_Prefix")), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
type = assembly.GetType("AssemblerVerticalConstruction.AssemblerComponentEx");
harmony.Patch((MethodBase)AccessTools.Method(type, "UpdateOutputToNextInner", (Type[])null, (Type[])null), new HarmonyMethod(typeof(AssemblerVerticalConstruction).GetMethod("UpdateOutputToNextInner_Prefix")), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
Log.Info("AssemblerVerticalConstruction - OK");
}
catch (Exception obj)
{
Log.Warn("AssemblerVerticalConstruction - Fail! Last target version: 1.1.4");
NC_Patch.ErrorMessage += "\nAssemblerVerticalConstruction (last target version: 1.1.4)";
Log.Debug(obj);
}
}
public static void SendRequest()
{
if (NebulaModAPI.IsMultiplayerActive && NebulaModAPI.MultiplayerSession.LocalPlayer.IsClient)
{
NebulaModAPI.MultiplayerSession.Network.SendPacket<NC_ModSaveRequest>(new NC_ModSaveRequest("lltcggie.DSP.plugin.AssemblerVerticalConstruction"));
}
}
public static void SendData()
{
if (NebulaModAPI.IsMultiplayerActive)
{
NebulaModAPI.MultiplayerSession.Network.SendPacket<NC_ModSaveData>(new NC_ModSaveData("lltcggie.DSP.plugin.AssemblerVerticalConstruction", Export()));
}
}
public static byte[] Export()
{
if (Save != null)
{
IWriterProvider binaryWriter = NebulaModAPI.GetBinaryWriter();
try
{
Save.Export(binaryWriter.BinaryWriter);
return binaryWriter.CloseAndGetBytes();
}
finally
{
((IDisposable)binaryWriter)?.Dispose();
}
}
return new byte[0];
}
public static void Import(byte[] bytes)
{
if (Save != null)
{
IReaderProvider binaryReader = NebulaModAPI.GetBinaryReader(bytes);
try
{
Save.Import(binaryReader.BinaryReader);
}
finally
{
((IDisposable)binaryReader)?.Dispose();
}
}
}
public static bool SyncAssemblerFunctions_Prefix(FactorySystem factorySystem, Player player, int assemblerId)
{
//IL_0163: Unknown result type (might be due to invalid IL or missing references)
//IL_016d: Expected O, but got Unknown
//IL_0104: Unknown result type (might be due to invalid IL or missing references)
//IL_010e: Expected O, but got Unknown
//IL_02dc: Unknown result type (might be due to invalid IL or missing references)
//IL_02e6: Expected O, but got Unknown
//IL_026e: Unknown result type (might be due to invalid IL or missing references)
//IL_0278: Expected O, but got Unknown
int entityId = factorySystem.assemblerPool[assemblerId].entityId;
if (entityId == 0)
{
return false;
}
int num = entityId;
bool flag = default(bool);
int num2 = default(int);
int num3 = default(int);
do
{
factorySystem.factory.ReadObjectConn(num, 14, ref flag, ref num2, ref num3);
num = num2;
if (num <= 0)
{
continue;
}
int assemblerId2 = factorySystem.factory.entityPool[num].assemblerId;
if (assemblerId2 <= 0 || factorySystem.assemblerPool[assemblerId2].id != assemblerId2)
{
continue;
}
if (factorySystem.assemblerPool[assemblerId].recipeId > 0)
{
if (factorySystem.assemblerPool[assemblerId2].recipeId != factorySystem.assemblerPool[assemblerId].recipeId)
{
factorySystem.TakeBackItems_Assembler(player, assemblerId2);
int recipeId = factorySystem.assemblerPool[assemblerId].recipeId;
((AssemblerComponent)(ref factorySystem.assemblerPool[assemblerId2])).SetRecipe(recipeId, factorySystem.factory.entitySignPool);
Multiplayer.Session.Network.SendPacketToLocalStar<AssemblerRecipeEventPacket>(new AssemblerRecipeEventPacket(factorySystem.planet.id, assemblerId2, recipeId));
}
}
else if (factorySystem.assemblerPool[assemblerId2].recipeId != 0)
{
factorySystem.TakeBackItems_Assembler(player, assemblerId2);
((AssemblerComponent)(ref factorySystem.assemblerPool[assemblerId2])).SetRecipe(0, factorySystem.factory.entitySignPool);
Multiplayer.Session.Network.SendPacketToLocalStar<AssemblerRecipeEventPacket>(new AssemblerRecipeEventPacket(factorySystem.planet.id, assemblerId2, 0));
}
}
while (num != 0);
num = entityId;
int num4 = default(int);
do
{
factorySystem.factory.ReadObjectConn(num, 15, ref flag, ref num4, ref num3);
num = num4;
if (num <= 0)
{
continue;
}
int assemblerId3 = factorySystem.factory.entityPool[num].assemblerId;
if (assemblerId3 <= 0 || factorySystem.assemblerPool[assemblerId3].id != assemblerId3)
{
continue;
}
if (factorySystem.assemblerPool[assemblerId].recipeId > 0)
{
if (factorySystem.assemblerPool[assemblerId3].recipeId != factorySystem.assemblerPool[assemblerId].recipeId)
{
factorySystem.TakeBackItems_Assembler(factorySystem.factory.gameData.mainPlayer, assemblerId3);
int recipeId2 = factorySystem.assemblerPool[assemblerId].recipeId;
((AssemblerComponent)(ref factorySystem.assemblerPool[assemblerId3])).SetRecipe(recipeId2, factorySystem.factory.entitySignPool);
Multiplayer.Session.Network.SendPacketToLocalStar<AssemblerRecipeEventPacket>(new AssemblerRecipeEventPacket(factorySystem.planet.id, assemblerId3, recipeId2));
}
}
else if (factorySystem.assemblerPool[assemblerId3].recipeId != 0)
{
factorySystem.TakeBackItems_Assembler(factorySystem.factory.gameData.mainPlayer, assemblerId3);
((AssemblerComponent)(ref factorySystem.assemblerPool[assemblerId3])).SetRecipe(0, factorySystem.factory.entitySignPool);
Multiplayer.Session.Network.SendPacketToLocalStar<AssemblerRecipeEventPacket>(new AssemblerRecipeEventPacket(factorySystem.planet.id, assemblerId3, 0));
}
}
while (num != 0);
return false;
}
public static bool UpdateOutputToNextInner_Prefix(int assemblerNextId, AssemblerComponent[] assemblerPool)
{
if (assemblerPool[assemblerNextId].timeSpend == 0)
{
return false;
}
return true;
}
}
public static class AutoStationConfig
{
public const string NAME = "AutoStationConfig";
public const string GUID = "pasukaru.dsp.AutoStationConfig";
public const string VERSION = "1.4.0";
public static void Init(Harmony harmony)
{
//IL_0053: 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_0079: Expected O, but got Unknown
//IL_0079: Expected O, but got Unknown
if (!Chainloader.PluginInfos.TryGetValue("pasukaru.dsp.AutoStationConfig", out var value))
{
return;
}
Assembly assembly = ((object)value.Instance).GetType().Assembly;
try
{
Type type = assembly.GetType("Pasukaru.DSP.AutoStationConfig.PlanetTransportPatch");
harmony.Patch((MethodBase)AccessTools.Method(type, "NewStationComponent", (Type[])null, (Type[])null), new HarmonyMethod(typeof(AutoStationConfig).GetMethod("NewStationComponent_Prefix")), new HarmonyMethod(typeof(AutoStationConfig).GetMethod("NewStationComponent_Postfix")), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
Log.Info("AutoStationConfig - OK");
}
catch (Exception obj)
{
Log.Warn("AutoStationConfig - Fail! Last target version: 1.4.0");
NC_Patch.ErrorMessage += "\nAutoStationConfig (last target version: 1.4.0)";
Log.Debug(obj);
}
}
public static bool NewStationComponent_Prefix()
{
if (!NebulaModAPI.IsMultiplayerActive)
{
return true;
}
IFactoryManager factories = NebulaModAPI.MultiplayerSession.Factories;
if (factories.PacketAuthor != NebulaModAPI.MultiplayerSession.LocalPlayer.Id)
{
if (NebulaModAPI.MultiplayerSession.LocalPlayer.IsHost)
{
return factories.PacketAuthor == -1;
}
return false;
}
return true;
}
public static void NewStationComponent_Postfix(PlanetTransport __0, StationComponent __1, bool __runOriginal)
{
if (NebulaModAPI.IsMultiplayerActive && __runOriginal)
{
PlanetFactory factory = __0.factory;
NebulaModAPI.MultiplayerSession.Network.SendPacketToLocalStar<NC_StationConfig>(new NC_StationConfig(in __1, in factory));
NebulaModAPI.MultiplayerSession.Network.SendPacketToLocalStar<NC_StationShipCount>(new NC_StationShipCount(__1, factory.planetId));
}
}
}
public static class Auxilaryfunction
{
public const string NAME = "Auxilaryfunction";
public const string GUID = "cn.blacksnipe.dsp.Auxilaryfunction";
public const string VERSION = "2.5.3";
private static ConfigEntry<bool> stationcopyItem_bool;
private static ConfigEntry<bool> auto_supply_station;
public static void Init(Harmony harmony)
{
//IL_0094: Unknown result type (might be due to invalid IL or missing references)
//IL_00a1: Expected O, but got Unknown
//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
//IL_00d2: Expected O, but got Unknown
//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
//IL_0103: Expected O, but got Unknown
//IL_0127: Unknown result type (might be due to invalid IL or missing references)
//IL_0134: Expected O, but got Unknown
//IL_0163: Unknown result type (might be due to invalid IL or missing references)
//IL_017c: Unknown result type (might be due to invalid IL or missing references)
//IL_0189: Expected O, but got Unknown
//IL_0189: Expected O, but got Unknown
//IL_01ac: Unknown result type (might be due to invalid IL or missing references)
//IL_01ba: Expected O, but got Unknown
if (!Chainloader.PluginInfos.TryGetValue("cn.blacksnipe.dsp.Auxilaryfunction", out var value))
{
return;
}
Assembly assembly = ((object)value.Instance).GetType().Assembly;
try
{
Type type = assembly.GetType("Auxilaryfunction.Auxilaryfunction");
stationcopyItem_bool = (ConfigEntry<bool>)AccessTools.Field(type, "stationcopyItem_bool").GetValue(value.Instance);
auto_supply_station = (ConfigEntry<bool>)AccessTools.Field(type, "auto_supply_station").GetValue(value.Instance);
harmony.Patch((MethodBase)AccessTools.Method(type, "AddDroneShipToStation", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(typeof(Auxilaryfunction).GetMethod("AddDroneShiptooldstation_Postfix")), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
harmony.Patch((MethodBase)AccessTools.Method(type, "ChangeAllStationConfig", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(typeof(Auxilaryfunction).GetMethod("Changeallstationconfig_Postfix")), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
harmony.Patch((MethodBase)AccessTools.Method(type, "ChangeAllVeinCollectorSpeedConfig", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(typeof(Auxilaryfunction).GetMethod("Changeallstationconfig_Postfix")), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
harmony.Patch((MethodBase)AccessTools.Method(type, "AddFuelToAllStar", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(typeof(Auxilaryfunction).GetMethod("AddfueltoallStar_Postfix")), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
type = assembly.GetType("Auxilaryfunction.AuxilaryfunctionPatch");
harmony.Patch((MethodBase)AccessTools.Method(type, "NewStationComponentPatch", (Type[])null, (Type[])null), new HarmonyMethod(typeof(Auxilaryfunction).GetMethod("NewStationComponent_Prefix")), new HarmonyMethod(typeof(Auxilaryfunction).GetMethod("NewStationComponent_Postfix")), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
harmony.Patch((MethodBase)AccessTools.Method(type, "PasteToFactoryObjectPatch", (Type[])null, (Type[])null), new HarmonyMethod(typeof(Auxilaryfunction).GetMethod("PasteToFactoryObject_Prefix")), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
Log.Info("Auxilaryfunction - OK");
}
catch (Exception obj)
{
Log.Warn("Auxilaryfunction - Fail! Last target version: 2.5.3");
NC_Patch.ErrorMessage += "\nAuxilaryfunction (last target version: 2.5.3)";
Log.Debug(obj);
}
}
public static void AddDroneShiptooldstation_Postfix()
{
if (NebulaModAPI.IsMultiplayerActive && GameMain.localPlanet?.factory != null)
{
NebulaModAPI.MultiplayerSession.Network.SendPacketToLocalStar<NC_StationShipCount>(new NC_StationShipCount(GameMain.localPlanet.factory.transport.stationPool, GameMain.localPlanet.id));
}
}
public static void Changeallstationconfig_Postfix()
{
if (NebulaModAPI.IsMultiplayerActive && GameMain.localPlanet?.factory != null)
{
NebulaModAPI.MultiplayerSession.Network.SendPacketToLocalStar<NC_StationConfig>(new NC_StationConfig(in GameMain.localPlanet.factory.transport.stationPool, in GameMain.localPlanet.factory));
}
}
public static void AddfueltoallStar_Postfix()
{
//IL_0035: Unknown result type (might be due to invalid IL or missing references)
//IL_003a: Unknown result type (might be due to invalid IL or missing references)
//IL_003b: Unknown result type (might be due to invalid IL or missing references)
//IL_004e: Unknown result type (might be due to invalid IL or missing references)
//IL_0054: Unknown result type (might be due to invalid IL or missing references)
//IL_005a: Unknown result type (might be due to invalid IL or missing references)
//IL_0060: Unknown result type (might be due to invalid IL or missing references)
//IL_0070: Unknown result type (might be due to invalid IL or missing references)
//IL_007a: Expected O, but got Unknown
if (!NebulaModAPI.IsMultiplayerActive || GameMain.localPlanet?.factory == null)
{
return;
}
PowerGeneratorComponent[] genPool = GameMain.localPlanet.factory.powerSystem.genPool;
foreach (PowerGeneratorComponent val in genPool)
{
if (val.fuelMask == 4)
{
NebulaModAPI.MultiplayerSession.Network.SendPacketToLocalStar<PowerGeneratorFuelUpdatePacket>(new PowerGeneratorFuelUpdatePacket(val.id, (int)val.fuelId, val.fuelCount, val.fuelInc, GameMain.localPlanet.id));
}
}
}
public static bool NewStationComponent_Prefix()
{
if (!auto_supply_station.Value)
{
return false;
}
if (!NebulaModAPI.IsMultiplayerActive)
{
return true;
}
IFactoryManager factories = NebulaModAPI.MultiplayerSession.Factories;
if (factories.PacketAuthor != NebulaModAPI.MultiplayerSession.LocalPlayer.Id)
{
if (NebulaModAPI.MultiplayerSession.LocalPlayer.IsHost)
{
return factories.PacketAuthor == -1;
}
return false;
}
return true;
}
public static void NewStationComponent_Postfix(StationComponent __0, PlanetTransport __1, bool __runOriginal)
{
if (NebulaModAPI.IsMultiplayerActive && __runOriginal)
{
PlanetFactory factory = __1.factory;
NebulaModAPI.MultiplayerSession.Network.SendPacketToLocalStar<NC_StationConfig>(new NC_StationConfig(in __0, in factory));
NebulaModAPI.MultiplayerSession.Network.SendPacketToLocalStar<NC_StationShipCount>(new NC_StationShipCount(__0, factory.planetId));
}
}
public static bool PasteToFactoryObject_Prefix()
{
if (!stationcopyItem_bool.Value)
{
return false;
}
if (!NebulaModAPI.IsMultiplayerActive)
{
return true;
}
return !NebulaModAPI.MultiplayerSession.Factories.IsIncomingRequest.Value;
}
}
public static class BlueprintTweaks
{
public const string NAME = "BlueprintTweaks";
public const string GUID = "org.kremnev8.plugin.BlueprintTweaks";
public const string VERSION = "1.6.3";
public static void Init(Harmony _)
{
if (!Chainloader.PluginInfos.TryGetValue("org.kremnev8.plugin.BlueprintTweaks", out var value))
{
return;
}
Assembly assembly = ((object)value.Instance).GetType().Assembly;
try
{
((ConfigEntry<bool>)AccessTools.Field(assembly.GetType("BlueprintTweaks.BlueprintTweaksPlugin"), "useFastDismantle").GetValue(value.Instance)).Value = false;
Log.Info("BlueprintTweaks - OK");
}
catch (Exception obj)
{
Log.Warn("BlueprintTweaks - Fail! Last target version: 1.6.3");
NC_Patch.ErrorMessage += "\nBlueprintTweaks (last target version: 1.6.3)";
Log.Debug(obj);
}
}
}
public static class DSPAutoSorter
{
public const string NAME = "DSPAutoSorter";
public const string GUID = "Appun.DSP.plugin.AutoSorter";
public const string VERSION = "1.2.11";
public static void Init(Harmony harmony)
{
//IL_0053: Unknown result type (might be due to invalid IL or missing references)
//IL_0061: Expected O, but got Unknown
if (!Chainloader.PluginInfos.TryGetValue("Appun.DSP.plugin.AutoSorter", out var value))
{
return;
}
Assembly assembly = ((object)value.Instance).GetType().Assembly;
try
{
Type type = assembly.GetType("DSPAutoSorter.DSPAutoSorter");
harmony.Patch((MethodBase)AccessTools.Method(type, "UIStorageWindow_OnOpen_Postfix", (Type[])null, (Type[])null), new HarmonyMethod(typeof(DSPAutoSorter).GetMethod("Block")), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
Log.Info("DSPAutoSorter - OK");
}
catch (Exception obj)
{
Log.Warn("DSPAutoSorter - Fail! Last target version: 1.2.11");
NC_Patch.ErrorMessage += "\nDSPAutoSorter (last target version: 1.2.11)";
Log.Debug(obj);
}
}
public static bool Block()
{
if (!NebulaModAPI.IsMultiplayerActive)
{
return true;
}
return false;
}
}
public static class DSPFreeMechaCustom
{
private const string NAME = "DSPFreeMechaCustom";
private const string GUID = "Appun.DSP.plugin.FreeMechaCustom";
private const string VERSION = "0.0.2";
public static void Init(Harmony harmony)
{
if (!Chainloader.PluginInfos.TryGetValue("Appun.DSP.plugin.FreeMechaCustom", out var _))
{
return;
}
try
{
harmony.PatchAll(typeof(DSPFreeMechaCustom));
Log.Info("DSPFreeMechaCustom - OK");
}
catch (Exception obj)
{
Log.Warn("DSPFreeMechaCustom - Fail! Last target version: 0.0.2");
NC_Patch.ErrorMessage += "\nDSPFreeMechaCustom (last target version: 0.0.2)";
Log.Debug(obj);
}
}
[HarmonyPrefix]
[HarmonyPatch(typeof(UIMechaEditor), "ApplyMechaAppearance")]
public static bool ApplyMechaAppearance_Prefix()
{
return false;
}
[HarmonyPostfix]
[HarmonyPatch(typeof(UIMechaMatsGroup), "OnApplyClick")]
public static void OnApplyClick_Postfix(UIMechaMatsGroup __instance)
{
__instance.mechaEditor.ApplyMechaAppearance();
}
}
public static class DSPOptimizations
{
public const string NAME = "DSPOptimizations";
public const string GUID = "com.Selsion.DSPOptimizations";
public const string VERSION = "1.1.16";
private static Action<GameData> InitFactoryInfo;
public static void Init(Harmony harmony)
{
if (!Chainloader.PluginInfos.TryGetValue("com.Selsion.DSPOptimizations", out var value))
{
return;
}
Assembly assembly = ((object)value.Instance).GetType().Assembly;
try
{
InitFactoryInfo = AccessTools.MethodDelegate<Action<GameData>>(AccessTools.Method(assembly.GetType("DSPOptimizations.StationStorageOpt"), "InitFactoryInfo", (Type[])null, (Type[])null), (object)null, true);
harmony.PatchAll(typeof(DSPOptimizations));
Log.Info("DSPOptimizations - OK");
}
catch (Exception obj)
{
Log.Warn("DSPOptimizations - Fail! Last target version: 1.1.16");
NC_Patch.ErrorMessage += "\nDSPOptimizations (last target version: 1.1.16)";
Log.Debug(obj);
}
}
[HarmonyPostfix]
[HarmonyPatch(typeof(GameData), "LeaveStar")]
public static void LeaveStar_Prefix()
{
if (GameMain.data.factoryCount == 0)
{
Log.Debug("Unload factories data for DSPOptimizations");
InitFactoryInfo(GameMain.data);
}
}
}
public static class DSPStarMapMemo
{
private const string NAME = "DSPStarMapMemo";
private const string GUID = "Appun.DSP.plugin.StarMapMemo";
private const string VERSION = "0.0.5";
private static IModCanSave Save;
public static void Init(Harmony harmony)
{
//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
//IL_00f7: Expected O, but got Unknown
if (!Chainloader.PluginInfos.TryGetValue("Appun.DSP.plugin.StarMapMemo", out var value))
{
return;
}
Assembly assembly = ((object)value.Instance).GetType().Assembly;
try
{
BaseUnityPlugin instance = value.Instance;
Save = (IModCanSave)(object)((instance is IModCanSave) ? instance : null);
NC_Patch.OnLogin = (Action)Delegate.Combine(NC_Patch.OnLogin, new Action(SendRequest));
NC_ModSaveRequest.OnReceive = (Action<string, INebulaConnection>)Delegate.Combine(NC_ModSaveRequest.OnReceive, (Action<string, INebulaConnection>)delegate(string guid, INebulaConnection conn)
{
if (!(guid != "Appun.DSP.plugin.StarMapMemo"))
{
conn.SendPacket<NC_ModSaveData>(new NC_ModSaveData("Appun.DSP.plugin.StarMapMemo", Export()));
}
});
NC_ModSaveData.OnReceive = (Action<string, byte[]>)Delegate.Combine(NC_ModSaveData.OnReceive, (Action<string, byte[]>)delegate(string guid, byte[] bytes)
{
if (!(guid != "Appun.DSP.plugin.StarMapMemo"))
{
Import(bytes);
}
});
Type type = assembly.GetType("DSPStarMapMemo.MemoPool");
harmony.Patch((MethodBase)AccessTools.Method(type, "AddOrUpdate", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(typeof(DSPStarMapMemo).GetMethod("SendData")), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
Log.Info("DSPStarMapMemo - OK");
}
catch (Exception obj)
{
Log.Warn("DSPStarMapMemo - Fail! Last target version: 0.0.5");
NC_Patch.ErrorMessage += "\nDSPStarMapMemo (last target version: 0.0.5)";
Log.Debug(obj);
}
}
public static void SendRequest()
{
if (NebulaModAPI.IsMultiplayerActive && NebulaModAPI.MultiplayerSession.LocalPlayer.IsClient)
{
NebulaModAPI.MultiplayerSession.Network.SendPacket<NC_ModSaveRequest>(new NC_ModSaveRequest("Appun.DSP.plugin.StarMapMemo"));
}
}
public static void SendData()
{
if (NebulaModAPI.IsMultiplayerActive)
{
NebulaModAPI.MultiplayerSession.Network.SendPacket<NC_ModSaveData>(new NC_ModSaveData("Appun.DSP.plugin.StarMapMemo", Export()));
}
}
public static byte[] Export()
{
if (Save != null)
{
IWriterProvider binaryWriter = NebulaModAPI.GetBinaryWriter();
try
{
Save.Export(binaryWriter.BinaryWriter);
return binaryWriter.CloseAndGetBytes();
}
finally
{
((IDisposable)binaryWriter)?.Dispose();
}
}
return new byte[0];
}
public static void Import(byte[] bytes)
{
if (Save != null)
{
IReaderProvider binaryReader = NebulaModAPI.GetBinaryReader(bytes);
try
{
Save.Import(binaryReader.BinaryReader);
}
finally
{
((IDisposable)binaryReader)?.Dispose();
}
}
}
}
public static class DSP_Battle_Patch
{
private const string NAME = "DSP_Battle";
private const string GUID = "com.ckcz123.DSP_Battle";
private const string VERSION = "3.0.5";
private static IModCanSave Save;
public static void Init(Harmony harmony)
{
if (!Chainloader.PluginInfos.TryGetValue("com.ckcz123.DSP_Battle", out var value))
{
return;
}
_ = ((object)value.Instance).GetType().Assembly;
try
{
BaseUnityPlugin instance = value.Instance;
Save = (IModCanSave)(object)((instance is IModCanSave) ? instance : null);
NC_Patch.OnLogin = (Action)Delegate.Combine(NC_Patch.OnLogin, new Action(SendRequest));
NC_ModSaveRequest.OnReceive = (Action<string, INebulaConnection>)Delegate.Combine(NC_ModSaveRequest.OnReceive, (Action<string, INebulaConnection>)delegate(string guid, INebulaConnection conn)
{
if (!(guid != "com.ckcz123.DSP_Battle"))
{
conn.SendPacket<NC_ModSaveData>(new NC_ModSaveData("com.ckcz123.DSP_Battle", Export()));
}
});
NC_ModSaveData.OnReceive = (Action<string, byte[]>)Delegate.Combine(NC_ModSaveData.OnReceive, (Action<string, byte[]>)delegate(string guid, byte[] bytes)
{
if (!(guid != "com.ckcz123.DSP_Battle"))
{
Import(bytes);
}
});
Log.Info("DSP_Battle - OK");
}
catch (Exception obj)
{
Log.Warn("DSP_Battle - Fail! Last target version: 3.0.5");
NC_Patch.ErrorMessage += "\nDSP_Battle (last target version: 3.0.5)";
Log.Debug(obj);
}
}
public static void SendRequest()
{
if (NebulaModAPI.IsMultiplayerActive && NebulaModAPI.MultiplayerSession.LocalPlayer.IsClient)
{
NebulaModAPI.MultiplayerSession.Network.SendPacket<NC_ModSaveRequest>(new NC_ModSaveRequest("com.ckcz123.DSP_Battle"));
}
}
public static byte[] Export()
{
if (Save != null)
{
IWriterProvider binaryWriter = NebulaModAPI.GetBinaryWriter();
try
{
Save.Export(binaryWriter.BinaryWriter);
return binaryWriter.CloseAndGetBytes();
}
finally
{
((IDisposable)binaryWriter)?.Dispose();
}
}
return new byte[0];
}
public static void Import(byte[] bytes)
{
if (Save != null)
{
IReaderProvider binaryReader = NebulaModAPI.GetBinaryReader(bytes);
try
{
Save.Import(binaryReader.BinaryReader);
}
finally
{
((IDisposable)binaryReader)?.Dispose();
}
}
}
}
public class FactoryLocator_Patch
{
public class Warper
{
private static int astroId;
private static int detailId;
[HarmonyPostfix]
[HarmonyPatch(typeof(UILocatorWindow), "SetViewingTarget")]
private static void SetViewingTarget_Postfix()
{
if (!NebulaModAPI.IsMultiplayerActive || !NebulaModAPI.MultiplayerSession.LocalPlayer.IsClient)
{
return;
}
UILocatorWindow mainWindow = Plugin.mainWindow;
PlanetData veiwPlanet = mainWindow.veiwPlanet;
int num;
if (veiwPlanet == null)
{
StarData veiwStar = mainWindow.veiwStar;
num = ((veiwStar != null) ? (veiwStar.id * 100) : 0);
}
else
{
num = veiwPlanet.id;
}
int num2 = num;
if (mainWindow.veiwPlanet != null && Plugin.mainLogic.factories.Count == 0)
{
NebulaModAPI.MultiplayerSession.Network.SendPacket<NC_PlanetInfoRequest>(new NC_PlanetInfoRequest(num2));
if (num2 != astroId)
{
mainWindow.nameText.text = "Loading...";
}
}
else if (mainWindow.veiwStar != null)
{
NebulaModAPI.MultiplayerSession.Network.SendPacket<NC_PlanetInfoRequest>(new NC_PlanetInfoRequest(num2));
if (num2 != astroId)
{
mainWindow.nameText.text = "Loading...";
}
}
astroId = num2;
}
public static void UpdateStatus(NC_PlanetInfoData packet)
{
UILocatorWindow mainWindow = Plugin.mainWindow;
bool flag = false;
if (packet.PlanetId > 0 && packet.PlanetId == mainWindow.veiwPlanet?.id)
{
mainWindow.nameText.text = mainWindow.veiwPlanet.displayName;
flag = true;
}
else if (packet.StarId > 0 && packet.StarId == mainWindow.veiwStar?.id)
{
mainWindow.nameText.text = mainWindow.veiwStar.displayName + Localization.Translate("空格行星系");
flag = true;
}
if (flag)
{
for (int i = 0; i < mainWindow.queryBtns.Length; i++)
{
((Behaviour)mainWindow.queryBtns[i].button).enabled = packet.NetworkCount > 0;
}
}
mainWindow.SetStatusTipText(packet.ConsumerRatios, packet.ConsumerCounts);
}
[HarmonyPrefix]
[HarmonyPatch(typeof(UILocatorWindow), "OnQueryClick")]
public static bool OnQueryClick(UILocatorWindow __instance, int queryType)
{
if (__instance.autoclear_enable)
{
WarningSystemPatch.ClearAll();
}
if (!NebulaModAPI.IsMultiplayerActive || !NebulaModAPI.MultiplayerSession.LocalPlayer.IsClient || (Plugin.mainLogic.factories.Count > 0 && __instance.veiwStar == null))
{
switch (queryType)
{
case 0:
Plugin.mainLogic.PickBuilding(0);
break;
case 1:
Plugin.mainLogic.PickVein(0);
break;
case 2:
Plugin.mainLogic.PickAssembler(0);
break;
case 3:
Plugin.mainLogic.PickWarning(0);
break;
case 4:
Plugin.mainLogic.PickStorage(0);
break;
case 5:
Plugin.mainLogic.PickStation(0);
break;
}
}
else
{
NebulaModAPI.MultiplayerSession.Network.SendPacket<NC_LocatorFilter>(new NC_LocatorFilter(astroId, queryType, null));
}
return false;
}
public static void HandleRequest(NC_LocatorFilter packet, INebulaConnection conn)
{
//IL_0040: Unknown result type (might be due to invalid IL or missing references)
//IL_0046: Expected O, but got Unknown
StarData val = null;
PlanetData val2 = null;
if (packet.AstroId % 100 == 0)
{
val = GameMain.data.galaxy.StarById(packet.AstroId / 100);
}
else
{
val2 = GameMain.data.galaxy.PlanetById(packet.AstroId);
}
MainLogic val3 = new MainLogic();
val3.SetFactories(val, val2);
switch (packet.QueryType)
{
case 0:
val3.RefreshBuilding(-1);
break;
case 1:
val3.RefreshVein(-1);
break;
case 2:
val3.RefreshAssemblers(-1);
break;
case 3:
val3.RefreshSignal(-1);
break;
case 4:
val3.RefreshStorage(-1);
break;
case 5:
val3.RefreshStation(-1);
break;
}
conn.SendPacket<NC_LocatorFilter>(new NC_LocatorFilter(packet.AstroId, packet.QueryType, val3.filterIds));
}
public static void ShowPickerWindow(NC_LocatorFilter packet)
{
//IL_00db: Unknown result type (might be due to invalid IL or missing references)
//IL_0129: Unknown result type (might be due to invalid IL or missing references)
//IL_0177: Unknown result type (might be due to invalid IL or missing references)
//IL_01b0: Unknown result type (might be due to invalid IL or missing references)
//IL_01fe: Unknown result type (might be due to invalid IL or missing references)
//IL_0237: Unknown result type (might be due to invalid IL or missing references)
if (astroId != packet.AstroId)
{
return;
}
Dictionary<int, int> filterIds = Plugin.mainLogic.filterIds;
filterIds.Clear();
for (int i = 0; i < packet.Ids.Length; i++)
{
filterIds[packet.Ids[i]] = packet.Counts[i];
}
switch (packet.QueryType)
{
case -1:
UIMessageBox.Show("ACCESS DENY", "Server doesn't install FactoryLocator", Localization.Translate("确定"), 3);
break;
case 0:
UIentryCount.OnOpen((ESignalType)1, filterIds);
UIItemPickerExtension.Popup(new Vector2(-300f, 250f), (Action<ItemProto>)delegate(ItemProto itemProto)
{
if (itemProto != null)
{
NebulaModAPI.MultiplayerSession.Network.SendPacket<NC_LocatorResult>(new NC_LocatorResult(astroId, packet.QueryType, ((Proto)itemProto).ID));
detailId = ((Proto)itemProto).ID;
}
UIentryCount.OnClose();
}, (Func<ItemProto, bool>)((ItemProto itemProto) => filterIds.ContainsKey(((Proto)itemProto).ID)));
UIRoot.instance.uiGame.itemPicker.OnTypeButtonClick(2);
break;
case 1:
UIentryCount.OnOpen((ESignalType)1, filterIds);
UIItemPickerExtension.Popup(new Vector2(-300f, 250f), (Action<ItemProto>)delegate(ItemProto itemProto)
{
if (itemProto != null)
{
NebulaModAPI.MultiplayerSession.Network.SendPacket<NC_LocatorResult>(new NC_LocatorResult(astroId, packet.QueryType, ((Proto)itemProto).ID));
detailId = ((Proto)itemProto).ID;
}
UIentryCount.OnClose();
}, (Func<ItemProto, bool>)((ItemProto itemProto) => filterIds.ContainsKey(((Proto)itemProto).ID)));
UIRoot.instance.uiGame.itemPicker.OnTypeButtonClick(1);
break;
case 2:
UIentryCount.OnOpen((ESignalType)2, filterIds);
UIRecipePickerExtension.Popup(new Vector2(-300f, 250f), (Action<RecipeProto>)delegate(RecipeProto recipeProto)
{
if (recipeProto != null)
{
NebulaModAPI.MultiplayerSession.Network.SendPacket<NC_LocatorResult>(new NC_LocatorResult(astroId, packet.QueryType, ((Proto)recipeProto).ID));
detailId = SignalProtoSet.SignalId((ESignalType)2, ((Proto)recipeProto).ID);
}
UIentryCount.OnClose();
}, (Func<RecipeProto, bool>)((RecipeProto recipeProto) => filterIds.ContainsKey(((Proto)recipeProto).ID)));
break;
case 3:
UIentryCount.OnOpen((ESignalType)0, filterIds);
UISignalPickerExtension.Popup(new Vector2(-300f, 250f), (Action<int>)delegate(int signalId)
{
if (signalId > 0)
{
NebulaModAPI.MultiplayerSession.Network.SendPacket<NC_LocatorResult>(new NC_LocatorResult(astroId, packet.QueryType, signalId));
detailId = signalId;
}
UIentryCount.OnClose();
}, (Func<int, bool>)((int signalId) => filterIds.ContainsKey(signalId)));
UIRoot.instance.uiGame.signalPicker.OnTypeButtonClick(1);
break;
case 4:
UIentryCount.OnOpen((ESignalType)1, filterIds);
UIItemPickerExtension.Popup(new Vector2(-300f, 250f), (Action<ItemProto>)delegate(ItemProto itemProto)
{
if (itemProto != null)
{
NebulaModAPI.MultiplayerSession.Network.SendPacket<NC_LocatorResult>(new NC_LocatorResult(astroId, packet.QueryType, ((Proto)itemProto).ID));
detailId = ((Proto)itemProto).ID;
}
UIentryCount.OnClose();
}, (Func<ItemProto, bool>)((ItemProto itemProto) => filterIds.ContainsKey(((Proto)itemProto).ID)));
break;
case 5:
UIentryCount.OnOpen((ESignalType)1, filterIds);
UIItemPickerExtension.Popup(new Vector2(-300f, 250f), (Action<ItemProto>)delegate(ItemProto itemProto)
{
if (itemProto != null)
{
NebulaModAPI.MultiplayerSession.Network.SendPacket<NC_LocatorResult>(new NC_LocatorResult(astroId, packet.QueryType, ((Proto)itemProto).ID));
detailId = ((Proto)itemProto).ID;
}
UIentryCount.OnClose();
}, (Func<ItemProto, bool>)((ItemProto itemProto) => filterIds.ContainsKey(((Proto)itemProto).ID)));
break;
}
}
public static void HandleRequest(NC_LocatorResult packet, INebulaConnection conn)
{
//IL_0040: Unknown result type (might be due to invalid IL or missing references)
//IL_0046: Expected O, but got Unknown
StarData val = null;
PlanetData val2 = null;
if (packet.AstroId % 100 == 0)
{
val = GameMain.data.galaxy.StarById(packet.AstroId / 100);
}
else
{
val2 = GameMain.data.galaxy.PlanetById(packet.AstroId);
}
MainLogic val3 = new MainLogic();
val3.SetFactories(val, val2);
switch (packet.QueryType)
{
case 0:
val3.RefreshBuilding(packet.ProtoId);
break;
case 1:
val3.RefreshVein(packet.ProtoId);
break;
case 2:
val3.RefreshAssemblers(packet.ProtoId);
break;
case 3:
val3.RefreshSignal(packet.ProtoId);
break;
case 4:
val3.RefreshStorage(packet.ProtoId);
break;
case 5:
val3.RefreshStation(packet.ProtoId);
break;
}
conn.SendPacket<NC_LocatorResult>(new NC_LocatorResult(packet.QueryType, val3.planetIds, val3.localPos, val3.detailIds));
}
public static void ShowResult(NC_LocatorResult packet)
{
//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)
MainLogic mainLogic = Plugin.mainLogic;
mainLogic.planetIds.Clear();
mainLogic.localPos.Clear();
mainLogic.detailIds.Clear();
for (int i = 0; i < packet.PlanetIds.Length; i++)
{
mainLogic.planetIds.Add(packet.PlanetIds[i]);
mainLogic.localPos.Add(DataStructureExtensions.ToVector3(packet.LocalPos[i]));
}
for (int j = 0; j < packet.DetailIds.Length; j++)
{
mainLogic.detailIds.Add(packet.DetailIds[j]);
}
if (packet.QueryType != 3)
{
WarningSystemPatch.AddWarningData(mainLogic.SignalId, detailId, mainLogic.planetIds, mainLogic.localPos, (List<int>)null);
}
else
{
WarningSystemPatch.AddWarningData(mainLogic.SignalId, detailId, mainLogic.planetIds, mainLogic.localPos, mainLogic.detailIds);
}
}
}
public const string NAME = "FactoryLocator";
public const string GUID = "starfi5h.plugin.FactoryLocator";
public const string VERSION = "1.2.2";
public static bool Enable { get; private set; }
public static void Init(Harmony harmony)
{
if (!Chainloader.PluginInfos.TryGetValue("starfi5h.plugin.FactoryLocator", out var _))
{
return;
}
Enable = true;
try
{
harmony.PatchAll(typeof(Warper));
Log.Info("FactoryLocator - OK");
}
catch (Exception obj)
{
Log.Warn("FactoryLocator - Fail! Last target version: 1.2.2");
NC_Patch.ErrorMessage += "\nFactoryLocator (last target version: 1.2.2)";
Log.Debug(obj);
}
}
public static void OnReceive(NC_PlanetInfoData packet)
{
Warper.UpdateStatus(packet);
}
public static void OnReceive(NC_LocatorFilter packet, INebulaConnection conn)
{
if (NebulaModAPI.MultiplayerSession.LocalPlayer.IsHost)
{
if (Enable)
{
Warper.HandleRequest(packet, conn);
return;
}
packet.QueryType = -1;
conn.SendPacket<NC_LocatorFilter>(packet);
}
else if (Enable)
{
Warper.ShowPickerWindow(packet);
}
}
public static void OnReceive(NC_LocatorResult packet, INebulaConnection conn)
{
if (NebulaModAPI.MultiplayerSession.LocalPlayer.IsHost)
{
if (Enable)
{
Warper.HandleRequest(packet, conn);
}
}
else if (Enable)
{
Warper.ShowResult(packet);
}
}
}
public static class LSTM
{
public const string NAME = "LSTM";
public const string GUID = "com.hetima.dsp.LSTM";
public const string VERSION = "0.8.7";
public static void Init(Harmony harmony)
{
//IL_0040: Unknown result type (might be due to invalid IL or missing references)
//IL_004e: Expected O, but got Unknown
//IL_006f: Unknown result type (might be due to invalid IL or missing references)
//IL_007d: Expected O, but got Unknown
//IL_009e: Unknown result type (might be due to invalid IL or missing references)
//IL_00ac: Expected O, but got Unknown
if (!Chainloader.PluginInfos.ContainsKey("com.hetima.dsp.LSTM"))
{
return;
}
try
{
Type type = AccessTools.TypeByName("LSTMMod.UIBalanceWindow");
harmony.Patch((MethodBase)AccessTools.Method(type, "_OnOpen", (Type[])null, (Type[])null), new HarmonyMethod(typeof(LSTM).GetMethod("SendRequest")), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
harmony.Patch((MethodBase)type.GetMethod("SwitchToStarSystem"), new HarmonyMethod(typeof(LSTM).GetMethod("SendRequest")), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
harmony.Patch((MethodBase)type.GetMethod("SwitchToGlobal"), new HarmonyMethod(typeof(LSTM).GetMethod("SendRequest")), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
Log.Info("LSTM - OK");
}
catch (Exception obj)
{
Log.Warn("LSTM - Fail! Last target version: 0.8.7");
NC_Patch.ErrorMessage += "\nLSTM (last target version: 0.8.7)";
Log.Debug(obj);
}
}
public static void SendRequest()
{
if (NebulaModAPI.IsMultiplayerActive && NebulaModAPI.MultiplayerSession.LocalPlayer.IsClient)
{
NebulaModAPI.MultiplayerSession.Network.SendPacket<NC_StationStorageRequest>(new NC_StationStorageRequest());
}
}
}
public static class MoreMegaStructure
{
public class PointerDownUpHandler : ManualBehaviour, IPointerDownHandler, IEventSystemHandler, IPointerUpHandler
{
public int Id;
public event Action<int> onPointerDown;
public event Action<int> onPointerUp;
public void OnPointerDown(PointerEventData pointerEventData)
{
this.onPointerDown?.Invoke(Id);
}
public void OnPointerUp(PointerEventData pointerEventData)
{
this.onPointerUp?.Invoke(Id);
}
}
private const string NAME = "MoreMegaStructure";
private const string GUID = "Gnimaerd.DSP.plugin.MoreMegaStructure";
private const string VERSION = "1.3.9";
private static IModCanSave Save;
public static void Init(Harmony harmony)
{
//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
//IL_00d5: Expected O, but got Unknown
//IL_011c: Unknown result type (might be due to invalid IL or missing references)
//IL_012a: Expected O, but got Unknown
//IL_015b: Unknown result type (might be due to invalid IL or missing references)
//IL_0167: Expected O, but got Unknown
//IL_021d: Unknown result type (might be due to invalid IL or missing references)
//IL_022b: Expected O, but got Unknown
//IL_0265: Unknown result type (might be due to invalid IL or missing references)
//IL_026c: Expected O, but got Unknown
//IL_0280: Unknown result type (might be due to invalid IL or missing references)
//IL_0287: Expected O, but got Unknown
if (!Chainloader.PluginInfos.TryGetValue("Gnimaerd.DSP.plugin.MoreMegaStructure", out var value))
{
return;
}
Assembly assembly = ((object)value.Instance).GetType().Assembly;
try
{
BaseUnityPlugin instance = value.Instance;
Save = (IModCanSave)(object)((instance is IModCanSave) ? instance : null);
NC_Patch.OnLogin = (Action)Delegate.Combine(NC_Patch.OnLogin, new Action(SendRequest));
NC_ModSaveRequest.OnReceive = (Action<string, INebulaConnection>)Delegate.Combine(NC_ModSaveRequest.OnReceive, (Action<string, INebulaConnection>)delegate(string guid, INebulaConnection conn)
{
if (!(guid != "Gnimaerd.DSP.plugin.MoreMegaStructure"))
{
conn.SendPacket<NC_ModSaveData>(new NC_ModSaveData("Gnimaerd.DSP.plugin.MoreMegaStructure", Export()));
}
});
NC_ModSaveData.OnReceive = (Action<string, byte[]>)Delegate.Combine(NC_ModSaveData.OnReceive, (Action<string, byte[]>)delegate(string guid, byte[] bytes)
{
if (!(guid != "Gnimaerd.DSP.plugin.MoreMegaStructure"))
{
Import(bytes);
}
});
HarmonyMethod val = new HarmonyMethod(typeof(MoreMegaStructure).GetMethod("SendData"));
Type type = assembly.GetType("MoreMegaStructure.MoreMegaStructure");
harmony.Patch((MethodBase)AccessTools.Method(type, "SetMegaStructure", (Type[])null, (Type[])null), (HarmonyMethod)null, val, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
harmony.Patch((MethodBase)AccessTools.Method(type, "BeforeGameTickPostPatch", (Type[])null, (Type[])null), new HarmonyMethod(typeof(MoreMegaStructure).GetMethod("SuppressOnClient")), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
type = assembly.GetType("MoreMegaStructure.ReceiverPatchers");
harmony.Patch((MethodBase)AccessTools.Method(type, "RequestDysonSpherePowerPrePatch", (Type[])null, (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, new HarmonyMethod(typeof(MoreMegaStructure).GetMethod("RequestDysonSpherePowerPrePatch_Transpiler")), (HarmonyMethod)null, (HarmonyMethod)null);
type = assembly.GetType("MoreMegaStructure.StarAssembly");
harmony.Patch((MethodBase)AccessTools.Method(type, "OnRecipePickerReturn", (Type[])null, (Type[])null), (HarmonyMethod)null, val, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
foreach (Slider item in AccessTools.StaticFieldRefAccess<List<Slider>>(type, "sliders"))
{
GameObject gameObject = ((Component)item).gameObject;
Object.Destroy((Object)(object)gameObject.GetComponent<PointerDownUpHandler>());
gameObject.AddComponent<PointerDownUpHandler>().onPointerUp += delegate
{
SendData();
};
}
harmony.Patch((MethodBase)AccessTools.Method(type, "UIFrameUpdate", (Type[])null, (Type[])null), new HarmonyMethod(typeof(MoreMegaStructure).GetMethod("SuppressUIupdate")), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
type = assembly.GetType("MoreMegaStructure.StarCannon");
harmony.Patch((MethodBase)AccessTools.Method(type, "StartAiming", (Type[])null, (Type[])null), (HarmonyMethod)null, val, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
HarmonyMethod val2 = new HarmonyMethod(typeof(MoreMegaStructure).GetMethod("SuppressPrefixOnMultiplayer"));
HarmonyMethod val3 = new HarmonyMethod(typeof(MoreMegaStructure).GetMethod("SuppressPostfixOnMultiplayer"));
type = assembly.GetType("MoreMegaStructure.UIStatisticsPatcher");
harmony.Patch((MethodBase)AccessTools.Method(type, "RefreshAstroBoxPostPatch", (Type[])null, (Type[])null), val2, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
harmony.Patch((MethodBase)AccessTools.Method(type, "PlanetByIdPostPatch", (Type[])null, (Type[])null), val3, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
harmony.Patch((MethodBase)AccessTools.Method(type, "ComputeDisplayEntriesPrePatch", (Type[])null, (Type[])null), val2, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
harmony.Patch((MethodBase)AccessTools.Method(type, "ProductionStatisticsGameTickPostPatch", (Type[])null, (Type[])null), val3, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
Log.Info("MoreMegaStructure - OK");
NC_Patch.RequriedPlugins += " +MoreMegaStructure";
}
catch (Exception obj)
{
Log.Warn("MoreMegaStructure - Fail! Last target version: 1.3.9");
NC_Patch.ErrorMessage += "\nMoreMegaStructure (last target version: 1.3.9)";
Log.Debug(obj);
}
}
public static void SendRequest()
{
if (NebulaModAPI.IsMultiplayerActive && NebulaModAPI.MultiplayerSession.LocalPlayer.IsClient)
{
NebulaModAPI.MultiplayerSession.Network.SendPacket<NC_ModSaveRequest>(new NC_ModSaveRequest("Gnimaerd.DSP.plugin.MoreMegaStructure"));
}
}
public static void SendData()
{
if (NebulaModAPI.IsMultiplayerActive)
{
NebulaModAPI.MultiplayerSession.Network.SendPacket<NC_ModSaveData>(new NC_ModSaveData("Gnimaerd.DSP.plugin.MoreMegaStructure", Export()));
}
}
public static byte[] Export()
{
if (Save != null)
{
IWriterProvider binaryWriter = NebulaModAPI.GetBinaryWriter();
try
{
Save.Export(binaryWriter.BinaryWriter);
return binaryWriter.CloseAndGetBytes();
}
finally
{
((IDisposable)binaryWriter)?.Dispose();
}
}
return new byte[0];
}
public static void Import(byte[] bytes)
{
if (Save != null)
{
IReaderProvider binaryReader = NebulaModAPI.GetBinaryReader(bytes);
try
{
Save.Import(binaryReader.BinaryReader);
}
finally
{
((IDisposable)binaryReader)?.Dispose();
}
}
}
public static bool SuppressPrefixOnMultiplayer(ref bool __result)
{
if (!NebulaModAPI.IsMultiplayerActive)
{
return true;
}
__result = true;
return false;
}
public static bool SuppressPostfixOnMultiplayer()
{
return !NebulaModAPI.IsMultiplayerActive;
}
public static bool SuppressOnClient()
{
if (NebulaModAPI.IsMultiplayerActive)
{
return NebulaModAPI.MultiplayerSession.IsServer;
}
return true;
}
public static bool SuppressUIupdate()
{
return ((ManualBehaviour)UIRoot.instance.uiGame.dysonEditor).active;
}
public static IEnumerable<CodeInstruction> RequestDysonSpherePowerPrePatch_Transpiler(IEnumerable<CodeInstruction> instructions)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0035: Unknown result type (might be due to invalid IL or missing references)
//IL_003b: Expected O, but got Unknown
//IL_005c: Unknown result type (might be due to invalid IL or missing references)
//IL_0062: Expected O, but got Unknown
//IL_0070: Unknown result type (might be due to invalid IL or missing references)
//IL_0076: Expected O, but got Unknown
//IL_0084: Unknown result type (might be due to invalid IL or missing references)
//IL_008a: Expected O, but got Unknown
//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
//IL_00be: Expected O, but got Unknown
//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
//IL_00cc: Expected O, but got Unknown
//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
//IL_00da: Expected O, but got Unknown
try
{
CodeMatcher val = new CodeMatcher(instructions, (ILGenerator)null).End().MatchBack(true, (CodeMatch[])(object)new CodeMatch[4]
{
new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction i) => CodeInstructionExtensions.IsLdloc(i, (LocalBuilder)null)), (string)null),
new CodeMatch((OpCode?)OpCodes.Ldfld, (object)AccessTools.Field(typeof(PowerSystem), "dysonSphere"), (string)null),
new CodeMatch((OpCode?)OpCodes.Ldnull, (object)null, (string)null),
new CodeMatch((OpCode?)OpCodes.Cgt_Un, (object)null, (string)null)
});
val.Advance(1).Insert((CodeInstruction[])(object)new CodeInstruction[3]
{
new CodeInstruction(OpCodes.Ldsfld, (object)AccessTools.Field(typeof(NC_Patch), "IsClient")),
new CodeInstruction(OpCodes.Not, (object)null),
new CodeInstruction(OpCodes.And, (object)null)
});
return val.InstructionEnumeration();
}
catch
{
Log.Error("PowerSystem.RequestDysonSpherePower_Transpiler failed. Mod version not compatible with game version.");
return instructions;
}
}
}
public static class PlanetFinder_Patch
{
public struct PlanetInfo
{
public long energyCapacity;
public long energyRequired;
public long energyExchanged;
public int networkCount;
}
public const string NAME = "PlanetFinder";
public const string GUID = "com.hetima.dsp.PlanetFinder";
public const string VERSION = "1.1.3";
private static Dictionary<int, PlanetInfo> planetInfos;
private static StringBuilder sbWatt;
private static StringBuilder sbText;
public static bool Enable { get; private set; }
public static void Init(Harmony harmony)
{
//IL_007e: Unknown result type (might be due to invalid IL or missing references)
//IL_008c: Expected O, but got Unknown
//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
//IL_00bb: Expected O, but got Unknown
//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
//IL_00f6: Expected O, but got Unknown
//IL_0123: Unknown result type (might be due to invalid IL or missing references)
//IL_0131: Expected O, but got Unknown
if (!Chainloader.PluginInfos.TryGetValue("com.hetima.dsp.PlanetFinder", out var value))
{
return;
}
Assembly assembly = ((object)value.Instance).GetType().Assembly;
Enable = true;
try
{
planetInfos = new Dictionary<int, PlanetInfo>();
sbWatt = new StringBuilder(" W", 12);
sbText = new StringBuilder();
Type type = assembly.GetType("PlanetFinderMod.UIPlanetFinderWindow");
harmony.Patch((MethodBase)AccessTools.Method(type, "SetUpAndOpen", (Type[])null, (Type[])null), new HarmonyMethod(typeof(PlanetFinder_Patch).GetMethod("SendRequest")), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
harmony.Patch((MethodBase)type.GetMethod("FilterPlanetsWithFactory"), new HarmonyMethod(typeof(PlanetFinder_Patch).GetMethod("FilterPlanetsWithFactory_Prefix")), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
type = assembly.GetType("PlanetFinderMod.UIPlanetFinderListItem");
harmony.Patch((MethodBase)type.GetMethod("RefreshValues"), (HarmonyMethod)null, new HarmonyMethod(typeof(PlanetFinder_Patch).GetMethod("RefreshValues_Postfix")), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
type = assembly.GetType("PlanetFinderMod.PLFN+Patch");
harmony.Patch((MethodBase)type.GetMethod("UIPlanetDetail_RefreshDynamicProperties"), new HarmonyMethod(typeof(PlanetFinder_Patch).GetMethod("UIPlanetDetail_RefreshDynamicProperties_Prefix")), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
Log.Info("PlanetFinder - OK");
}
catch (Exception obj)
{
Log.Warn("PlanetFinder - Fail! Last target version: 1.1.3");
NC_Patch.ErrorMessage += "\nPlanetFinder (last target version: 1.1.3)";
Log.Debug(obj);
}
}
public static void SendRequest()
{
if (NebulaModAPI.IsMultiplayerActive && NebulaModAPI.MultiplayerSession.LocalPlayer.IsClient)
{
NebulaModAPI.MultiplayerSession.Network.SendPacket<NC_PlanetInfoRequest>(new NC_PlanetInfoRequest(-1));
}
}
public static void OnReceive(NC_PlanetInfoData packet)
{
if (packet.PlanetId > 0)
{
planetInfos[packet.PlanetId] = new PlanetInfo
{
energyCapacity = packet.EnergyCapacity,
energyRequired = packet.EnergyRequired,
energyExchanged = packet.EnergyExchanged,
networkCount = packet.NetworkCount
};
}
}
public static void RefreshValues_Postfix(GameObject ___baseObj, int ____itemId, PlanetData ___planetData, Text ___valueText, Text ___valueSketchText)
{
if (___baseObj.activeSelf && ____itemId == 0 && ___planetData != null && NebulaModAPI.IsMultiplayerActive && !NebulaModAPI.MultiplayerSession.LocalPlayer.IsHost && ___planetData.factory == null && planetInfos.ContainsKey(___planetData.id))
{
long energyRequired = planetInfos[___planetData.id].energyRequired;
long energyCapacity = planetInfos[___planetData.id].energyCapacity;
long num = -planetInfos[___planetData.id].energyExchanged;
int networkCount = planetInfos[___planetData.id].networkCount;
StringBuilderUtility.WriteKMG(sbWatt, 8, energyRequired * 60, false);
sbText.Append((object?)sbWatt);
StringBuilderUtility.WriteKMG(sbWatt, 8, energyCapacity * 60, false);
sbText.Append(" / ").Append(sbWatt.ToString().Trim());
if (num > 0)
{
StringBuilderUtility.WriteKMG(sbWatt, 8, num * 60, false);
sbText.Append(" + ").Append(sbWatt.ToString().Trim());
}
else
{
num = 0L;
}
float num2 = (float)energyRequired / (float)(energyCapacity + num);
if (num2 > 0.9f)
{
sbText.Append(" (").Append(num2.ToString("P1")).Append(")");
sbText.Insert(0, (num2 > 0.99f) ? "<color=#FF404D99>" : "<color=#DB883E85>");
sbText.Append("</color>");
}
___valueText.text = sbText.ToString();
sbText.Clear();
if (networkCount > 1)
{
___valueSketchText.text = "(" + networkCount + ")";
}
}
}
public static bool FilterPlanetsWithFactory_Prefix(List<PlanetListData> ____allPlanetList)
{
if (!NebulaModAPI.IsMultiplayerActive || NebulaModAPI.MultiplayerSession.LocalPlayer.IsHost)
{
return true;
}
foreach (PlanetListData ____allPlanet in ____allPlanetList)
{
____allPlanet.shouldShow = planetInfos.ContainsKey(____allPlanet.planetData.id);
}
return false;
}
public static bool UIPlanetDetail_RefreshDynamicProperties_Prefix()
{
if (NebulaModAPI.IsMultiplayerActive)
{
return NebulaModAPI.MultiplayerSession.IsGameLoaded;
}
return true;
}
}
public static class SplitterOverBelt
{
public const string NAME = "SplitterOverBelt";
public const string GUID = "com.hetima.dsp.SplitterOverBelt";
public const string VERSION = "1.1.6";
private static List<int> removingBeltEids;
public static void Init(Harmony harmony)
{
//IL_005f: Unknown result type (might be due to invalid IL or missing references)
//IL_006b: Expected O, but got Unknown
//IL_008f: Unknown result type (might be due to invalid IL or missing references)
//IL_009c: Expected O, but got Unknown
//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
//IL_00cd: Expected O, but got Unknown
if (!Chainloader.PluginInfos.TryGetValue("com.hetima.dsp.SplitterOverBelt", out var value))
{
return;
}
Assembly assembly = ((object)value.Instance).GetType().Assembly;
removingBeltEids = new List<int>();
try
{
Type type = assembly.GetType("SplitterOverBelt.SplitterOverBelt");
harmony.Patch((MethodBase)AccessTools.Method(type, "DeleteConfusedBelts", (Type[])null, (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, new HarmonyMethod(typeof(SplitterOverBelt).GetMethod("DeleteConfusedBelts_Transpiler")), (HarmonyMethod)null, (HarmonyMethod)null);
harmony.Patch((MethodBase)AccessTools.Method(type, "ConnectBelts", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(typeof(SplitterOverBelt).GetMethod("ConnectBelts_Postfix")), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
harmony.Patch((MethodBase)AccessTools.Method(type, "ValidateBelt2", (Type[])null, (Type[])null), new HarmonyMethod(typeof(SplitterOverBelt).GetMethod("ValidateBelt2_Prefix")), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
Log.Info("SplitterOverBelt - OK");
}
catch (Exception obj)
{
Log.Warn("SplitterOverBelt - Fail! Last target version: 1.1.6");
NC_Patch.ErrorMessage += "\nSplitterOverBelt (last target version: 1.1.6)";
Log.Debug(obj);
}
}
public static IEnumerable<CodeInstruction> DeleteConfusedBelts_Transpiler(IEnumerable<CodeInstruction> instructions)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0030: Unknown result type (might be due to invalid IL or missing references)
//IL_0036: Expected O, but got Unknown
try
{
return new CodeMatcher(instructions, (ILGenerator)null).MatchForward(false, (CodeMatch[])(object)new CodeMatch[1]
{
new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction i) => i.opcode == OpCodes.Callvirt && ((MethodInfo)i.operand).Name == "DoDismantleObject"), (string)null)
}).Repeat((Action<CodeMatcher>)delegate(CodeMatcher matcher)
{
matcher.SetAndAdvance(OpCodes.Call, (object)typeof(SplitterOverBelt).GetMethod("RecordAndDismantleObject"));
}, (Action<string>)null).InstructionEnumeration();
}
catch (Exception)
{
Log.Warn("DeleteConfusedBelts_Transpiler fail!");
return instructions;
}
}
public static bool RecordAndDismantleObject(PlayerAction_Build action_Build, int entityId)
{
removingBeltEids.Add(entityId);
return action_Build.DoDismantleObject(entityId);
}
public static void ConnectBelts_Postfix()
{
removingBeltEids.Clear();
}
public static bool ValidateBelt2_Prefix(BuildTool_Click tool, EntityData entityData, out bool validBelt, out bool isOutput)
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
isOutput = false;
validBelt = false;
int id = entityData.id;
bool flag = false;
bool flag2 = false;
bool flag3 = default(bool);
int num = default(int);
int num2 = default(int);
for (int i = 0; i < 4; i++)
{
((BuildTool)tool).factory.ReadObjectConn(id, i, ref flag3, ref num, ref num2);
if (num != 0 && !removingBeltEids.Contains(num))
{
if (flag3)
{
flag2 = true;
}
else
{
flag = true;
}
}
}
if (flag2 == flag)
{
validBelt = false;
}
else if (flag2)
{
isOutput = true;
validBelt = true;
}
else if (flag)
{
isOutput = false;
validBelt = true;
}
return false;
}
}
}
namespace NebulaCompatibilityAssist.Hotfix
{
public static class ChatManager
{
public static NC_AllModList ServerModList { get; set; }
public static void Init(Harmony harmony)
{
NebulaModAPI.OnPlayerJoinedGame = (Action<IPlayerData>)Delegate.Combine(NebulaModAPI.OnPlayerJoinedGame, new Action<IPlayerData>(OnPlayerJoined));
harmony.PatchAll(typeof(ChatManager));
}
public static void OnDestory()
{
NebulaModAPI.OnPlayerJoinedGame = (Action<IPlayerData>)Delegate.Remove(NebulaModAPI.OnPlayerJoinedGame, new Action<IPlayerData>(OnPlayerJoined));
}
private static void OnPlayerJoined(IPlayerData player)
{
NebulaModAPI.MultiplayerSession.Network.SendToMatching<NC_AllModList>(new NC_AllModList(0), (Predicate<INebulaPlayer>)((INebulaPlayer iplayer) => iplayer.Id == player.PlayerId));
}
public static void ShowMessageInChat(string message)
{
ChatManager instance = ChatManager.Instance;
if (instance != null)
{
instance.SendChatMessage(message, (ChatMessageType)1);
}
}
public static void ShowWarningInChat(string message)
{
ChatManager instance = ChatManager.Instance;
if (instance != null)
{
instance.SendChatMessage(message, (ChatMessageType)2);
}
}
[HarmonyPostfix]
[HarmonyPatch(typeof(InfoCommandHandler), "GetClientInfoText")]
private static void GetClientInfoText_Postfix(bool full, ref string __result)
{
if (ServerModList != null && ServerModList.GUIDs != null && ServerModList.GUIDs.Length != 0 && CheckModsVersion(out var report) > 0)
{
__result += report;
}
}
public static int CheckModsVersion(out string report)
{
int num = 0;
string text = "";
string text2 = "";
string text3 = "";
Dictionary<string, string> dictionary = new Dictionary<string, string>();
int num2 = ServerModList.GUIDs.Length;
for (int i = 0; i < num2; i++)
{
if (!Chainloader.PluginInfos.Keys.Contains(ServerModList.GUIDs[i]))
{
text = text + " " + ServerModList.Names[i] + " " + ServerModList.Versions[i] + "\n";
num++;
}
dictionary[ServerModList.GUIDs[i]] = ServerModList.Versions[i];
}
foreach (KeyValuePair<string, PluginInfo> pluginInfo in Chainloader.PluginInfos)
{
string key = pluginInfo.Key;
string text4 = pluginInfo.Value.Metadata.Version.ToString();
if (!dictionary.ContainsKey(pluginInfo.Key))
{
text2 = text2 + " " + pluginInfo.Value.Metadata.Name + " " + text4 + "\n";
num++;
}
else if (text4 != dictionary[pluginInfo.Key])
{
text3 = text3 + " " + key + " " + text4 + " - server:" + dictionary[pluginInfo.Key] + "\n";
num++;
}
}
report = "\n";
if (text2 != "")
{
report = report + "\nNot on serever:\n" + text2;
}
if (text != "")
{
report = report + "\nNot on client:\n" + text;
}
if (text3 != "")
{
report = report + "\nVersion mismatched:\n" + text3;
}
return num;
}
}
public static class NebulaHotfix
{
private const string GUID = "dsp.nebula-multiplayer";
public static void Init(Harmony harmony)
{
if (!Chainloader.PluginInfos.TryGetValue("dsp.nebula-multiplayer", out var value))
{
return;
}
try
{
Version version = value.Metadata.Version;
if (version.Major == 0 && version.Minor == 9 && version.Build == 2)
{
harmony.PatchAll(typeof(Waraper093));
Log.Info("Nebula hotfix 0.9.3 - OK");
}
ChatManager.Init(harmony);
harmony.PatchAll(typeof(StacktraceParser));
Log.Info("Nebula extra features - OK");
}
catch (Exception obj)
{
Log.Warn("Nebula hotfix patch fail! Current version: " + value.Metadata.Version);
Log.Debug(obj);
}
}
}
public static class Waraper093
{
private static bool suppressed;
[HarmonyPostfix]
[HarmonyPatch(typeof(GameMain), "Begin")]
public static void OnGameBegin()
{
suppressed = false;
}
[HarmonyFinalizer]
[HarmonyPatch(typeof(EnemyDFGroundSystem), "GameTickLogic")]
[HarmonyPatch(typeof(EnemyDFGroundSystem), "KeyTickLogic")]
[HarmonyPatch(typeof(EnemyDFHiveSystem), "GameTickLogic")]
[HarmonyPatch(typeof(EnemyDFHiveSystem), "KeyTickLogic")]
public static Exception EnemyGameTick_Finalizer(Exception __exception)
{
if (__exception != null && !suppressed)
{
suppressed = true;
string text = "NebulaCompatibilityAssist suppressed the following exception: \n" + __exception.ToString();
ChatManager.ShowWarningInChat(text);
Log.Error(text);
}
return null;
}
}
}
namespace NebulaCompatibilityAssist.Analysis
{
internal class StacktraceParser
{
private static bool IsChecked;
private static Dictionary<string, List<MethodBase>> patchMap;
[HarmonyPostfix]
[HarmonyPatch(typeof(UIFatalErrorTip), "_OnClose")]
public static void OnClose_Postfix()
{
IsChecked = false;
patchMap = null;
}
[HarmonyPostfix]
[HarmonyPatch(typeof(UIFatalErrorTip), "_OnOpen")]
public static void OnOpen_Postfix(UIFatalErrorTip __instance)
{
//IL_00f9: 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_0134: 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 (IsChecked)
{
return;
}
if (patchMap == null)
{
patchMap = new Dictionary<string, List<MethodBase>>();
foreach (MethodBase allPatchedMethod in PatchProcessor.GetAllPatchedMethods())
{
string fullName = allPatchedMethod.DeclaringType.FullName;
if (!patchMap.TryGetValue(fullName, out var value))
{
value = new List<MethodBase>();
patchMap[fullName] = value;
}
value.Add(allPatchedMethod);
}
Log.Debug("Patched type: " + patchMap.Count);
}
List<MethodBase> modifiedMethods = new List<MethodBase>();
ParseStackTraceLines(__instance.errorLogText.text, delegate(string typeName, string methodName)
{
if (patchMap.TryGetValue(typeName, out var value2))
{
foreach (MethodBase item in value2)
{
if (item.Name == methodName)
{
modifiedMethods.Add(item);
}
}
}
});
Text errorLogText = __instance.errorLogText;
errorLogText.text += GetResultString(modifiedMethods);
__instance.rectTrans.sizeDelta = new Vector2(__instance.rectTrans.sizeDelta.x, __instance.errorLogText.preferredHeight + 45f);
((Graphic)__instance.errorLogText).rectTransform.sizeDelta = new Vector2(((Graphic)__instance.errorLogText).rectTransform.sizeDelta.x, __instance.errorLogText.preferredHeight + 2f);
IsChecked = true;
}
private static void ParseStackTraceLines(string source, Action<string, string> validate)
{
string[] array = source.Split(new char[2] { '\n', '\r' }, StringSplitOptions.RemoveEmptyEntries);
foreach (string text in array)
{
int num = text.IndexOf('(');
if (num != -1)
{
int num2 = text.LastIndexOf('.', num);
if (num2 != -1 && num - num2 - 2 > 0)
{
string arg = ((!text.StartsWith(" at ")) ? text.Substring(0, num2) : text.Substring(5, num2 - 5));
string arg2 = text.Substring(num2 + 1, num - num2 - 2);
validate(arg, arg2);
}
}
}
}
private static string GetResultString(List<MethodBase> modifiedMethods)
{
StringBuilder stringBuilder = new StringBuilder();
foreach (MethodBase modifiedMethod in modifiedMethods)
{
Patches patchInfo = PatchProcessor.GetPatchInfo(modifiedMethod);
PatchesToString(stringBuilder, modifiedMethod.Name, "Prefix", patchInfo.Prefixes);
PatchesToString(stringBuilder, modifiedMethod.Name, "Postfix", patchInfo.Postfixes);
PatchesToString(stringBuilder, modifiedMethod.Name, "Transpiler", patchInfo.Transpilers);
Log.Debug(modifiedMethod.Name + " owners:" + patchInfo.Owners.Count);
}
if (stringBuilder.Length > 0)
{
stringBuilder.Insert(0, "\nPossible related patches:\n");
}
return stringBuilder.ToString();
}
private static void PatchesToString(StringBuilder sb, string name, string prefix, ReadOnlyCollection<Patch> patches)
{
foreach (Patch patch in patches)
{
if (!IsWhitelist(name, patch))
{
sb.Append(name).Append("(").Append(prefix)
.Append("): ");
if (prefix != "Transpiler")
{
sb.AppendLine(GeneralExtensions.FullDescription((MethodBase)patch.PatchMethod));
}
else
{
sb.AppendLine(GeneralExtensions.FullDescription((MethodBase)patch.PatchMethod).Replace("System.Collections.Generic.IEnumerable<HarmonyLib.CodeInstruction>", "var").Replace("System.Reflection.Emit.ILGenerator", "var"));
}
}
}
}
private static bool IsWhitelist(string name, Patch patch)
{
if (name == "FixedUpdate")
{
string text = patch.PatchMethod.DeclaringType.ToString();
if (text == "BulletTime.GameMain_Patch")
{
return true;
}
if (text == "NebulaPatcher.Patches.Transpiler.GameMain_Transpiler")
{
return true;
}
}
return false;
}
}
}