using System;
using System.Collections.Generic;
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 System.Threading;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using CommonAPI.Systems;
using DSP_Battle;
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.Hotfix;
using NebulaCompatibilityAssist.Packets;
using NebulaCompatibilityAssist.Patches;
using NebulaModel.DataStructures.Chat;
using NebulaModel.Logger;
using NebulaModel.Packets.Factory.PowerGenerator;
using NebulaWorld;
using NebulaWorld.Chat.Commands;
using NebulaWorld.Factory;
using NebulaWorld.MonoBehaviours.Local.Chat;
using PlanetFinderMod;
using SphereOpt;
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.5.1")]
[assembly: AssemblyInformationalVersion("0.5.1")]
[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.5.1.0")]
[module: UnverifiableCode]
namespace NebulaCompatibilityAssist
{
[BepInPlugin("NebulaCompatibilityAssist", "NebulaCompatibilityAssist", "0.5.1")]
[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.5.1";
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_BattleUpdate
{
public enum EType
{
None,
AddRelic,
RemoveRelic,
ApplyAuthorizationPoint,
ResetAuthorizationPoint
}
public string Username { get; set; }
public EType Type { get; set; }
public int Value1 { get; set; }
public int Value2 { get; set; }
public int[] Values1 { get; set; }
public int[] Values2 { get; set; }
public NC_BattleUpdate()
{
}
public NC_BattleUpdate(EType type, int value1, int value2)
{
Username = Multiplayer.Session.LocalPlayer.Data.Username;
Type = type;
Value1 = value1;
Value2 = value2;
Values1 = (Values2 = new int[0]);
}
public NC_BattleUpdate(EType type, int[] values1, int[] values2)
{
Username = Multiplayer.Session.LocalPlayer.Data.Username;
Type = type;
Values1 = values1;
Values2 = values2;
}
}
[RegisterPacketProcessor]
internal class NC_BattleUpdateProcessor : BasePacketProcessor<NC_BattleUpdate>
{
public override void ProcessPacket(NC_BattleUpdate packet, INebulaConnection conn)
{
DSP_Battle_Patch.OnReceive(packet);
}
}
public class NC_LocatorFilter
{
public int AstroId { get; set; }
public int QueryType { get; set; }
public int Mode { get; set; }
public int[] Ids { get; set; }
public int[] Counts { get; set; }
public NC_LocatorFilter()
{
}
public NC_LocatorFilter(int astroId, int queryType, int mode, Dictionary<int, int> filter)
{
AstroId = astroId;
QueryType = queryType;
Mode = mode;
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 Mode { 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 mode, int protoId)
{
AstroId = astroId;
QueryType = queryType;
Mode = mode;
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)
{
continue;
}
StationComponent val = stations[i];
StationIds[i] = val.id;
if (!val.isCollector)
{
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)
{
ref EntityData reference = ref factory.entityPool[val.entityId];
MaxMiningSpeed[i] = factory.factorySystem.minerPool[reference.minerId].speed;
Log.Debug(string.Format("Advance Miner [{0}]: minerId:{1} mining speed {2}%", i, reference.minerId, ((float)MaxMiningSpeed[i] / 100f).ToString("0")));
}
}
}
}
}
[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!");
}
else if (!val2.isCollector)
{
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)
{
ref EntityData reference = ref val.entityPool[val2.entityId];
val.factorySystem.minerPool[reference.minerId].speed = packet.MaxMiningSpeed[i];
Log.Debug(string.Format("Advance Miner [{0}]: minerId:{1} mining speed {2}%", i, reference.minerId, ((float)packet.MaxMiningSpeed[i] / 100f).ToString("0")));
}
}
}
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());
}
}
}
public class NC_UXA_Packet
{
public enum EType
{
None,
InitDysonSphere,
DismantleAll,
BuildOrbitalCollector
}
public EType Type { get; set; }
public int PlanetId { get; set; }
public int AuthorId { get; set; }
public float Value1 { get; set; }
public float Value2 { get; set; }
public float Value3 { get; set; }
public NC_UXA_Packet()
{
}
public NC_UXA_Packet(EType type, int planetId, int authorId)
{
Type = type;
PlanetId = planetId;
AuthorId = authorId;
}
}
[RegisterPacketProcessor]
internal class NC_UXA_PacketProcessor : BasePacketProcessor<NC_UXA_Packet>
{
public override void ProcessPacket(NC_UXA_Packet packet, INebulaConnection conn)
{
//IL_005a: Unknown result type (might be due to invalid IL or missing references)
//IL_0061: Expected O, but got Unknown
//IL_026d: Unknown result type (might be due to invalid IL or missing references)
//IL_0274: Unknown result type (might be due to invalid IL or missing references)
//IL_0279: 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_029a: Unknown result type (might be due to invalid IL or missing references)
//IL_029c: Unknown result type (might be due to invalid IL or missing references)
//IL_02a3: Unknown result type (might be due to invalid IL or missing references)
//IL_02a5: Unknown result type (might be due to invalid IL or missing references)
//IL_02ac: Unknown result type (might be due to invalid IL or missing references)
//IL_02ae: Unknown result type (might be due to invalid IL or missing references)
//IL_02b5: Unknown result type (might be due to invalid IL or missing references)
//IL_02b7: Unknown result type (might be due to invalid IL or missing references)
//IL_02e4: Unknown result type (might be due to invalid IL or missing references)
//IL_02e6: Unknown result type (might be due to invalid IL or missing references)
//IL_02e9: Unknown result type (might be due to invalid IL or missing references)
//IL_01cd: Unknown result type (might be due to invalid IL or missing references)
//IL_01d2: Unknown result type (might be due to invalid IL or missing references)
//IL_01d4: 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_0231: Unknown result type (might be due to invalid IL or missing references)
Log.Debug(packet.Type);
if (packet.Type == NC_UXA_Packet.EType.InitDysonSphere)
{
if (base.IsHost)
{
((INetworkProvider)Multiplayer.Session.Server).SendPacketExclude<NC_UXA_Packet>(packet, conn);
}
int num = (int)packet.Value1;
int num2 = (int)packet.Value2;
DysonSphere val = GameMain.data.dysonSpheres[num];
if (val == null)
{
return;
}
if (num2 < 0)
{
DysonSphere val2 = new DysonSphere();
GameMain.data.dysonSpheres[num] = val2;
val2.Init(GameMain.data, GameMain.data.galaxy.stars[num]);
val2.ResetNew();
}
else
{
if (((val != null) ? val.layersIdBased[num2] : null) == null)
{
return;
}
DysonRocket[] rocketPool = val.rocketPool;
for (int num3 = val.rocketCursor - 1; num3 > 0; num3--)
{
if (rocketPool[num3].id == num3 && rocketPool[num3].nodeLayerId == num2)
{
val.RemoveDysonRocket(num3);
}
}
val.RemoveLayer(num2);
}
return;
}
PlanetFactory val3 = GameMain.galaxy.PlanetById(packet.PlanetId)?.factory;
if (val3 == null)
{
return;
}
using (Multiplayer.Session.Factories.IsIncomingRequest.On())
{
Multiplayer.Session.Factories.TargetPlanet = packet.PlanetId;
Multiplayer.Session.Factories.PacketAuthor = packet.AuthorId;
Multiplayer.Session.Factories.EventFactory = val3;
if (!val3.planet.factoryLoaded)
{
IFactoryManager factories = Multiplayer.Session.Factories;
FactoryManager val4 = (FactoryManager)(object)((factories is FactoryManager) ? factories : null);
if (val4.RemovePlanetTimer(packet.PlanetId))
{
val4.UnloadPlanetData(packet.PlanetId);
}
}
switch (packet.Type)
{
case NC_UXA_Packet.EType.DismantleAll:
{
EntityData[] entityPool = val3.entityPool;
foreach (EntityData val9 in entityPool)
{
if (val9.id == 0)
{
continue;
}
int stationId = val9.stationId;
if (stationId > 0)
{
StationComponent val10 = val3.transport.stationPool[stationId];
if (val10.storage != null)
{
for (int j = 0; j < val10.storage.Length; j++)
{
val10.storage[j].count = 0;
}
}
}
val3.RemoveEntityWithComponents(val9.id, false);
}
break;
}
case NC_UXA_Packet.EType.BuildOrbitalCollector:
{
Vector3 val5 = default(Vector3);
((Vector3)(ref val5))..ctor(packet.Value1, packet.Value2, packet.Value3);
Quaternion val6 = Maths.SphericalRotation(val5, 0f);
PrebuildData val7 = default(PrebuildData);
val7.protoId = 2105;
val7.modelIndex = 117;
val7.pos = val5;
val7.pos2 = val5;
val7.rot = val6;
val7.rot2 = val6;
val7.pickOffset = 0;
val7.insertOffset = 0;
val7.recipeId = 0;
val7.filterId = 0;
val7.paramCount = 0;
PrebuildData val8 = val7;
val3.AddPrebuildDataWithComponents(val8);
break;
}
}
Multiplayer.Session.Factories.TargetPlanet = -2;
Multiplayer.Session.Factories.PacketAuthor = -1;
Multiplayer.Session.Factories.EventFactory = null;
}
}
}
}
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;
GalacticScale.Init(harmony);
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);
UXAssist_Patch.Init(harmony);
Dustbin.Init(harmony);
SphereOpt_Patch.Init(harmony);
FactoryLocator_Patch.Init(harmony);
SplitterOverBelt.Init(harmony);
if (config.Bind<bool>("Sync Patch", "MoreMegaStructure", true, "Enable patching MoreMegaStructure").Value)
{
MoreMegaStructure.Init(harmony);
}
DSPAutoSorter.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.5.1" + 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++;
}
if (Chainloader.PluginInfos.ContainsKey("Weaver"))
{
incompatMessage += "Weaver\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 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 = "3.0.4";
private static ConfigEntry<bool> stationcopyItem_bool;
private static ConfigEntry<bool> auto_supply_station;
public static void Init(Harmony harmony)
{
//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
//IL_00b9: Expected O, but got Unknown
//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
//IL_00ea: Expected O, but got Unknown
//IL_010e: Unknown result type (might be due to invalid IL or missing references)
//IL_011b: Expected O, but got Unknown
//IL_013f: Unknown result type (might be due to invalid IL or missing references)
//IL_014c: Expected O, but got Unknown
//IL_0181: Unknown result type (might be due to invalid IL or missing references)
//IL_019a: Unknown result type (might be due to invalid IL or missing references)
//IL_01a7: Expected O, but got Unknown
//IL_01a7: Expected O, but got Unknown
//IL_01ca: Unknown result type (might be due to invalid IL or missing references)
//IL_01d8: 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.AuxConfig");
Log.Debug(type);
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);
type = assembly.GetType("Auxilaryfunction.Services.LogisticsService");
Log.Debug(type);
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");
Log.Debug(type);
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: 3.0.4");
NC_Patch.ErrorMessage += "\nAuxilaryfunction (last target version: 3.0.4)";
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 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 static class Warper
{
private static bool IsIncoming { get; set; }
public static void HandleRequest(NC_BattleUpdate packet)
{
string text = $"{packet.Username} {packet.Type} ";
Log.Info(text + $"{packet.Value1} {packet.Value2}");
IsIncoming = true;
try
{
switch (packet.Type)
{
case NC_BattleUpdate.EType.AddRelic:
Relic.AddRelic(packet.Value1, packet.Value2);
UIRelic.RefreshSlotsWindowUI();
text += Localization.Translate("遗物名称" + packet.Value1 + "-" + packet.Value2).Split(new char[1] { '\n' })[0];
break;
case NC_BattleUpdate.EType.RemoveRelic:
Relic.RemoveRelic(packet.Value1, packet.Value2);
UIRelic.RefreshSlotsWindowUI();
text += Localization.Translate("遗物名称" + packet.Value1 + "-" + packet.Value2).Split(new char[1] { '\n' })[0];
break;
case NC_BattleUpdate.EType.ApplyAuthorizationPoint:
UISkillPointsWindow.ClearTempLevelAdded();
Array.Copy(packet.Values1, UISkillPointsWindow.tempLevelAddedL, Math.Min(packet.Values1.Length, UISkillPointsWindow.tempLevelAddedL.Length));
Array.Copy(packet.Values2, UISkillPointsWindow.tempLevelAddedR, Math.Min(packet.Values2.Length, UISkillPointsWindow.tempLevelAddedR.Length));
SkillPoints.ConfirmAll();
break;
case NC_BattleUpdate.EType.ResetAuthorizationPoint:
SkillPoints.ResetAll();
break;
}
ChatManager.ShowMessageInChat(text);
}
catch (Exception ex)
{
ChatManager.ShowWarningInChat("DSP_Battle_Patch error!\n" + ex);
}
IsIncoming = false;
}
[HarmonyPostfix]
[HarmonyPatch(typeof(Relic), "AddRelic")]
private static void AddRelic_Postfix(int type, int num)
{
if (Multiplayer.IsActive && !IsIncoming)
{
Multiplayer.Session.Network.SendPacket<NC_BattleUpdate>(new NC_BattleUpdate(NC_BattleUpdate.EType.AddRelic, type, num));
}
}
[HarmonyPostfix]
[HarmonyPatch(typeof(Relic), "RemoveRelic")]
private static void RemoveRelic_Postfix(int removeType, int removeNum)
{
if (Multiplayer.IsActive && !IsIncoming)
{
Multiplayer.Session.Network.SendPacket<NC_BattleUpdate>(new NC_BattleUpdate(NC_BattleUpdate.EType.RemoveRelic, removeType, removeNum));
}
}
[HarmonyPrefix]
[HarmonyPatch(typeof(SkillPoints), "ConfirmAll")]
private static void SkillConfirmAll_Prefix()
{
if (Multiplayer.IsActive && !IsIncoming)
{
Multiplayer.Session.Network.SendPacket<NC_BattleUpdate>(new NC_BattleUpdate(NC_BattleUpdate.EType.ApplyAuthorizationPoint, UISkillPointsWindow.tempLevelAddedL, UISkillPointsWindow.tempLevelAddedR));
}
}
[HarmonyPrefix]
[HarmonyPatch(typeof(SkillPoints), "ResetAll")]
private static void ResetAll_Prefix()
{
if (Multiplayer.IsActive && !IsIncoming)
{
Multiplayer.Session.Network.SendPacket<NC_BattleUpdate>(new NC_BattleUpdate(NC_BattleUpdate.EType.ResetAuthorizationPoint, 0, 0));
}
}
[HarmonyPrefix]
[HarmonyPatch(typeof(PlanetFactory), "KillEnemyFinally")]
private static void KillEnemyFinally_Prefix(PlanetFactory __instance, int enemyId)
{
//IL_003d: Unknown result type (might be due to invalid IL or missing references)
if (!Multiplayer.IsActive || !Multiplayer.Session.IsClient || !Multiplayer.Session.Combat.IsIncomingRequest.Value || enemyId <= 0 || enemyId >= __instance.enemyPool.Length)
{
return;
}
try
{
CombatStat val = default(CombatStat);
val.astroId = __instance.planetId;
val.objectType = 4;
val.objectId = enemyId;
EventSystem.ZeroHpInceptor(ref val, GameMain.data, GameMain.data.spaceSector.skillSystem);
}
catch (Exception obj)
{
Log.Warn(obj);
}
}
[HarmonyPrefix]
[HarmonyPatch(typeof(SpaceSector), "KillEnemyFinal")]
private static void KillEnemyFinal_Prefix(SpaceSector __instance, int enemyId)
{
//IL_004a: Unknown result type (might be due to invalid IL or missing references)
if (!Multiplayer.IsActive || !Multiplayer.Session.IsClient || !Multiplayer.Session.Enemies.IsIncomingRequest.Value || enemyId <= 0 || enemyId >= __instance.enemyPool.Length)
{
return;
}
try
{
ref EnemyData reference = ref __instance.enemyPool[enemyId];
CombatStat val = default(CombatStat);
val.astroId = reference.originAstroId;
val.objectType = 4;
val.objectId = enemyId;
EventSystem.ZeroHpInceptor(ref val, GameMain.data, GameMain.data.spaceSector.skillSystem);
}
catch (Exception obj)
{
Log.Warn(obj);
}
}
}
private const string NAME = "DSP_Battle";
private const string GUID = "com.ckcz123.DSP_Battle";
private const string VERSION = "3.4.10";
private static IModCanSave Save;
public static void Init(Harmony harmony)
{
//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
//IL_0108: Expected O, but got Unknown
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);
}
});
harmony.PatchAll(typeof(Warper));
MethodInfo methodInfo = AccessTools.Method(AccessTools.TypeByName("CommonAPI.Patches.ResourcesPatch"), "Prefix", (Type[])null, (Type[])null);
harmony.Patch((MethodBase)methodInfo, (HarmonyMethod)null, (HarmonyMethod)null, new HarmonyMethod(AccessTools.Method(typeof(DSP_Battle_Patch), "ResourcesPatch_Prefix_Transpiler", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null);
Log.Info("DSP_Battle - OK");
}
catch (Exception obj)
{
Log.Warn("DSP_Battle - Fail! Last target version: 3.4.10");
NC_Patch.ErrorMessage += "\nDSP_Battle (last target version: 3.4.10)";
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 static void OnReceive(NC_BattleUpdate packet)
{
Warper.HandleRequest(packet);
}
public static IEnumerable<CodeInstruction> ResourcesPatch_Prefix_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 == "LogDebug"), (string)null)
}).Repeat((Action<CodeMatcher>)delegate(CodeMatcher matcher)
{
matcher.SetAndAdvance(OpCodes.Pop, (object)null);
}, (Action<string>)null).InstructionEnumeration();
}
catch (Exception)
{
Log.Warn("CommonAPI.Patches.ResourcesPatch.Prefix Transpiler fail!");
return instructions;
}
}
}
public static class Dustbin
{
public const string NAME = "Dustbin";
public const string GUID = "org.soardev.dustbin";
public const string VERSION = "1.3.3";
private static Action<int> RemovePlanetSignalBelts;
private static Action<int, int> SetSignalBelt;
public static void Init(Harmony harmony)
{
if (!Chainloader.PluginInfos.TryGetValue("org.soardev.dustbin", out var value))
{
return;
}
Assembly assembly = ((object)value.Instance).GetType().Assembly;
try
{
Type? type = assembly.GetType("Dustbin.BeltSignal");
SetSignalBelt = AccessTools.MethodDelegate<Action<int, int>>(AccessTools.Method(type, "SetSignalBelt", (Type[])null, (Type[])null), (object)null, true);
RemovePlanetSignalBelts = AccessTools.MethodDelegate<Action<int>>(AccessTools.Method(type, "RemovePlanetSignalBelts", (Type[])null, (Type[])null), (object)null, true);
harmony.PatchAll(typeof(Dustbin));
Log.Info("Dustbin - OK");
}
catch (Exception obj)
{
Log.Warn("Dustbin - Fail! Last target version: 1.3.3");
NC_Patch.ErrorMessage += "\nDustbin (last target version: 1.3.3)";
Log.Debug(obj);
}
}
[HarmonyPrefix]
[HarmonyPatch(typeof(PlanetFactory), "Free")]
private static void Free_Prefix(PlanetFactory __instance)
{
RemovePlanetSignalBelts(__instance.index);
}
[HarmonyPostfix]
[HarmonyPatch(typeof(PlanetFactory), "Import")]
private static void Import_Postfix(PlanetFactory __instance)
{
if (!NC_Patch.IsClient)
{
return;
}
SignData[] entitySignPool = __instance.entitySignPool;
CargoTraffic cargoTraffic = __instance.cargoTraffic;
BeltComponent[] beltPool = cargoTraffic.beltPool;
for (int num = cargoTraffic.beltCursor - 1; num > 0; num--)
{
if (beltPool[num].id == num && entitySignPool[beltPool[num].entityId].iconId0 == 410)
{
SetSignalBelt(__instance.index, num);
}
}
}
}
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 (!NebulaModAPI.IsMultiplayerActive || !NebulaModAPI.MultiplayerSession.LocalPlayer.IsClient || (Plugin.mainLogic.factories.Count > 0 && __instance.veiwStar == null))
{
return true;
}
if (__instance.autoclear_enable)
{
WarningSystemPatch.ClearAll();
}
UILocatorWindow.networkIds = null;
__instance.SetSubcategory(queryType);
NebulaModAPI.MultiplayerSession.Network.SendPacket<NC_LocatorFilter>(new NC_LocatorFilter(astroId, queryType, UILocatorWindow.comboBox.itemIndex, null));
return false;
}
[HarmonyPrefix]
[HarmonyPatch(typeof(UILocatorWindow), "OnComboBoxIndexChange")]
public static bool OnComboBoxIndexChange()
{
if (!NebulaModAPI.IsMultiplayerActive || !NebulaModAPI.MultiplayerSession.LocalPlayer.IsClient || (Plugin.mainLogic.factories.Count > 0 && Plugin.mainWindow.veiwStar == null))
{
return true;
}
bool active = ((ManualBehaviour)UIRoot.instance.uiGame.itemPicker).active;
bool active2 = ((ManualBehaviour)UIRoot.instance.uiGame.recipePicker).active;
switch (UILocatorWindow.queryingType)
{
case 0:
UILocatorWindow.buildingIndex = UILocatorWindow.comboBox.itemIndex;
if (active)
{
Plugin.mainLogic.OnBuildingPickReturn((ItemProto)null);
UIItemPicker.Close();
NebulaModAPI.MultiplayerSession.Network.SendPacket<NC_LocatorFilter>(new NC_LocatorFilter(astroId, UILocatorWindow.queryingType, UILocatorWindow.comboBox.itemIndex, null));
}
break;
case 1:
UILocatorWindow.veinIndex = UILocatorWindow.comboBox.itemIndex;
if (active)
{
Plugin.mainLogic.OnVeinPickReturn((ItemProto)null);
UIItemPicker.Close();
NebulaModAPI.MultiplayerSession.Network.SendPacket<NC_LocatorFilter>(new NC_LocatorFilter(astroId, UILocatorWindow.queryingType, UILocatorWindow.comboBox.itemIndex, null));
}
break;
case 2:
UILocatorWindow.assemblerIndex = UILocatorWindow.comboBox.itemIndex;
if (active2)
{
Plugin.mainLogic.OnAssemblerPickReturn((RecipeProto)null);
UIRecipePicker.Close();
NebulaModAPI.MultiplayerSession.Network.SendPacket<NC_LocatorFilter>(new NC_LocatorFilter(astroId, UILocatorWindow.queryingType, UILocatorWindow.comboBox.itemIndex, null));
}
break;
case 4:
UILocatorWindow.storageIndex = UILocatorWindow.comboBox.itemIndex;
if (active)
{
Plugin.mainLogic.OnStoragePickReturn((ItemProto)null);
UIItemPicker.Close();
NebulaModAPI.MultiplayerSession.Network.SendPacket<NC_LocatorFilter>(new NC_LocatorFilter(astroId, UILocatorWindow.queryingType, UILocatorWindow.comboBox.itemIndex, null));
}
break;
case 5:
UILocatorWindow.stationIndex = UILocatorWindow.comboBox.itemIndex;
if (active)
{
Plugin.mainLogic.OnStationPickReturn((ItemProto)null);
UIItemPicker.Close();
NebulaModAPI.MultiplayerSession.Network.SendPacket<NC_LocatorFilter>(new NC_LocatorFilter(astroId, UILocatorWindow.queryingType, UILocatorWindow.comboBox.itemIndex, null));
}
break;
}
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, packet.Mode);
break;
case 1:
val3.RefreshVein(-1, packet.Mode);
break;
case 2:
val3.RefreshAssemblers(-1, packet.Mode);
break;
case 3:
val3.RefreshSignal(-1);
break;
case 4:
if (packet.Mode == 0)
{
val3.RefreshStorage(-1);
}
else
{
val3.RefreshDispenser(-1, packet.Mode);
}
break;
case 5:
val3.RefreshStation(-1, packet.Mode);
break;
}
conn.SendPacket<NC_LocatorFilter>(new NC_LocatorFilter(packet.AstroId, packet.QueryType, packet.Mode, val3.filterIds));
}
public static void ShowPickerWindow(NC_LocatorFilter packet)
{
//IL_007d: Unknown result type (might be due to invalid IL or missing references)
//IL_0082: 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_011e: Unknown result type (might be due to invalid IL or missing references)
//IL_015f: Unknown result type (might be due to invalid IL or missing references)
//IL_018b: Unknown result type (might be due to invalid IL or missing references)
//IL_01cc: Unknown result type (might be due to invalid IL or missing references)
//IL_01f8: 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];
}
Vector2 windowPos = Plugin.mainLogic.windowPos;
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, (Dictionary<int, Color>)null);
UIItemPickerExtension.Popup(windowPos, (Action<ItemProto>)delegate(ItemProto itemProto)
{
if (itemProto != null)
{
NebulaModAPI.MultiplayerSession.Network.SendPacket<NC_LocatorResult>(new NC_LocatorResult(astroId, packet.QueryType, packet.Mode, ((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, (Dictionary<int, Color>)null);
UIItemPickerExtension.Popup(windowPos, (Action<ItemProto>)delegate(ItemProto itemProto)
{
if (itemProto != null)
{
NebulaModAPI.MultiplayerSession.Network.SendPacket<NC_LocatorResult>(new NC_LocatorResult(astroId, packet.QueryType, packet.Mode, ((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, (Dictionary<int, Color>)null);
UIRecipePickerExtension.Popup(windowPos, (Action<RecipeProto>)delegate(RecipeProto recipeProto)
{
if (recipeProto != null)
{
NebulaModAPI.MultiplayerSession.Network.SendPacket<NC_LocatorResult>(new NC_LocatorResult(astroId, packet.QueryType, packet.Mode, ((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, (Dictionary<int, Color>)null);
UISignalPickerExtension.Popup(windowPos, (Action<int>)delegate(int signalId)
{
if (signalId > 0)
{
NebulaModAPI.MultiplayerSession.Network.SendPacket<NC_LocatorResult>(new NC_LocatorResult(astroId, packet.QueryType, packet.Mode, 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, (Dictionary<int, Color>)null);
UIItemPickerExtension.Popup(windowPos, (Action<ItemProto>)delegate(ItemProto itemProto)
{
if (itemProto != null)
{
NebulaModAPI.MultiplayerSession.Network.SendPacket<NC_LocatorResult>(new NC_LocatorResult(astroId, packet.QueryType, packet.Mode, ((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, (Dictionary<int, Color>)null);
UIItemPickerExtension.Popup(windowPos, (Action<ItemProto>)delegate(ItemProto itemProto)
{
if (itemProto != null)
{
NebulaModAPI.MultiplayerSession.Network.SendPacket<NC_LocatorResult>(new NC_LocatorResult(astroId, packet.QueryType, packet.Mode, ((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, packet.Mode);
break;
case 1:
val3.RefreshVein(packet.ProtoId, packet.Mode);
break;
case 2:
val3.RefreshAssemblers(packet.ProtoId, packet.Mode);
break;
case 3:
val3.RefreshSignal(packet.ProtoId);
break;
case 4:
if (packet.Mode == 0)
{
val3.RefreshStorage(packet.ProtoId);
}
else
{
val3.RefreshDispenser(packet.ProtoId, packet.Mode);
}
break;
case 5:
val3.RefreshStation(packet.ProtoId, packet.Mode);
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.3.4";
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.3.4");
NC_Patch.ErrorMessage += "\nFactoryLocator (last target version: 1.3.4)";
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 GalacticScale
{
public const string NAME = "Galactic Scale 2 Plug-In";
public const string GUID = "dsp.galactic-scale.2";
public const string VERSION = "2.75.10";
public static void Init(Harmony harmony)
{
if (!Chainloader.PluginInfos.TryGetValue("dsp.galactic-scale.2", out var _) || AccessTools.Method(typeof(PlanetData), "GetUnloadedCopy", (Type[])null, (Type[])null) == null)
{
return;
}
try
{
harmony.PatchAll(typeof(GalacticScale));
Log.Info("Galactic Scale 2 Plug-In - OK");
}
catch (Exception obj)
{
Log.Warn("Galactic Scale 2 Plug-In - Fail! Last target version: 2.75.10");
NC_Patch.ErrorMessage += "\nGalactic Scale 2 Plug-In (last target version: 2.75.10)";
Log.Debug(obj);
}
}
[HarmonyPrefix]
[HarmonyPatch(typeof(PlanetFactory), "Init")]
private static void PlanetFactory_Init_Prefix()
{
Monitor.Enter(PlanetModelingManager.planetProcessingLock);
}
[HarmonyPostfix]
[HarmonyPatch(typeof(PlanetFactory), "Init")]
private static void PlanetFactory_Init_Postfix()
{
Monitor.Exit(PlanetModelingManager.planetProcessingLock);
}
[HarmonyTranspiler]
[HarmonyPatch(typeof(PlanetFactory), "Init")]
private static IEnumerable<CodeInstruction> PlanetFactory_Init_Transpiler(IEnumerable<CodeInstruction> instructions)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0031: Unknown result type (might be due to invalid IL or missing references)
//IL_0037: Expected O, but got Unknown
//IL_0081: Unknown result type (might be due to invalid IL or missing references)
//IL_0087: Expected O, but got Unknown
try
{
return new CodeMatcher(instructions, (ILGenerator)null).MatchForward(true, (CodeMatch[])(object)new CodeMatch[1]
{
new CodeMatch((OpCode?)OpCodes.Call, (object)AccessTools.Method(typeof(PlanetData), "GetUnloadedCopy", (Type[])null, (Type[])null), (string)null)
}).SetOperandAndAdvance((object)AccessTools.Method(typeof(GalacticScale), "GetUnloadedCopy", (Type[])null, (Type[])null)).MatchForward(true, (CodeMatch[])(object)new CodeMatch[1]
{
new CodeMatch((OpCode?)OpCodes.Call, (object)AccessTools.Method(typeof(PlanetData), "ReleaseCopy", (Type[])null, (Type[])null), (string)null)
})
.SetAndAdvance(OpCodes.Pop, (object)null)
.InstructionEnumeration();
}
catch (Exception obj)
{
Log.Warn("Transpiler error in PlanetFactory.Init");
Log.Warn(obj);
return instructions;
}
}
private static PlanetData GetUnloadedCopy(PlanetData p)
{
return p;
}
}
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.8.5";
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_01e1: Unknown result type (might be due to invalid IL or missing references)
//IL_01ef: Expected O, but got Unknown
//IL_0229: Unknown result type (might be due to invalid IL or missing references)
//IL_0230: Expected O, but got Unknown
//IL_0244: Unknown result type (might be due to invalid IL or missing references)
//IL_024b: 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);
harmony.Patch((MethodBase)AccessTools.Method(type, "OnRecipeRemoveClick", (Type[])null, (Type[])null), (HarmonyMethod)null, val, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
harmony.Patch((MethodBase)AccessTools.Method(type, "SetProductSpeedRequest", (Type[])null, (Type[])null), (HarmonyMethod)null, val, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
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, "MMSPlanetById", (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.8.5");
NC_Patch.ErrorMessage += "\nMoreMegaStructure (last target version: 1.8.5)";
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)
{
Log.Debug("MoreMegaStructure.SendData");
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_0055: Unknown result type (might be due to invalid IL or missing references)
//IL_005b: Expected O, but got Unknown
//IL_0083: Unknown result type (might be due to invalid IL or missing references)
//IL_0089: Expected O, but got Unknown
//IL_0091: Unknown result type (might be due to invalid IL or missing references)
//IL_0097: Expected O, but got Unknown
//IL_009f: Unknown result type (might be due to invalid IL or missing references)
//IL_00a5: Expected O, but got Unknown
try
{
CodeMatcher val = new CodeMatcher(instructions, (ILGenerator)null).End().MatchBack(true, (CodeMatch[])(object)new CodeMatch[1]
{
new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction i) => i.opcode == OpCodes.Stfld && ((FieldInfo)i.operand).Name == "energyReqCurrentTick"), (string)null)
}).MatchBack(true, (CodeMatch[])(object)new CodeMatch[1]
{
new CodeMatch((OpCode?)OpCodes.Brfalse, (object)null, (string)null)
});
val.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.2.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");
harmony.Patch((MethodBase)type.GetMethod("IsFavPlanet"), new HarmonyMethod(typeof(PlanetFinder_Patch).GetMethod("IsFavPlanet_Prefix")), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
Log.Info("PlanetFinder - OK (last support: 1.2.3)");
}
catch (Exception obj)
{
Log.Warn("PlanetFinder - Fail! Last target version: 1.2.3");
NC_Patch.ErrorMessage += "\nPlanetFinder (last target version: 1.2.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, '\u2009', ' ');
sbText.Append((object?)sbWatt);
StringBuilderUtility.WriteKMG(sbWatt, 8, energyCapacity * 60, false, '\u2009', ' ');
sbText.Append(" / ").Append(sbWatt.ToString().Trim());
if (num > 0)
{
StringBuilderUtility.WriteKMG(sbWatt, 8, num * 60, false, '\u2009', ' ');
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 IsFavPlanet_Prefix(PlanetData planetData, ref bool __result)
{
__result = planetData != null;
return planetData != null;
}
}
public class SphereOpt_Patch
{
public static class Warper
{
public static void OnDysonSphereLoadFinished(int starIndex)
{
DysonSphere val = GameMain.data.dysonSpheres[starIndex];
Log.Debug($"OnDysonSphereLoad [{starIndex}] {val.starData.displayName}");
if (SphereOpt.instRenderers.TryGetValue(val.starData.id, out var value))
{
value.dysonSphere = val;
}
}
[HarmonyPrefix]
[HarmonyPatch(typeof(InstDysonShellRenderer), "RenderShells")]
private static bool RenderShells_Prefix()
{
return GameMain.mainPlayer != null;
}
[HarmonyFinalizer]
[HarmonyPatch(typeof(InstDysonShellRenderer), "RenderShells")]
public static Exception RenderShells_Finalizer()
{
return null;
}
}
public const string NAME = "SphereOpt";
public const string GUID = "SphereOpt";
public const string VERSION = "0.9.1";
public static void Init(Harmony harmony)
{
if (!Chainloader.PluginInfos.TryGetValue("SphereOpt", out var _))
{
return;
}
try
{
NebulaModAPI.OnDysonSphereLoadFinished = (Action<int>)Delegate.Combine(NebulaModAPI.OnDysonSphereLoadFinished, new Action<int>(Warper.OnDysonSphereLoadFinished));
harmony.PatchAll(typeof(Warper));
Log.Info("SphereOpt - OK");
}
catch (Exception obj)
{
Log.Warn("SphereOpt - Fail! Last target version: 0.9.1");
NC_Patch.ErrorMessage += "\nSphereOpt (last target version: 0.9.1)";
Log.Debug(obj);
}
}
}
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;
}
}
public stat