Decompiled source of Void Saving v0.4.7
VoidSaving.dll
Decompiled 2 days ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections.Generic; using System.Diagnostics; using System.IO; 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 BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using CG; using CG.Client.Quests.SectorTwists; using CG.Client.Ship; using CG.Cloud; using CG.Game; using CG.Game.Scenarios; using CG.Game.SpaceObjects.Controllers; using CG.GameLoopStateMachine; using CG.GameLoopStateMachine.GameStates; using CG.Network; using CG.Objects; using CG.Ship.Hull; using CG.Ship.Modules; using CG.Ship.Modules.Shield; using CG.Ship.Object; using CG.Ship.Repair; using CG.Ship.Shield; using CG.Space; using Gameplay.Atmosphere; using Gameplay.CompositeWeapons; using Gameplay.Defects; using Gameplay.Enhancements; using Gameplay.Power; using Gameplay.Quests; using Gameplay.SpacePlatforms; using HarmonyLib; using Microsoft.CodeAnalysis; using Newtonsoft.Json; using Newtonsoft.Json.Linq; using Photon.Pun; using ResourceAssets; using ToolClasses; using UI.AstralMap; using UnityEngine; using VoidManager; using VoidManager.CustomGUI; using VoidManager.MPModChecks; using VoidManager.Progression; using VoidManager.Utilities; using VoidSaving.ReadWriteTools; using VoidSaving.VanillaFixes; using WebSocketSharp; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: AssemblyCompany("VoidSaving")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("0.4.7.0")] [assembly: AssemblyInformationalVersion("0.4.7+52cd50471c723747df11b3f1313739e072b6c81c")] [assembly: AssemblyProduct("VoidSaving")] [assembly: AssemblyTitle("Saves the game while in Void, allowing users to load back up where they left off.")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.4.7.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace VoidSaving { internal class Config { internal static ConfigEntry<string> SavesLocation; internal static ConfigEntry<string> LastSave; internal static ConfigEntry<bool> AutoSavingEnabled; internal static ConfigEntry<int> AutoSaveLimit; internal static ConfigEntry<int> LastAutoSave; internal static ConfigEntry<bool> DefaultIronMan; internal static ConfigEntry<int> ExtraMSUntilInterdiction; internal static void Load(ConfigFile configFile) { SavesLocation = configFile.Bind<string>("Settings", "SavesLocation", string.Empty, (ConfigDescription)null); LastSave = configFile.Bind<string>("Settings", "LastSave", string.Empty, (ConfigDescription)null); AutoSavingEnabled = configFile.Bind<bool>("Settings", "AutoSaving", true, "Auto Saving Enabled/Disabled"); AutoSaveLimit = configFile.Bind<int>("Settings", "AutoSaveLimit", 10, "How many auto save IDs to loop through"); DefaultIronMan = configFile.Bind<bool>("Settings", "DefaultIronManMode", true, "Default state for iron man setting."); ExtraMSUntilInterdiction = configFile.Bind<int>("Settings", "ExtraMSUntilInterdiction", 10000, "Time in MS added to interdictions during load."); LastAutoSave = configFile.Bind<int>("Data", "LastAutoSave", 0, (ConfigDescription)null); } } internal class GUI : ModSettingsMenu { private Dictionary<string, SaveFilePeekData> SaveNames; private Vector2 SaveScrollPosition; private bool IronManMode = true; private string ToDeleteFileName; private bool ConfirmedDelete; private string SaveName; private string ErrorMessage; public override string Name() { return "Void Saving"; } private void DrawSaveFileList() { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) SaveScrollPosition = GUILayout.BeginScrollView(SaveScrollPosition, Array.Empty<GUILayoutOption>()); foreach (KeyValuePair<string, SaveFilePeekData> saveName in SaveNames) { GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); SaveFilePeekData value = saveName.Value; if (GUITools.DrawButtonSelected(string.Format("{0}{1}{2} - {3} | {4}, {5} Jumps, Hull {6:N0}%. {7}:{8:00} Played", saveName.Key, value.IronMan ? " (IronMan)" : string.Empty, value.ProgressDisabled ? " (Progress Disabled)" : string.Empty, value.writeTime, value.ShipName, value.JumpCounter, value.HealthPercent * 100f, (int)value.TimePlayed.TotalHours, value.TimePlayed.Minutes), SaveName == saveName.Key)) { SaveName = saveName.Key; } if (GUILayout.Button("X", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.MaxWidth(25f) })) { ToDeleteFileName = saveName.Key; } GUILayout.EndHorizontal(); if (ToDeleteFileName == saveName.Key && GUILayout.Button("Confirm delete file?", Array.Empty<GUILayoutOption>())) { ConfirmedDelete = true; } } GUILayout.EndScrollView(); if (ConfirmedDelete) { ConfirmedDelete = false; SaveNames.Remove(ToDeleteFileName); SaveHandler.DeleteSaveFile(ToDeleteFileName); ToDeleteFileName = null; } } private void DrawAutoSaveSelection() { GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); GUITools.DrawCheckbox("Auto Saves Enabled", ref Config.AutoSavingEnabled); GUILayout.FlexibleSpace(); GUILayout.FlexibleSpace(); GUITools.DrawTextField<int>("Auto Save Limit", ref Config.AutoSaveLimit, 80f); GUILayout.EndHorizontal(); } public override void Draw() { if (!GameSessionManager.HasActiveSession) { DrawSaveFileList(); GUILayout.Label("Must be in hub to load a save file", Array.Empty<GUILayoutOption>()); return; } if (!(((AbstractStateMachine<GameStateMachine>)(object)Singleton<GameStateMachine>.I).CurrentState is GSIngame)) { DrawSaveFileList(); GUILayout.Label("Must be in hub or in-game to load/save", Array.Empty<GUILayoutOption>()); return; } if (GameSessionManager.InHub) { GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); GUITools.DrawCheckbox("Default Iron Man Mode", ref Config.DefaultIronMan); if (GUITools.DrawCheckbox("Iron Man Mode for next game", ref IronManMode)) { SaveHandler.IsIronManMode = IronManMode; } GUILayout.EndHorizontal(); DrawAutoSaveSelection(); DrawSaveFileList(); if (SaveName == null) { GUILayout.Label("Select a save", Array.Empty<GUILayoutOption>()); } else if (GUILayout.Button(SaveHandler.LoadSavedData ? ("Loading " + SaveHandler.LastSaveName + " on next session start") : "Load Save", Array.Empty<GUILayoutOption>()) && !SaveHandler.LoadSave(SaveName)) { ErrorMessage = "<color=red>Failed to load " + SaveName + "</color>"; } if (ErrorMessage != null) { GUILayout.Label(ErrorMessage, Array.Empty<GUILayoutOption>()); } if (SaveHandler.LoadSavedData) { if (GUILayout.Button("Cancel Load", Array.Empty<GUILayoutOption>())) { SaveHandler.CancelOrFinalzeLoad(); } } else { GUILayout.Label(string.Empty, Array.Empty<GUILayoutOption>()); } return; } DrawSaveFileList(); ClientGame current = ClientGame.Current; object obj; if (current == null) { obj = null; } else { AbstractPlayerControlledShip playerShip = current.PlayerShip; if (playerShip == null) { obj = null; } else { Transform transform = ((Component)playerShip).transform; obj = ((transform != null) ? ((Component)transform).GetComponent<VoidJumpSystem>() : null); } } VoidJumpSystem val = (VoidJumpSystem)obj; VoidJumpState val2 = ((val != null) ? val.ActiveState : null); if (!SaveHandler.StartedAsHost) { GUILayout.Label("Must be the original host of the session.", Array.Empty<GUILayoutOption>()); return; } if (val2 == null || (!(val2 is VoidJumpTravellingStable) && !(val2 is VoidJumpTravellingUnstable))) { GUILayout.Label("Cannot save outside void jump.", Array.Empty<GUILayoutOption>()); return; } SaveName = GUILayout.TextField(SaveName, Array.Empty<GUILayoutOption>()); if (ErrorMessage != null) { GUILayout.Label(ErrorMessage, Array.Empty<GUILayoutOption>()); } DrawAutoSaveSelection(); if (SaveHandler.IsIronManMode) { if (GUILayout.Button("Save Game", Array.Empty<GUILayoutOption>())) { if (Ext.IsNullOrEmpty(SaveName)) { ErrorMessage = "<color=red>Cannot save without a file name.</color>"; } else if (SaveHandler.WriteIronManSave(SaveName)) { SaveNames = SaveHandler.GetPeekedSaveFiles(); ErrorMessage = "Successfully wrote " + SaveName; } } } else if (GUILayout.Button("Save Game", Array.Empty<GUILayoutOption>())) { if (Ext.IsNullOrEmpty(SaveName)) { ErrorMessage = "<color=red>Cannot save without a file name.</color>"; } else if (SaveHandler.WriteSave(SaveName)) { SaveNames = SaveHandler.GetPeekedSaveFiles(); ErrorMessage = "Successfully wrote " + SaveName; } } } public override void OnOpen() { IronManMode = SaveHandler.IsIronManMode; ToDeleteFileName = null; SaveNames = SaveHandler.GetPeekedSaveFiles(); if (SaveHandler.ActiveData != null) { SaveName = SaveHandler.ActiveData?.FileName; } else { SaveName = SaveHandler.LastSaveName; } ErrorMessage = null; } } public class MyPluginInfo { public const string PLUGIN_GUID = "Dragon.VoidSaving"; public const string PLUGIN_NAME = "VoidSaving"; public const string USERS_PLUGIN_NAME = "Void Saving"; public const string PLUGIN_VERSION = "0.4.7"; public const string PLUGIN_DESCRIPTION = "Saves the game while in Void, allowing users to load back up where they left off."; public const string PLUGIN_ORIGINAL_AUTHOR = "Dragon"; public const string PLUGIN_AUTHORS = "Dragon"; public const string PLUGIN_THUNDERSTORE_ID = "VoidCrewModdingTeam/Void-Saving"; } [BepInPlugin("Dragon.VoidSaving", "Void Saving", "0.4.7")] [BepInProcess("Void Crew.exe")] [BepInDependency(/*Could not decode attribute arguments.*/)] public class BepinPlugin : BaseUnityPlugin { internal static ManualLogSource Log; private void Awake() { Log = ((BaseUnityPlugin)this).Logger; Config.Load(((BaseUnityPlugin)this).Config); Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), (string)null); ((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin Dragon.VoidSaving is loaded!"); } } public class VoidManagerPlugin : VoidPlugin { public override MultiplayerType MPType => (MultiplayerType)14; public override string Author => "Dragon"; public override string Description => "Saves the game while in Void, allowing users to load back up where they left off."; public override string ThunderstoreID => "VoidCrewModdingTeam/Void-Saving"; public override SessionChangedReturn OnSessionChange(SessionChangedInput input) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Expected I4, but got Unknown //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) SaveHandler.StartedAsHost = input.StartedSessionAsHost; CallType callType = input.CallType; CallType val = callType; switch ((int)val) { case 2: SaveHandler.LatestData = null; break; case 0: { SessionChangedReturn result = default(SessionChangedReturn); result.SetMod_Session = true; return result; } case 1: case 3: if (input.IsHost && GameSessionManager.HasActiveSession && GameSessionManager.InHub) { SessionChangedReturn result = default(SessionChangedReturn); result.SetMod_Session = true; return result; } break; } return ((VoidPlugin)this).OnSessionChange(input); } } internal class SaveFilePeekData { public DateTime writeTime; public string ShipName; public int JumpCounter; public TimeSpan TimePlayed; public bool IronMan; public bool ProgressDisabled; public float HealthPercent; public SaveFilePeekData(string FileName, DateTime LastWriteTime) { writeTime = LastWriteTime; SaveGameData saveGameData = SaveHandler.PeekSaveFile(FileName); if (!Ext.IsNullOrEmpty(saveGameData.PeekInfo)) { string[] array = saveGameData.PeekInfo.Split(','); ShipName = array[0]; JumpCounter = int.Parse(array[1]); TimePlayed = TimeSpan.FromHours(double.Parse(array[2])); if (array.Length > 3) { ProgressDisabled = bool.Parse(array[3]); if (array.Length > 4) { HealthPercent = float.Parse(array[4]); } } } else { TimePlayed = TimeSpan.FromHours(-99.99); JumpCounter = -1; ShipName = "Couldn't peek file info"; HealthPercent = -0.99f; } IronMan = saveGameData.IronManMode; } } public class SaveGameData { public uint SaveDataVersion; public string FileName; public string PeekInfo = string.Empty; public bool IronManMode = Config.DefaultIronMan.Value; public bool ProgressionDisabled; public int Alloy; public int Biomass; public GUIDUnion[] Relics; public GUIDUnion[] UnlockedBPs; public int FabricatorTier; public float ShipHealth; public float RepairableShipHealth; public byte[] Breaches; public sbyte[] Defects; public GUIDUnion ShipLoadoutGUID; public JObject ShipLoadout; public ShipSocketData[] BuildSocketCarryables; public bool ShipPowered; public bool[] ModulePowerStates; public bool[] ShipSystemPowerStates; public BoosterStatus[] BoosterStates; public EnhancementData[] Enhancements; public WeaponBullets[] WeaponBullets; public CircuitBreakerData BreakerData; public VoidDriveModuleData JumpModule; public AtmosphereValues[] AtmosphereValues; public AtmosphereValues[] AtmosphereBufferValues; public bool[] DoorStates; public bool[] AirlockSafeties; public byte[] LifeSupportModeSwitches; public byte[] AutoMechanicSwitches; public bool[] ShieldDirections; public float[] ShieldHealths; public float[] KPDBullets; public List<float> AmmoResourceValues = new List<float>(); public List<float> PowerResourceValues = new List<float>(); public int Seed; public int JumpCounter; public int InterdictionCounter; public float CurrentInterdictionChance; public FullSectorData[] CompletedSectors; public GameSessionStatistics SessionStats; } public struct SectionData { public FullSectorData[] ObjectiveSectors; public FullSectorData InterdictionSector; public int SolarSystemIndex; public int SectionIndex; } public struct FullSectorData { public ObjectiveState State; public int SectorID; public FullSectorData(GameSessionSector Sector) { //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) if (Bindings.IsDebugMode) { BepinPlugin.Log.LogInfo((object)"Converting sector data"); } State = Sector.ObjectiveState; SectorID = Sector.Id; } } public struct SimpleSectorData { public int SolarSystemIndex; public GUIDUnion SectorContainerGUID; public SimpleSectorData(int solarSystemIndex, GUIDUnion sectorContainerGUID) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) SolarSystemIndex = solarSystemIndex; SectorContainerGUID = sectorContainerGUID; } } public struct BoosterStatus { public ThrusterBoosterState BoosterState; public float DischargeTimer; public float ChargeTimer; public float CooldownTimer; public BoosterStatus(ThrusterBoosterState state, float dischargeTimer, float chargeTimer, float cooldownTimer) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) BoosterState = state; DischargeTimer = dischargeTimer; ChargeTimer = chargeTimer; CooldownTimer = cooldownTimer; } } public struct WeaponBullets { public float AmmoLoaded; public float AmmoReservoir; public WeaponBullets(float ammoLoaded, float ammoReservoir) { AmmoLoaded = ammoLoaded; AmmoReservoir = ammoReservoir; } } public struct EnhancementData { public EnhancementState state; public int ActivationTimeEnd; public int ActivationTimeStart; public int CooldownTimeEnd; public int CooldownTimeStart; public int FailureTimeEnd; public int FailureTimeStart; public short ParentModuleID; public float LastGrade; public float LastDurationMult; public EnhancementData(Enhancement enhancement, int moduleID) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) int serverTimestamp = PhotonNetwork.ServerTimestamp; state = enhancement.State; ActivationTimeStart = enhancement._activationStartTime - serverTimestamp; ActivationTimeEnd = enhancement._activationEndTime - serverTimestamp; CooldownTimeStart = enhancement._cooldownStartTime - serverTimestamp; CooldownTimeEnd = enhancement._cooldownEndTime - serverTimestamp; FailureTimeStart = enhancement._failureStartTime - serverTimestamp; FailureTimeEnd = enhancement._failureEndTime - serverTimestamp; LastGrade = enhancement._lastActivationGrade; LastDurationMult = enhancement._lastDurationMultiplier; ParentModuleID = (short)moduleID; } } public struct CircuitBreakerData { public bool[] breakers; public float currentTemperature; public float NextBreakTemperature; } public struct VoidDriveModuleData { public bool[] engineChargedStates; public float JumpCharge; public VoidDriveModuleData(VoidDriveModule module) { engineChargedStates = module.EngineChargedStates; JumpCharge = module.JumpCharge; } } public struct ShipSocketData { public int SocketID; public GUIDUnion ObjectGUID; public string JData; public ShipSocketData(BuildSocket socket) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) SocketID = socket.Index; ObjectGUID = ((AbstractCloneStarObject)((CarryablesSocket)socket).Payload).assetGuid; object jData; if (!((AbstractCloneStarObject)((CarryablesSocket)socket).Payload).SerializeExtraData) { jData = string.Empty; } else { JObject extraJData = ((AbstractCloneStarObject)((CarryablesSocket)socket).Payload).ExtraJData; jData = ((extraJData != null) ? ((JToken)extraJData).ToString((Formatting)0, Array.Empty<JsonConverter>()) : null); } JData = (string)jData; } } internal class SaveHandler { [Flags] public enum LoadingStage { None = 0, SectorLoad = 1, AbstractPlayerShipStart = 2, InGameLoad = 4 } public const string SaveFolderName = "Saves"; public const string SaveExtension = ".voidsave"; private static SaveGameData m_LatestData; private static LoadingStage CompletedStages; private static LoadingStage AllLoadingStages = LoadingStage.SectorLoad | LoadingStage.AbstractPlayerShipStart | LoadingStage.InGameLoad; public const uint CurrentDataVersion = 1u; public static string SaveLocation => Directory.GetCurrentDirectory() + "\\Saves"; public static SaveGameData ActiveData { get; internal set; } internal static SaveGameData LatestData { get { if (m_LatestData == null) { m_LatestData = new SaveGameData(); } return m_LatestData; } set { m_LatestData = value; } } public static bool StartedAsHost { get; internal set; } internal static bool LoadSavedData => ActiveData != null; internal static bool IsIronManMode { get { return LatestData.IronManMode; } set { LatestData.IronManMode = value; } } internal static string LastSaveName => LatestData.FileName; internal static void DeleteSaveFile(string SaveName) { File.Delete(Path.Combine(SaveLocation, SaveName + ".voidsave")); } internal static Dictionary<string, SaveFilePeekData> GetPeekedSaveFiles() { Directory.CreateDirectory(SaveLocation); string[] files = Directory.GetFiles(SaveLocation); Dictionary<string, SaveFilePeekData> dictionary = new Dictionary<string, SaveFilePeekData>(); string[] array = files; foreach (string text in array) { if (text.EndsWith(".voidsave")) { string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(text); dictionary.Add(fileNameWithoutExtension, new SaveFilePeekData(fileNameWithoutExtension, File.GetLastWriteTime(text))); } } dictionary.OrderBy((KeyValuePair<string, SaveFilePeekData> x) => x.Value.writeTime); return dictionary; } internal static SaveGameData GetSessionSaveGameData() { //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_03c9: Unknown result type (might be due to invalid IL or missing references) //IL_03d0: Expected O, but got Unknown //IL_042b: Unknown result type (might be due to invalid IL or missing references) SaveGameData latestData = LatestData; try { GameSession activeGameSession = GameSessionManager.Instance.activeGameSession; AbstractPlayerControlledShip playerShip = ClientGame.Current.PlayerShip; latestData.ProgressionDisabled = !ProgressionHandler.ProgressionEnabled; latestData.Alloy = GameSessionSuppliesManager.Instance.AlloyAmount; latestData.Biomass = GameSessionSuppliesManager.Instance.BiomassAmount; latestData.ShipHealth = ((OrbitObject)playerShip).HitPoints; latestData.ShipLoadoutGUID = GameSessionManager.Instance.PreviousSessionShipLoadout; latestData.ShipLoadout = new ShipLoadout(((Component)playerShip).GetComponent<PlayerShip>()).AsJObject(); latestData.Relics = Helpers.RelicGUIDsFromShip(playerShip); latestData.UnlockedBPs = Helpers.UnlockedBPGUIDsFromShip(playerShip); latestData.FabricatorTier = ((Component)playerShip).GetComponentInChildren<FabricatorModule>().CurrentTier; HullDamageController componentInChildren = ((Component)playerShip).GetComponentInChildren<HullDamageController>(); latestData.RepairableShipHealth = componentInChildren.State.repairableHp; latestData.Breaches = Helpers.GetBreachStates(componentInChildren); latestData.Defects = Helpers.GetDefectStates(((Component)playerShip).GetComponent<PlayerShipDefectDamageController>()); List<bool> list = new List<bool>(); CellModule[] coreSystems = playerShip.CoreSystems; foreach (CellModule val in coreSystems) { list.Add(val.IsPowered); } latestData.ShipSystemPowerStates = list.ToArray(); BuildSocketController component = ((Component)playerShip).GetComponent<BuildSocketController>(); List<bool> list2 = new List<bool>(); List<WeaponBullets> list3 = new List<WeaponBullets>(); List<float> list4 = new List<float>(); List<bool> list5 = new List<bool>(); List<byte> list6 = new List<byte>(); List<byte> list7 = new List<byte>(); foreach (BuildSocket socket in component.Sockets) { if ((Object)(object)socket.InstalledModule == (Object)null) { continue; } list2.Add(socket.InstalledModule.IsPowered); CellModule installedModule = socket.InstalledModule; CompositeWeaponModule val2 = (CompositeWeaponModule)(object)((installedModule is CompositeWeaponModule) ? installedModule : null); if (val2 != null) { WeaponMagazine magazine = val2.InsideElementsCollection.Magazine; BulletMagazine val3 = (BulletMagazine)(object)((magazine is BulletMagazine) ? magazine : null); if (val3 != null) { list3.Add(new WeaponBullets(val3.AmmoLoaded, val3.ReservoirAmmoCount)); continue; } } CellModule installedModule2 = socket.InstalledModule; KineticPointDefenseModule val4 = (KineticPointDefenseModule)(object)((installedModule2 is KineticPointDefenseModule) ? installedModule2 : null); if (val4 != null) { list4.Add(val4.AmmoCount); continue; } CellModule installedModule3 = socket.InstalledModule; ShieldModule val5 = (ShieldModule)(object)((installedModule3 is ShieldModule) ? installedModule3 : null); if (val5 != null) { list5.Add(((ChangeResponsive<bool>)(object)val5.IsClockwise).Value); list5.Add(((ChangeResponsive<bool>)(object)val5.IsForward).Value); list5.Add(((ChangeResponsive<bool>)(object)val5.IsCounterClockwise).Value); continue; } CellModule installedModule4 = socket.InstalledModule; AutoMechanicModule val6 = (AutoMechanicModule)(object)((installedModule4 is AutoMechanicModule) ? installedModule4 : null); if (val6 != null) { list7.Add(((ChangeResponsive<byte>)(object)val6.TriSwitch).Value); continue; } CellModule installedModule5 = socket.InstalledModule; LifeSupportModule val7 = (LifeSupportModule)(object)((installedModule5 is LifeSupportModule) ? installedModule5 : null); if (val7 != null) { list6.Add(((ChangeResponsive<byte>)(object)val7.TemperatureSwitch).Value); } } latestData.BuildSocketCarryables = Helpers.GetBuildSocketPayloads(component); latestData.ModulePowerStates = list2.ToArray(); latestData.ShieldDirections = list5.ToArray(); latestData.KPDBullets = list4.ToArray(); latestData.WeaponBullets = list3.ToArray(); latestData.AutoMechanicSwitches = list7.ToArray(); latestData.LifeSupportModeSwitches = list6.ToArray(); latestData.BoosterStates = Helpers.GetBoosterStates(playerShip); latestData.ShieldHealths = Helpers.GetShipShieldHealths(playerShip); latestData.Enhancements = Helpers.GetEnhancements(playerShip); latestData.JumpModule = new VoidDriveModuleData(((Component)playerShip).GetComponentInChildren<VoidDriveModule>()); Tuple<AtmosphereValues[], AtmosphereValues[]> atmosphereValues = Helpers.GetAtmosphereValues(playerShip); latestData.AtmosphereValues = atmosphereValues.Item1; latestData.AtmosphereBufferValues = atmosphereValues.Item2; latestData.DoorStates = Helpers.GetDoorStates(playerShip); latestData.AirlockSafeties = Helpers.GetAirlockSafeties(playerShip); ProtectedPowerSystem powerSystem = (ProtectedPowerSystem)playerShip.ShipsPowerSystem; latestData.ShipPowered = ((PowerDistributor)playerShip.ShipsPowerSystem).IsPowered(); latestData.BreakerData = Helpers.GetBreakerData(powerSystem); Quest activeQuest = activeGameSession.ActiveQuest; EndlessQuest val8 = (EndlessQuest)(object)((activeQuest is EndlessQuest) ? activeQuest : null); latestData.Seed = ((Quest)val8).QuestParameters.Seed; latestData.SessionStats = GameSessionTracker.Statistics; latestData.CompletedSectors = Helpers.GetCompletedSectorDatas(val8); ShipLoadoutDataDef val9 = default(ShipLoadoutDataDef); string text = ((!((ResourceAssetContainer<ShipLoadoutDataContainer, ShipLoadoutData, ShipLoadoutDataDef>)(object)ResourceAssetContainer<ShipLoadoutDataContainer, ShipLoadoutData, ShipLoadoutDataDef>.Instance).TryGetByGuid(latestData.ShipLoadoutGUID, ref val9)) ? ((AbstractCloneStarObject)playerShip).DisplayName : (val9.ShipContextInfo.HeaderText + ": " + val9.ContextInfo.HeaderText)); latestData.PeekInfo = $"{text},{latestData.CompletedSectors.Length},{DateTime.Now.Subtract(latestData.SessionStats.QuestStartTime).TotalHours},{latestData.ProgressionDisabled},{latestData.ShipHealth / ((OrbitObject)playerShip).startingHitPoints}"; } catch (Exception ex) { BepinPlugin.Log.LogError((object)("Failed to save data\n" + ex)); Messaging.Notification("<color=red>Failed to save data.</color>", false); } return latestData; } public static void CompleteLoadingStage(LoadingStage stage) { CompletedStages |= stage; BepinPlugin.Log.LogInfo((object)("Completed Loading Stage: " + stage)); if (CompletedStages == AllLoadingStages) { BepinPlugin.Log.LogInfo((object)"Finished all loading stages"); CancelOrFinalzeLoad(); } } public static bool HasCompletedStage(LoadingStage stage) { return CompletedStages.HasFlag(stage); } public static void CancelOrFinalzeLoad() { ActiveData = null; CompletedStages = LoadingStage.None; if (GameSessionManager.InHub) { HubQuestManager.Instance.SelectShip(new int[4]); HubQuestManager.Instance.SelectQuest((QuestParameters)null); } } public static bool LoadSave(string SaveName) { //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: Unknown result type (might be due to invalid IL or missing references) string text = Path.Combine(SaveLocation, SaveName + ".voidsave"); BepinPlugin.Log.LogInfo((object)("Attempting to load save: " + text)); Directory.CreateDirectory(Path.GetDirectoryName(text)); SaveGameData saveGameData = new SaveGameData(); saveGameData.FileName = SaveName; try { using FileStream fileStream = File.OpenRead(text); BepinPlugin.Log.LogInfo((object)$"Starting read save: {fileStream.Length} Bytes"); using BinaryReader binaryReader = new BinaryReader(fileStream); saveGameData.SaveDataVersion = binaryReader.ReadUInt32(); saveGameData.PeekInfo = binaryReader.ReadString(); saveGameData.IronManMode = binaryReader.ReadBoolean(); saveGameData.ProgressionDisabled = binaryReader.ReadBoolean(); saveGameData.Alloy = binaryReader.ReadInt32(); saveGameData.Biomass = binaryReader.ReadInt32(); saveGameData.ShipHealth = binaryReader.ReadSingle(); if (Bindings.IsDebugMode) { BepinPlugin.Log.LogInfo((object)$"Read {fileStream.Position} Bytes"); } saveGameData.ShipLoadoutGUID = binaryReader.ReadGUIDUnion(); saveGameData.ShipLoadout = binaryReader.ReadJObject(); if (saveGameData.SaveDataVersion >= 1) { saveGameData.BuildSocketCarryables = binaryReader.ReadIndexedSocketPayloads(); } saveGameData.AmmoResourceValues = binaryReader.ReadSingleList(); saveGameData.PowerResourceValues = binaryReader.ReadSingleList(); saveGameData.Relics = binaryReader.ReadGUIDUnionArray(); saveGameData.UnlockedBPs = binaryReader.ReadGUIDUnionArray(); saveGameData.FabricatorTier = binaryReader.ReadByte(); if (Bindings.IsDebugMode) { BepinPlugin.Log.LogInfo((object)$"Read {fileStream.Position} Bytes"); } saveGameData.RepairableShipHealth = binaryReader.ReadSingle(); saveGameData.Breaches = binaryReader.ReadByteArray(); saveGameData.Defects = binaryReader.ReadSByteArray(); saveGameData.ShipPowered = binaryReader.ReadBoolean(); saveGameData.BreakerData = binaryReader.ReadBreakers(); saveGameData.ShipSystemPowerStates = binaryReader.ReadBooleanArray(); saveGameData.ModulePowerStates = binaryReader.ReadBooleanArray(); saveGameData.ShieldDirections = binaryReader.ReadBooleanArray(); saveGameData.Enhancements = binaryReader.ReadEnhancements(); saveGameData.WeaponBullets = binaryReader.ReadWeaponBullets(); saveGameData.KPDBullets = binaryReader.ReadSingleArray(); saveGameData.LifeSupportModeSwitches = binaryReader.ReadByteArray(); saveGameData.AutoMechanicSwitches = binaryReader.ReadByteArray(); if (Bindings.IsDebugMode) { BepinPlugin.Log.LogInfo((object)$"Read {fileStream.Position} Bytes"); } saveGameData.BoosterStates = binaryReader.ReadBoosterStatuses(); saveGameData.ShieldHealths = binaryReader.ReadSingleArray(); saveGameData.JumpModule = binaryReader.ReadVoidDriveData(); saveGameData.AtmosphereValues = binaryReader.ReadAtmosphereValues(); saveGameData.AtmosphereBufferValues = binaryReader.ReadAtmosphereValues(); saveGameData.DoorStates = binaryReader.ReadBooleanArray(); saveGameData.AirlockSafeties = binaryReader.ReadBooleanArray(); if (Bindings.IsDebugMode) { BepinPlugin.Log.LogInfo((object)$"Read {fileStream.Position} Bytes"); } saveGameData.Seed = binaryReader.ReadInt32(); saveGameData.JumpCounter = binaryReader.ReadInt32(); saveGameData.InterdictionCounter = binaryReader.ReadInt32(); saveGameData.CurrentInterdictionChance = binaryReader.ReadSingle(); if (Bindings.IsDebugMode) { BepinPlugin.Log.LogInfo((object)$"Read {fileStream.Position} Bytes"); } saveGameData.CompletedSectors = binaryReader.ReadFullSectorDatas(); saveGameData.SessionStats = binaryReader.ReadSessionStats(); BepinPlugin.Log.LogInfo((object)$"Finalized read at {fileStream.Position} Bytes"); } catch (Exception ex) { BepinPlugin.Log.LogError((object)("Failed to load save " + text + "\n" + ex.Message)); return false; } HubQuestManager.Instance.SelectShip(((GUIDUnion)(ref saveGameData.ShipLoadoutGUID)).AsIntArray()); HubQuestManager.Instance.SelectQuest(((Quest)HubQuestManager.Instance.GetEndlessQuest()).QuestParameters); ActiveData = saveGameData; LatestData = saveGameData; Messaging.Echo("Loading save '" + SaveName + "' on next game start.", false); if (saveGameData.ProgressionDisabled) { Messaging.Echo("Progress will be disabled after starting.", true); } return true; } public static SaveGameData PeekSaveFile(string SaveName) { string text = Path.Combine(SaveLocation, SaveName + ".voidsave"); BepinPlugin.Log.LogInfo((object)("Attempting to peek save: " + text)); Directory.CreateDirectory(Path.GetDirectoryName(text)); SaveGameData saveGameData = new SaveGameData(); try { using FileStream fileStream = File.OpenRead(text); BepinPlugin.Log.LogInfo((object)$"Starting peek save: {fileStream.Length} Bytes"); using BinaryReader binaryReader = new BinaryReader(fileStream); saveGameData.SaveDataVersion = binaryReader.ReadUInt32(); saveGameData.PeekInfo = binaryReader.ReadString(); saveGameData.IronManMode = binaryReader.ReadBoolean(); } catch (Exception ex) { BepinPlugin.Log.LogError((object)("Failed to peek save " + text + "\n" + ex.Message)); } return saveGameData; } public static bool WriteSave(string FileName) { //IL_0108: Unknown result type (might be due to invalid IL or missing references) string text = Path.Combine(SaveLocation, FileName); BepinPlugin.Log.LogInfo((object)("Attempting to write save: " + text)); if (!text.EndsWith(".voidsave")) { text += ".voidsave"; } string text2 = text + ".safe"; Directory.CreateDirectory(Path.GetDirectoryName(text)); SaveGameData sessionSaveGameData = GetSessionSaveGameData(); sessionSaveGameData.FileName = FileName; try { using (FileStream fileStream = File.Create(text2)) { using BinaryWriter binaryWriter = new BinaryWriter(fileStream); binaryWriter.Write(1u); binaryWriter.Write(sessionSaveGameData.PeekInfo); binaryWriter.Write(sessionSaveGameData.IronManMode); binaryWriter.Write(sessionSaveGameData.ProgressionDisabled); binaryWriter.Write(sessionSaveGameData.Alloy); binaryWriter.Write(sessionSaveGameData.Biomass); binaryWriter.Write(sessionSaveGameData.ShipHealth); if (Bindings.IsDebugMode) { BepinPlugin.Log.LogInfo((object)$"Wrote {fileStream.Length} Bytes"); } binaryWriter.Write(sessionSaveGameData.ShipLoadoutGUID); binaryWriter.Write(sessionSaveGameData.ShipLoadout); binaryWriter.Write(sessionSaveGameData.BuildSocketCarryables); binaryWriter.Write(sessionSaveGameData.AmmoResourceValues); binaryWriter.Write(sessionSaveGameData.PowerResourceValues); binaryWriter.Write(sessionSaveGameData.Relics); binaryWriter.Write(sessionSaveGameData.UnlockedBPs); binaryWriter.Write((byte)sessionSaveGameData.FabricatorTier); if (Bindings.IsDebugMode) { BepinPlugin.Log.LogInfo((object)$"Wrote {fileStream.Length} Bytes"); } binaryWriter.Write(sessionSaveGameData.RepairableShipHealth); binaryWriter.WriteByteArray(sessionSaveGameData.Breaches); binaryWriter.WriteSByteArray(sessionSaveGameData.Defects); binaryWriter.Write(sessionSaveGameData.ShipPowered); binaryWriter.Write(sessionSaveGameData.BreakerData); if (Bindings.IsDebugMode) { BepinPlugin.Log.LogInfo((object)$"Wrote {fileStream.Length} Bytes"); } binaryWriter.Write(sessionSaveGameData.ShipSystemPowerStates); binaryWriter.Write(sessionSaveGameData.ModulePowerStates); binaryWriter.Write(sessionSaveGameData.ShieldDirections); binaryWriter.Write(sessionSaveGameData.Enhancements); binaryWriter.Write(sessionSaveGameData.WeaponBullets); binaryWriter.Write(sessionSaveGameData.KPDBullets); binaryWriter.WriteByteArray(sessionSaveGameData.LifeSupportModeSwitches); binaryWriter.WriteByteArray(sessionSaveGameData.AutoMechanicSwitches); if (Bindings.IsDebugMode) { BepinPlugin.Log.LogInfo((object)$"Wrote {fileStream.Length} Bytes"); } binaryWriter.Write(sessionSaveGameData.BoosterStates); binaryWriter.Write(sessionSaveGameData.ShieldHealths); binaryWriter.Write(sessionSaveGameData.JumpModule); binaryWriter.Write(sessionSaveGameData.AtmosphereValues); binaryWriter.Write(sessionSaveGameData.AtmosphereBufferValues); binaryWriter.Write(sessionSaveGameData.DoorStates); binaryWriter.Write(sessionSaveGameData.AirlockSafeties); if (Bindings.IsDebugMode) { BepinPlugin.Log.LogInfo((object)$"Wrote {fileStream.Length} Bytes"); } binaryWriter.Write(sessionSaveGameData.Seed); binaryWriter.Write(sessionSaveGameData.JumpCounter); binaryWriter.Write(sessionSaveGameData.InterdictionCounter); binaryWriter.Write(sessionSaveGameData.CurrentInterdictionChance); if (Bindings.IsDebugMode) { BepinPlugin.Log.LogInfo((object)$"Wrote {fileStream.Length} Bytes"); } binaryWriter.Write(sessionSaveGameData.CompletedSectors); binaryWriter.Write(sessionSaveGameData.SessionStats); BepinPlugin.Log.LogInfo((object)$"Finalized write at {fileStream.Length} Bytes"); } File.Delete(text); File.Move(text2, text); return true; } catch (Exception ex) { Messaging.Notification("<color=red>Failed to Write Save!</color>", false); BepinPlugin.Log.LogError((object)ex); File.Delete(text2); } return false; } public static bool WriteIronManSave(string FileName) { string lastSaveName = LastSaveName; if (WriteSave(FileName) && FileName != lastSaveName) { BepinPlugin.Log.LogInfo((object)("Iron Man Save succesfully wrote " + FileName + ", deleting old file " + lastSaveName)); DeleteSaveFile(lastSaveName); return true; } return false; } internal static string IronManSaveDefaultNameFromID(int SaveID) { return "IronManSave_" + SaveID.ToString("D2"); } public static string GetNextIronManSaveName() { int num = 1; while (File.Exists(Path.Combine(SaveLocation, "IronManSave_" + num.ToString("D2") + ".voidsave"))) { num++; } return IronManSaveDefaultNameFromID(num); } } } namespace VoidSaving.VanillaFixes { [HarmonyPatch(typeof(AstralMapController), "FetchCurrentSystemProgression")] internal class AstralMapFetchProgressionFix { private static bool Prefix(AstralMapController __instance) { //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0128: Unknown result type (might be due to invalid IL or missing references) //IL_014c: Unknown result type (might be due to invalid IL or missing references) //IL_0151: Unknown result type (might be due to invalid IL or missing references) //IL_0153: Unknown result type (might be due to invalid IL or missing references) //IL_0156: Invalid comparison between Unknown and I4 //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Invalid comparison between Unknown and I4 //IL_0158: Unknown result type (might be due to invalid IL or missing references) //IL_015b: Invalid comparison between Unknown and I4 //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Invalid comparison between Unknown and I4 //IL_015d: Unknown result type (might be due to invalid IL or missing references) //IL_0160: Invalid comparison between Unknown and I4 //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Invalid comparison between Unknown and I4 //IL_016f: Unknown result type (might be due to invalid IL or missing references) //IL_01cf: Unknown result type (might be due to invalid IL or missing references) Quest activeQuest = GameSessionManager.ActiveSession.ActiveQuest; EndlessQuest val = (EndlessQuest)(object)((activeQuest is EndlessQuest) ? activeQuest : null); if (val == null) { return false; } __instance._newSystem = (Object)(object)val.Context.CurrentSection.SolarSystem != (Object)(object)val.Context.NextSection.SolarSystem; List<UIObjective> list = new List<UIObjective>(); List<GameSessionSection> completedSections = val.Context.CompletedSections; int count = completedSections.Count; for (int i = Math.Max(count - 6, 0); i < count; i++) { GameSessionSection val2 = completedSections[i]; if (!((Object)(object)val2.SolarSystem == (Object)(object)val.Context.CurrentSection.SolarSystem)) { continue; } foreach (GameSessionSector allAvailableSector in val2.AllAvailableSectors) { ObjectiveState objectiveState = allAvailableSector.ObjectiveState; if ((int)objectiveState == 3 || (int)objectiveState == 4 || (int)objectiveState == 2) { list.Add(__instance.CreateProgressionHistoryItem(val2, allAvailableSector)); } } } foreach (GameSessionSector allAvailableSector2 in val.Context.CurrentSection.AllAvailableSectors) { ObjectiveState objectiveState2 = allAvailableSector2.ObjectiveState; if ((int)objectiveState2 == 3 || (int)objectiveState2 == 4 || (int)objectiveState2 == 2) { list.Add(__instance.CreateProgressionHistoryItem(val.Context.CurrentSection, allAvailableSector2)); } } if (GameSessionManager.ActiveSector == (GameSessionSector)null) { if (__instance._voidJumpSystem.DestinationSector != (GameSessionSector)null) { list.Add(__instance.CreateProgressionHistoryItem(val.Context.CurrentSection, __instance._voidJumpSystem.DestinationSector)); } else { list.Add(null); } } if (list.Count > 0) { __instance._currentProgressionHistory = list; } return false; } } [HarmonyPatch(typeof(EndlessQuestManager), "CompleteSector")] internal class CompletedSectorSetStatusFix { private static void PatchMethod(EndlessQuestManager instance, byte status) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Expected I4, but got Unknown //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) GameSessionSector val = instance.endlessQuest.Context.CompletedSectors.Last(); if (val.SectorObjective != null) { SectorCompletionStatus val2 = (SectorCompletionStatus)status; SectorCompletionStatus val3 = val2; switch (val3 - 1) { case 3: val.SectorObjective.Objective.State = (ObjectiveState)3; break; case 1: val.SectorObjective.Objective.State = (ObjectiveState)4; break; case 0: val.SectorObjective.Objective.State = (ObjectiveState)5; break; case 2: break; } } } private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Expected O, but got Unknown //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Expected O, but got Unknown //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004d: 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_0078: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Expected O, but got Unknown CodeInstruction[] array = (CodeInstruction[])(object)new CodeInstruction[2] { new CodeInstruction(OpCodes.Ldarg_0, (object)null), new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(EndlessQuestManager), "RefreshSectorVisibility", (Type[])null, (Type[])null)) }; CodeInstruction[] array2 = (CodeInstruction[])(object)new CodeInstruction[3] { new CodeInstruction(OpCodes.Ldarg_0, (object)null), new CodeInstruction(OpCodes.Ldarg_2, (object)null), new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(CompletedSectorSetStatusFix), "PatchMethod", (Type[])null, (Type[])null)) }; return HarmonyHelpers.PatchBySequence(instructions, (IEnumerable<CodeInstruction>)array, (IEnumerable<CodeInstruction>)array2, (PatchMode)0, (CheckMode)1, false); } } [HarmonyPatch(typeof(GameSession), "AsJObject")] internal class GameSessionAntiSerializePatches { internal static bool Serializing; private static void Prefix() { Serializing = true; } private static void Postfix() { Serializing = false; } [HarmonyPatch(/*Could not decode attribute arguments.*/)] [HarmonyPrefix] private static bool InterdictionStopSerialize() { return !Serializing; } } [HarmonyPatch(typeof(QuestManager), "SetQuestObjectiveState")] internal class ObjectiveStateStopStartPatch { private static bool Prefix(Objective objective, ObjectiveState state) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Invalid comparison between Unknown and I4 ObjectiveState state2 = objective.State; if (state2 - 3 <= 1) { return false; } return true; } } [HarmonyPatch(typeof(ShipLoadout), "InitializeShip")] internal class RegisterShelvesPatch { private static void PatchMethod(AbstractPlayerControlledShip ship) { List<CellModule> list = ship.CoreSystems.ToList(); CellModule[] componentsInChildren = ((Component)ship).GetComponentsInChildren<CellModule>(); foreach (CellModule val in componentsInChildren) { if (val is CarryablesShelf && !ship.CoreSystems.Contains(val)) { if (Bindings.IsDebugMode) { BepinPlugin.Log.LogInfo((object)("Adding " + ((AbstractCloneStarObject)val).DisplayName + " with to core systems")); } list.Add(val); } } ship.CoreSystems = list.ToArray(); } private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Expected O, but got Unknown //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Expected O, but got Unknown //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Expected O, but got Unknown CodeInstruction[] array = (CodeInstruction[])(object)new CodeInstruction[1] { new CodeInstruction(OpCodes.Stloc_2, (object)null) }; CodeInstruction[] array2 = (CodeInstruction[])(object)new CodeInstruction[2] { new CodeInstruction(OpCodes.Ldloc_2, (object)null), new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(RegisterShelvesPatch), "PatchMethod", (Type[])null, (Type[])null)) }; return HarmonyHelpers.PatchBySequence(instructions, (IEnumerable<CodeInstruction>)array, (IEnumerable<CodeInstruction>)array2, (PatchMode)1, (CheckMode)2, false); } } [HarmonyPatch(typeof(GameSessionSectorManager), "OnRoomPropertiesUpdate")] internal class SessionManagerPropertiesFix { internal static bool BlockLoadingExecution; private static bool Prefix() { if (BlockLoadingExecution) { BlockLoadingExecution = false; return false; } return true; } } [HarmonyPatch(typeof(ModuleUpgraderEffects), "StartBeingCarried")] internal class UpgraderShelfLoadPatch { private static bool Prefix() { if (SaveHandler.LoadSavedData) { return false; } return true; } } [HarmonyPatch(typeof(CloudPlayerProfileDataSync), "ClaimPendingXp")] internal class XPProfileLoadPatch { private static void Postfix(CloudPlayerProfileDataSync __instance) { __instance.UploadProfile(); } } } namespace VoidSaving.ReadWriteTools { internal class Helpers { public static GUIDUnion[] RelicGUIDsFromShip(AbstractPlayerControlledShip playerShip) { //IL_0047: 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: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) RelicSocketController[] componentsInChildren = ((Component)playerShip).GetComponentsInChildren<RelicSocketController>(); int num = componentsInChildren.Length; GUIDUnion[] array = (GUIDUnion[])(object)new GUIDUnion[num]; for (int i = 0; i < num; i++) { array[i] = (GUIDUnion)(Object.op_Implicit((Object)(object)((CarryablesSocket)componentsInChildren[i].RelicSocket).Payload) ? ((AbstractCloneStarObject)((CarryablesSocket)componentsInChildren[i].RelicSocket).Payload).assetGuid : default(GUIDUnion)); } return array; } public static GUIDUnion[] UnlockedBPGUIDsFromShip(AbstractPlayerControlledShip playerShip) { return ((Component)playerShip).GetComponentInChildren<FabricatorModule>().SessionBasedUnlockPool.ToArray(); } public static void AddBlueprintsToFabricator(AbstractPlayerControlledShip playerShip, GUIDUnion[] BPGUIDs) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) foreach (GUIDUnion val in BPGUIDs) { ((Component)playerShip).GetComponentInChildren<FabricatorModule>().TryAddItemToSharedUnlockPool(val, false); } } public static void AddRelicsToShip(AbstractPlayerControlledShip playerShip, GUIDUnion[] relicIDs) { //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001b: 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_003d: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) RelicSocketController[] componentsInChildren = ((Component)playerShip).GetComponentsInChildren<RelicSocketController>(); int num = componentsInChildren.Length; for (int i = 0; i < num; i++) { if (!(relicIDs[i] == GUIDUnion.Empty())) { try { OrbitObject obj = SpawnUtils.SpawnCarryable(relicIDs[i], ((Component)componentsInChildren[i]).transform.position, ((Component)componentsInChildren[i]).transform.rotation); CarryableObject val = (CarryableObject)(object)((obj is CarryableObject) ? obj : null); ((CarryablesSocket)componentsInChildren[i].RelicSocket).TryInsertCarryable(val); } catch (Exception ex) { BepinPlugin.Log.LogError((object)($"Failed to spawn relic {relicIDs[i]} in controller!\n" + ex)); } } } } public static BoosterStatus[] GetBoosterStates(AbstractPlayerControlledShip PlayerShip) { //IL_0032: Unknown result type (might be due to invalid IL or missing references) ThrusterBoosterController component = ((Component)PlayerShip).GetComponent<ThrusterBoosterController>(); int num = component.ThrusterBoosters.Count(); BoosterStatus[] array = new BoosterStatus[num]; for (int i = 0; i < num; i++) { ThrusterBooster val = component.ThrusterBoosters[i]; array[i] = new BoosterStatus(val.State, val.DischargeTimer, val.ChargeTimer, val.CooldownTimer); } return array; } public static void LoadBoosterStates(AbstractPlayerControlledShip PlayerShip, BoosterStatus[] boosterStatuses) { //IL_0022: Unknown result type (might be due to invalid IL or missing references) ThrusterBoosterController component = ((Component)PlayerShip).GetComponent<ThrusterBoosterController>(); for (int i = 0; i < boosterStatuses.Length; i++) { ThrusterBooster val = component.ThrusterBoosters[i]; val.ChangeState(boosterStatuses[i].BoosterState); val.ChargeTimer = boosterStatuses[i].ChargeTimer; val.CooldownTimer = boosterStatuses[i].CooldownTimer; val.DischargeTimer = boosterStatuses[i].DischargeTimer; } } public static float[] GetShipShieldHealths(AbstractPlayerControlledShip PlayerShip) { ShieldSystem component = ((Component)PlayerShip).GetComponent<ShieldSystem>(); float[] array = new float[4]; for (int i = 0; i < 4; i++) { array[i] = ((OrbitObject)component._shields[i]).hitPoints; } return array; } public static EnhancementData[] GetEnhancements(AbstractPlayerControlledShip PlayerShip) { //IL_0134: Unknown result type (might be due to invalid IL or missing references) BuildSocketController component = ((Component)PlayerShip).GetComponent<BuildSocketController>(); Dictionary<CellModule, int> dictionary = new Dictionary<CellModule, int>(); foreach (BuildSocket socket in component.Sockets) { if ((Object)(object)socket.InstalledModule != (Object)null) { dictionary.Add(socket.InstalledModule, socket.Index); } } Enhancement[] componentsInChildren = ((Component)PlayerShip).GetComponentsInChildren<Enhancement>(); EnhancementData[] array = new EnhancementData[componentsInChildren.Length]; for (int i = 0; i < componentsInChildren.Length; i++) { CellModule componentInParent = ((Component)componentsInChildren[i]).GetComponentInParent<CellModule>(); if ((Object)(object)componentInParent != (Object)null && dictionary.TryGetValue(componentInParent, out var value)) { array[i] = new EnhancementData(componentsInChildren[i], value); } else { array[i] = new EnhancementData(componentsInChildren[i], -1); } if (Bindings.IsDebugMode) { EnhancementData enhancementData = array[i]; Enhancement val = componentsInChildren[i]; BepinPlugin.Log.LogInfo((object)$"Collected Enhancement: {val.contextInfo.HeaderText} {((Object)val).name} of moduleIndex {enhancementData.ParentModuleID} with data: {enhancementData.state} Grade: {enhancementData.LastGrade} Duration: {enhancementData.LastDurationMult}x"); } } return array; } public static void LoadEnhancements(AbstractPlayerControlledShip PlayerShip, EnhancementData[] datas) { //IL_01cf: Unknown result type (might be due to invalid IL or missing references) //IL_0209: Unknown result type (might be due to invalid IL or missing references) BuildSocketController component = ((Component)PlayerShip).GetComponent<BuildSocketController>(); Dictionary<CellModule, int> dictionary = new Dictionary<CellModule, int>(); foreach (BuildSocket socket in component.Sockets) { if ((Object)(object)socket.InstalledModule != (Object)null) { dictionary.Add(socket.InstalledModule, socket.Index); } } Dictionary<Enhancement, int> dictionary2 = new Dictionary<Enhancement, int>(); Enhancement[] componentsInChildren = ((Component)PlayerShip).GetComponentsInChildren<Enhancement>(); for (int i = 0; i < componentsInChildren.Length; i++) { CellModule componentInParent = ((Component)componentsInChildren[i]).GetComponentInParent<CellModule>(); if ((Object)(object)componentInParent != (Object)null && dictionary.TryGetValue(componentInParent, out var value)) { dictionary2.Add(componentsInChildren[i], value); } else { dictionary2.Add(componentsInChildren[i], -1); } } for (int j = 0; j < datas.Length; j++) { EnhancementData enhancementData = datas[j]; Enhancement val = null; foreach (KeyValuePair<Enhancement, int> item in dictionary2) { if (enhancementData.ParentModuleID == item.Value) { val = item.Key; break; } } if ((Object)(object)val == (Object)null) { BepinPlugin.Log.LogWarning((object)$"Failed to find enhancement for data of module index {enhancementData.ParentModuleID}"); continue; } dictionary2.Remove(val); if (Bindings.IsDebugMode) { BepinPlugin.Log.LogInfo((object)$"Loading Enhancement: {val.contextInfo.HeaderText} {((Object)val).name} of moduleIndex {enhancementData.ParentModuleID} with data: {enhancementData.state} Grade: {enhancementData.LastGrade} Duration: {enhancementData.LastDurationMult}x"); } try { val.SetState(enhancementData.state, enhancementData.LastGrade, enhancementData.LastDurationMult, false); val._activationStartTime = PhotonNetwork.ServerTimestamp + enhancementData.ActivationTimeStart; val._activationEndTime = PhotonNetwork.ServerTimestamp + enhancementData.ActivationTimeEnd; val._cooldownStartTime = PhotonNetwork.ServerTimestamp + enhancementData.CooldownTimeStart; val._cooldownEndTime = PhotonNetwork.ServerTimestamp + enhancementData.CooldownTimeEnd; val._failureStartTime = PhotonNetwork.ServerTimestamp + enhancementData.FailureTimeStart; val._failureEndTime = PhotonNetwork.ServerTimestamp + enhancementData.FailureTimeEnd; } catch (Exception ex) { BepinPlugin.Log.LogError((object)ex); } } } public static CircuitBreakerData GetBreakerData(ProtectedPowerSystem powerSystem) { CircuitBreakerData result = default(CircuitBreakerData); result.breakers = powerSystem.Breakers.Select((PowerBreaker x) => ((ChangeResponsive<bool>)(object)x.IsOn).Value).ToArray(); result.currentTemperature = powerSystem.currentTemperature; result.NextBreakTemperature = powerSystem.NextBreakTemperature; return result; } public static void LoadBreakers(ProtectedPowerSystem powerSystem, CircuitBreakerData data) { for (int i = 0; i < data.breakers.Length; i++) { ((ChangeResponsive<bool>)(object)powerSystem.Breakers[i].IsOn).ForceChange(data.breakers[i]); } powerSystem.NextBreakTemperature = data.NextBreakTemperature; powerSystem.currentTemperature = data.currentTemperature; } public static void LoadVoidDriveModule(AbstractPlayerControlledShip playerShip, VoidDriveModuleData data) { //IL_0022: Unknown result type (might be due to invalid IL or missing references) VoidDriveModule componentInChildren = ((Component)playerShip).GetComponentInChildren<VoidDriveModule>(); for (int i = 0; i < data.engineChargedStates.Length; i++) { componentInChildren.SetEngineCharging(i, data.engineChargedStates[i], new PhotonMessageInfo(PhotonNetwork.LocalPlayer, PhotonNetwork.ServerTimestamp, (PhotonView)null)); } componentInChildren.JumpCharge = data.JumpCharge; } public static Tuple<AtmosphereValues[], AtmosphereValues[]> GetAtmosphereValues(AbstractPlayerControlledShip playerShip) { Atmosphere componentInChildren = ((Component)playerShip).GetComponentInChildren<Atmosphere>(); return new Tuple<AtmosphereValues[], AtmosphereValues[]>(componentInChildren.Atmospheres.elements.ToArray(), componentInChildren._buffer.ToArray()); } public static void LoadAtmosphereValues(AbstractPlayerControlledShip playerShip, AtmosphereValues[] data, AtmosphereValues[] bufferData) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) Atmosphere componentInChildren = ((Component)playerShip).GetComponentInChildren<Atmosphere>(); for (int i = 0; i < data.Count(); i++) { componentInChildren.RoomAtmospheres.SetElementAt(i, data[i]); } componentInChildren._buffer = bufferData.ToList(); } public static bool[] GetDoorStates(AbstractPlayerControlledShip playerShip) { return (from door in ((Component)playerShip).GetComponentsInChildren<AbstractDoor>() select door.isOpen).ToArray(); } public static void LoadDoorStates(AbstractPlayerControlledShip playerShip, bool[] states) { AbstractDoor[] componentsInChildren = ((Component)playerShip).GetComponentsInChildren<AbstractDoor>(); for (int i = 0; i < states.Length; i++) { componentsInChildren[i].IsOpen = states[i]; } } public static bool[] GetAirlockSafeties(AbstractPlayerControlledShip playerShip) { Airlock[] componentsInChildren = ((Component)playerShip).GetComponentsInChildren<Airlock>(); bool[] array = new bool[componentsInChildren.Length]; for (int i = 0; i < componentsInChildren.Length; i++) { array[i] = componentsInChildren[i].IsSafetyEnabled; } return array; } public static void LoadAirlockSafeties(AbstractPlayerControlledShip playerShip, bool[] states) { Airlock[] componentsInChildren = ((Component)playerShip).GetComponentsInChildren<Airlock>(); for (int i = 0; i < states.Length; i++) { componentsInChildren[i].IsSafetyEnabled = states[i]; } } public static byte[] GetBreachStates(HullDamageController damageController) { return damageController.Breaches.Select((HullBreach breach) => (byte)(int)breach.State.condition).ToArray(); } public static void LoadBreachStates(HullDamageController damageController, byte[] breachConditions) { int num = breachConditions.Length; for (int i = 0; i < num; i++) { damageController.breaches[i].SetCondition((BreachCondition)breachConditions[i]); } } public static sbyte[] GetDefectStates(PlayerShipDefectDamageController damageController) { List<sbyte> list = new List<sbyte>(); foreach (DefectSystem defectSystem in ((DefectDamageController)damageController)._defectSystems) { foreach (Defect availableDefect in defectSystem.AvailableDefects) { list.Add((sbyte)availableDefect.activeStageIndex); } } return list.ToArray(); } public static void LoadDefectStates(PlayerShipDefectDamageController damageController, sbyte[] states) { int num = states.Length; int num2 = 0; foreach (DefectSystem defectSystem in ((DefectDamageController)damageController)._defectSystems) { foreach (Defect availableDefect in defectSystem.AvailableDefects) { availableDefect.SetDefectStage((int)states[num2++]); if (num2 == num) { return; } } } } public static void LoadBuildSocketPayloads(BuildSocketController BSC, ShipSocketData[] datas) { //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) int i = 0; int count = BSC.Sockets.Count; for (int j = 0; j < datas.Length; j++) { ShipSocketData shipSocketData = datas[j]; for (; i < count; i++) { if (shipSocketData.SocketID == i) { BuildSocket val = BSC.Sockets[i]; Dictionary<byte, object> dictionary = new Dictionary<byte, object> { { 1, ((MonoBehaviourPun)val).photonView.ViewID } }; if (!Ext.IsNullOrEmpty(shipSocketData.JData)) { dictionary.Add(0, shipSocketData.JData); } CarryableObject component = ((Component)ObjectFactory.InstantiateSpaceObjectByGUID(shipSocketData.ObjectGUID, ((AbstractCloneStarObject)val).WorldPosition, ((AbstractCloneStarObject)val).WorldRotation, dictionary)).GetComponent<CarryableObject>(); ((CarryablesSocket)val).TryInsertCarryable(component); i++; break; } } } } public static ShipSocketData[] GetBuildSocketPayloads(BuildSocketController BSC) { List<ShipSocketData> list = new List<ShipSocketData>(); foreach (BuildSocket socket in BSC.Sockets) { if ((Object)(object)((CarryablesSocket)socket).Payload != (Object)null && (Object)(object)socket.InstalledModule == (Object)null) { list.Add(new ShipSocketData(socket)); } } return list.ToArray(); } public static FullSectorData[] GetSectorDatasFromList(List<GameSessionSector> sectors) { int count = sectors.Count; FullSectorData[] array = new FullSectorData[count]; for (int i = 0; i < count; i++) { array[i] = new FullSectorData(sectors[i]); } return array; } public static FullSectorData[] GetCompletedSectorDatas(EndlessQuest quest) { if (Bindings.IsDebugMode) { BepinPlugin.Log.LogInfo((object)$"Collecting data of {quest.context.CompletedSectors.Count()} sectors"); } FullSectorData[] sectorDatasFromList = GetSectorDatasFromList(quest.context.CompletedSectors); if (Bindings.IsDebugMode) { BepinPlugin.Log.LogInfo((object)$"Collected data of {sectorDatasFromList.Length} sectors"); } return sectorDatasFromList; } } public static class RandomSerializer { private static FieldInfo[] randomFields; public static FieldInfo[] RandomFields { get { if (randomFields == null) { randomFields = new FieldInfo[3]; Type typeFromHandle = typeof(Random); randomFields[0] = typeFromHandle.GetField("_seedArray", BindingFlags.Instance | BindingFlags.NonPublic); randomFields[1] = typeFromHandle.GetField("_inext", BindingFlags.Instance | BindingFlags.NonPublic); randomFields[2] = typeFromHandle.GetField("_inextp", BindingFlags.Instance | BindingFlags.NonPublic); } return randomFields; } } public static int[] GetSeedArray(this Random rand) { int[] array = new int[58]; ((int[])RandomFields[0].GetValue(rand)).CopyTo(array, 0); array[56] = (int)RandomFields[1].GetValue(rand); array[57] = (int)RandomFields[2].GetValue(rand); return array; } public static void SetSeedArray(this Random rand, int[] seedArray) { if (seedArray.Length == 58) { Array.Copy(seedArray, (int[])RandomFields[0].GetValue(rand), 56); RandomFields[1].SetValue(rand, seedArray[56]); RandomFields[2].SetValue(rand, seedArray[57]); } } } public static class ReadWriteExtensions { public static void Write(this BinaryWriter Writer, GUIDUnion union) { int[] array = ((GUIDUnion)(ref union)).AsIntArray(); foreach (int value in array) { Writer.Write(value); } } public static GUIDUnion ReadGUIDUnion(this BinaryReader Reader) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) int[] array = new int[4]; for (int i = 0; i < 4; i++) { array[i] = Reader.ReadInt32(); } return new GUIDUnion(array); } public static void Write(this BinaryWriter Writer, GUIDUnion[] unions) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) Writer.Write(unions.Length); foreach (GUIDUnion union in unions) { Writer.Write(union); } } public static GUIDUnion[] ReadGUIDUnionArray(this BinaryReader Reader) { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) int num = Reader.ReadInt32(); GUIDUnion[] array = (GUIDUnion[])(object)new GUIDUnion[num]; for (int i = 0; i < num; i++) { array[i] = Reader.ReadGUIDUnion(); } return array; } public static void WriteByteArray(this BinaryWriter Writer, byte[] bytes) { Writer.Write(bytes.Length); Writer.Write(bytes); } public static byte[] ReadByteArray(this BinaryReader Reader) { return Reader.ReadBytes(Reader.ReadInt32()); } public static void WriteSByteArray(this BinaryWriter Writer, sbyte[] bytes) { int num = bytes.Length; Writer.Write(bytes.Length); for (int i = 0; i < num; i++) { Writer.Write(bytes[i]); } } public static sbyte[] ReadSByteArray(this BinaryReader Reader) { int num = Reader.ReadInt32(); sbyte[] array = new sbyte[num]; for (int i = 0; i < num; i++) { array[i] = Reader.ReadSByte(); } return array; } public static void Write(this BinaryWriter Writer, int[] ints) { Writer.Write(ints.Length); foreach (int value in ints) { Writer.Write(value); } } public static int[] ReadInt32Array(this BinaryReader Reader) { int num = Reader.ReadInt32(); int[] array = new int[num]; for (int i = 0; i < num; i++) { array[i] = Reader.ReadInt32(); } return array; } public static void Write(this BinaryWriter Writer, bool[] bools) { Writer.Write(bools.Length); foreach (bool value in bools) { Writer.Write(value); } } public static bool[] ReadBooleanArray(this BinaryReader Reader) { int num = Reader.ReadInt32(); bool[] array = new bool[num]; for (int i = 0; i < num; i++) { array[i] = Reader.ReadBoolean(); } return array; } public static void Write(this BinaryWriter Writer, float[] floats) { Writer.Write(floats.Length); foreach (float value in floats) { Writer.Write(value); } } public static float[] ReadSingleArray(this BinaryReader Reader) { int num = Reader.ReadInt32(); float[] array = new float[num]; for (int i = 0; i < num; i++) { array[i] = Reader.ReadSingle(); } return array; } public static void Write(this BinaryWriter Writer, List<float> floats) { Writer.Write(floats.Count); foreach (float @float in floats) { Writer.Write(@float); } } public static List<float> ReadSingleList(this BinaryReader Reader) { int num = Reader.ReadInt32(); List<float> list = new List<float>(num); for (int i = 0; i < num; i++) { list.Add(Reader.ReadSingle()); } return list; } public static void Write(this BinaryWriter Writer, JObject jobject) { Writer.Write(((JToken)jobject).ToString((Formatting)0, Array.Empty<JsonConverter>())); } public static JObject ReadJObject(this BinaryReader Reader) { return JObject.Parse(Reader.ReadString()); } public static void Write(this BinaryWriter Writer, Random random) { Writer.Write(random.GetSeedArray()); } public static Random ReadRandom(this BinaryReader reader) { Random random = new Random(); random.SetSeedArray(reader.ReadInt32Array()); return random; } public static void Write(this BinaryWriter Writer, BoosterStatus[] boosterStatuses) { //IL_001d: Unknown result type (might be due to invalid IL or missing references) Writer.Write(boosterStatuses.Length); for (int i = 0; i < boosterStatuses.Length; i++) { BoosterStatus boosterStatus = boosterStatuses[i]; Writer.Write((byte)boosterStatus.BoosterState); Writer.Write(boosterStatus.CooldownTimer); Writer.Write(boosterStatus.ChargeTimer); Writer.Write(boosterStatus.DischargeTimer); } } public static BoosterStatus[] ReadBoosterStatuses(this BinaryReader reader) { //IL_0026: Unknown result type (might be due to invalid IL or missing references) int num = reader.ReadInt32(); BoosterStatus[] array = new BoosterStatus[num]; for (int i = 0; i < num; i++) { array[i] = new BoosterStatus { BoosterState = (ThrusterBoosterState)reader.ReadByte(), CooldownTimer = reader.ReadSingle(), ChargeTimer = reader.ReadSingle(), DischargeTimer = reader.ReadSingle() }; } return array; } public static void Write(this BinaryWriter Writer, WeaponBullets[] WeaponBullets) { Writer.Write(WeaponBullets.Length); for (int i = 0; i < WeaponBullets.Length; i++) { WeaponBullets weaponBullets = WeaponBullets[i]; Writer.Write(weaponBullets.AmmoLoaded); Writer.Write(weaponBullets.AmmoReservoir); } } public static WeaponBullets[] ReadWeaponBullets(this BinaryReader reader) { int num = reader.ReadInt32(); WeaponBullets[] array = new WeaponBullets[num]; for (int i = 0; i < num; i++) { array[i] = new WeaponBullets { AmmoLoaded = reader.ReadSingle(), AmmoReservoir = reader.ReadSingle() }; } return array; } public static void Write(this BinaryWriter Writer, EnhancementData[] Enhancements) { //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Expected I4, but got Unknown Writer.Write(Enhancements.Length); for (int i = 0; i < Enhancements.Length; i++) { EnhancementData enhancementData = Enhancements[i]; Writer.Write((byte)(int)enhancementData.state); Writer.Write(enhancementData.ActivationTimeStart); Writer.Write(enhancementData.ActivationTimeEnd); Writer.Write(enhancementData.CooldownTimeStart); Writer.Write(enhancementData.CooldownTimeEnd); Writer.Write(enhancementData.FailureTimeStart); Writer.Write(enhancementData.FailureTimeEnd); Writer.Write(enhancementData.LastGrade); Writer.Write(enhancementData.LastDurationMult); Writer.Write(enhancementData.ParentModuleID); } } public static EnhancementData[] ReadEnhancements(this BinaryReader reader) { //IL_0029: Unknown result type (might be due to invalid IL or missing references) int num = reader.ReadInt32(); EnhancementData[] array = new EnhancementData[num]; for (int i = 0; i < num; i++) { array[i] = new EnhancementData { state = (EnhancementState)reader.ReadByte(), ActivationTimeStart = reader.ReadInt32(), ActivationTimeEnd = reader.ReadInt32(), CooldownTimeStart = reader.ReadInt32(), CooldownTimeEnd = reader.ReadInt32(), FailureTimeStart = reader.ReadInt32(), FailureTimeEnd = reader.ReadInt32(), LastGrade = reader.ReadSingle(), LastDurationMult = reader.ReadSingle(), ParentModuleID = reader.ReadInt16() }; } return array; } public static void Write(this BinaryWriter Writer, CircuitBreakerData Breakers) { Writer.Write(Breakers.breakers); Writer.Write(Breakers.NextBreakTemperature); Writer.Write(Breakers.currentTemperature); } public static CircuitBreakerData ReadBreakers(this BinaryReader reader) { CircuitBreakerData result = default(CircuitBreakerData); result.breakers = reader.ReadBooleanArray(); result.NextBreakTemperature = reader.ReadSingle(); result.currentTemperature = reader.ReadSingle(); return result; } public static void Write(this BinaryWriter Writer, GameSessionStatistics Stats) { Writer.Write(Stats.TotalEnemiesKilled); Writer.Write(Stats.PlayerDeaths); Writer.Write(Stats.TotalDamageInflicted); Writer.Write(Stats.TotalShipDamageTaken); Writer.Write(Stats.TotalAlloysCollected); Writer.Write(Stats.TotalBiomassCollected); Writer.Write(DateTime.Now.Subtract(Stats.QuestStartTime).TotalHours); } public static GameSessionStatistics ReadSessionStats(this BinaryReader reader) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown GameSessionStatistics val = new GameSessionStatistics(); val.TotalEnemiesKilled = reader.ReadInt32(); val.PlayerDeaths = reader.ReadInt32(); val.TotalDamageInflicted = reader.ReadInt64(); val.TotalShipDamageTaken = reader.ReadInt64(); val.TotalAlloysCollected = reader.ReadInt32(); val.TotalBiomassCollected = reader.ReadInt32(); TimeSpan value = TimeSpan.FromHours(reader.ReadDouble()); val.QuestStartTime = DateTime.Now.Subtract(value); return val; } public static void Write(this BinaryWriter Writer, VoidDriveModuleData VoidDriveData) { Writer.Write(VoidDriveData.engineChargedStates); Writer.Write(VoidDriveData.JumpCharge); } public static VoidDriveModuleData ReadVoidDriveData(this BinaryReader reader) { VoidDriveModuleData result = default(VoidDriveModuleData); result.engineChargedStates = reader.ReadBooleanArray(); result.JumpCharge = reader.ReadSingle(); return result; } public static void Write(this BinaryWriter Writer, AtmosphereValues[] Values) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) Writer.Write(Values.Length); foreach (AtmosphereValues val in Values) { Writer.Write(val.Pressure); Writer.Write(val.Oxygen); Writer.Write(val.Temperature); } } public static AtmosphereValues[] ReadAtmosphereValues(this BinaryReader reader) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) int num = reader.ReadInt32(); AtmosphereValues[] array = (AtmosphereValues[])(object)new AtmosphereValues[num]; for (int i = 0; i < num; i++) { AtmosphereValues val = default(AtmosphereValues); val.Pressure = reader.ReadSingle(); val.Oxygen = reader.ReadSingle(); val.Temperature = reader.ReadSingle(); val.AtmosphericForce = default(AtmosphericForceProbe); array[i] = val; } return array; } public static void Write(this BinaryWriter Writer, ShipSocketData[] IndexedSocketPayloads) { //IL_0029: Unknown result type (might be due to invalid IL or missing references) int num = IndexedSocketPayloads.Length; Writer.Write(num); for (int i = 0; i < num; i++) { ShipSocketData shipSocketData = IndexedSocketPayloads[i]; Writer.Write(shipSocketData.SocketID); Writer.Write(shipSocketData.ObjectGUID); Writer.Write(shipSocketData.JData); } } public static ShipSocketData[] ReadIndexedSocketPayloads(this BinaryReader reader) { //IL_002c: 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) int num = reader.ReadInt32(); ShipSocketData[] array = new ShipSocketData[num]; for (int i = 0; i < num; i++) { ShipSocketData shipSocketData = default(ShipSocketData); shipSocketData.SocketID = reader.ReadInt32(); shipSocketData.ObjectGUID = reader.ReadGUIDUnion(); shipSocketData.JData = reader.ReadString(); ShipSocketData shipSocketData2 = shipSocketData; array[i] = shipSocketData2; } return array; } public static void Write(this BinaryWriter Writer, List<SimpleSectorData> Values) { //IL_0030: Unknown result type (might be due to invalid IL or missing references) int count = Values.Count; Writer.Write(count); for (int i = 0; i < count; i++) { Writer.Write(Values[i].SolarSystemIndex); Writer.Write(Values[i].SectorContainerGUID); } } public static List<SimpleSectorData> ReadSimpleSectorDatas(this BinaryReader reader) { //IL_001c: Unknown result type (might be due to invalid IL or missing references) int num = reader.ReadInt32(); List<SimpleSectorData> list = new List<SimpleSectorData>(num); for (int i = 0; i < num; i++) { list.Add(new SimpleSectorData(reader.ReadInt32(), reader.ReadGUIDUnion())); } return list; } public static void Write(this BinaryWriter Writer, FullSectorData[] sectorDatas) { //IL_0043: Unknown result type (might be due to invalid IL or missing references) Writer.Write(sectorDatas.Length); if (Bindings.IsDebugMode) { BepinPlugin.Log.LogInfo((object)$"Writing {sectorDatas.Length} sector datas"); } for (int i = 0; i < sectorDatas.Length; i++) { FullSectorData fullSectorData = sectorDatas[i]; Writer.Write((byte)fullSectorData.State); Writer.Write(fullSectorData.SectorID); } } public static FullSectorData[] ReadFullSectorDatas(this BinaryReader reader) { //IL_004a: Unknown result type (might be due to invalid IL or missing references) int num = reader.ReadInt32(); FullSectorData[] array = new FullSectorData[num]; if (Bindings.IsDebugMode) { BepinPlugin.Log.LogInfo((object)$"Reading {num} sector datas"); } for (int i = 0; i < num; i++) { array[i] = new FullSectorData { State = (ObjectiveState)reader.ReadByte(), SectorID = reader.ReadInt32() }; } return array; } public static void Write(this BinaryWriter Writer, SectionData sectionData, bool IncludeInterdictionData = false) { Writer.Write(sectionData.ObjectiveSectors); if (IncludeInterdictionData) { Writer.Write(new FullSectorData[1] { sectionData.InterdictionSector }); } Writer.Write(sectionData.SolarSystemIndex); } public static SectionData ReadSectionData(this BinaryReader Reader, bool IncludeInterdictionData = false) { SectionData result = default(SectionData); result.ObjectiveSectors = Reader.ReadFullSectorDatas(); result.InterdictionSector = (IncludeInterdictionData ? Reader.ReadFullSectorDatas()[0] : default(FullSectorData)); result.SolarSystemIndex = Reader.ReadInt32(); return result; } public static void Write(this BinaryWriter Writer, SectionData[] sections) { int value = sections.Length; Writer.Write(value); for (int i = 0; i < sections.Length; i++) { Writer.Write(sections[i]); } } public static SectionData[] ReadSectionDatas(this BinaryReader Reader) { int num = Reader.ReadInt32(); SectionData[] array = new SectionData[num]; for (int i = 0; i < num; i++) { array[i] = Reader.ReadSectionData(); } return array; } } } namespace VoidSaving.Patches { [HarmonyPatch(typeof(AstralMapController), "CheckForGameStart")] internal class AstralMapStartCheckPatch { private static bool Prefix(AstralMapController __instance) { if (GameSessionManager.ActiveSession.ActiveSectorId == 0) { __instance._gameStart = true; return false; } return true; } } [HarmonyPatch(typeof(AsteroidRain), "SetRandomSpawnDirection")] internal class AstroidRainLoadExceptionPatch { private static bool Prefix() { return !SaveHandler.LoadSavedData; } } [HarmonyPatch(typeof(VoidJumpSystem), "EnterVoid")] internal class AutoSavePatch { internal static bool FirstJump; private static void Postfix() { if (!Config.AutoSavingEnabled.Value || SaveHandler.LoadSavedData || !SaveHandler.StartedAsHost) { return; } if (FirstJump) { FirstJump = false; return; } if (SaveHandler.IsIronManMode) { if (SaveHandler.LastSaveName == null) { SaveHandler.LatestData.FileName = SaveHandler.GetNextIronManSaveName(); } SaveHandler.WriteSave(SaveHandler.LastSaveName); return; } ConfigEntry<int> lastAutoSave = Config.LastAutoSave; int value = lastAutoSave.Value; lastAutoSave.Value = value + 1; if (Config.LastAutoSave.Value > Config.AutoSaveLimit.Value) { Config.LastAutoSave.Value = 1; } SaveHandler.WriteSave($"AutoSave_{Config.LastAutoSave.Value}"); } } [HarmonyPatch(typeof(HubQuestManager))] internal class BlockQuestChangingInHubPatches { [HarmonyPatch("SelectQuest")] [HarmonyPrefix] private static bool SelectQuestPatch() { return !SaveHandler.LoadSavedData; } [HarmonyPatch("SelectShip")] [HarmonyPrefix] private static bool SelectShipPatch() { return !SaveHandler.LoadSavedData; } } [HarmonyPatch(typeof(AbstractPlayerControlledShip), "Kill")] internal class IronManDeleteOnDeathPatch { private static void Postfix() { if (SaveHandler.StartedAsHost && SaveHandler.IsIronManMode) { SaveHandler.DeleteSaveFile(SaveHandler.LastSaveName); } } } [HarmonyPatch(typeof(GSEndSession), "OnEnter")] internal class IronManDeleteOnWinPatch { private static void Postfix() { if (SaveHandler.StartedAsHost && SaveHandler.IsIronManMode) { SaveHandler.DeleteSaveFile(SaveHandler.LastSaveName); } } } [HarmonyPatch(typeof(GSIngame), "OnEnter")] internal class IronManNotifiyPatch { private static void Postfix(IState previous) { if (previous is GSSpawn && GameSessionManager.InHub && SaveHandler.StartedAsHost && SaveHandler.IsIronManMode) { Messaging.Notification("Iron Man for the next session is ON", false); } } } [HarmonyPatch(typeof(GSQuitFromMenu), "OnEnter")] internal class LeaveGameCancelLoadPatch { private static void Postfix() { SaveHandler.LatestData = null; SaveHandler.CancelOrFinalzeLoad(); } } [HarmonyPatch] internal class LoadInInterdictionTimerPatches { [HarmonyPatch(typeof(VoidJumpTravellingStable), "OnEnter")] [HarmonyPostfix] private static void VoidJumpStableInterdictionTimerPatch(VoidJumpTravellingStable __instance) { if (SaveHandler.LoadSavedData) { __instance.DurationUntilUnstable += Config.ExtraMSUntilInterdiction.Value; } } [HarmonyPatch(typeof(VoidJumpTravellingUnstable), "OnEnter")] [HarmonyPostfix] private static void VoidJumpUnstableInterdictionTimerPatch(VoidJumpTravellingUnstable __instance) { if (SaveHandler.LoadSavedData) { __instance.DurationUntilInterdiction += Config.ExtraMSUntilInterdiction.Value; } } } [HarmonyPatch] internal class LoadSavePatches { private static bool FirstLoadJump; private static bool BlockSpinUpSignalResolution; [HarmonyPatch(typeof(HubQuestManager), "StartQuest")] [HarmonyPrefix] private static void LoadShipGUID(HubQuestManager __instance, Quest quest) { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) if (SaveHandler.LoadSavedData) { __instance.SelectedShipGuid = SaveHandler.ActiveData.ShipLoadoutGUID; quest.QuestParameters.Seed = SaveHandler.ActiveData.Seed; PunSingleton<PhotonService>.Instance.SetCurrentRoomShip(__instance.SelectedShipGuid); if (SaveHandler.ActiveData.ProgressionDisabled) { ProgressionHandler.DisableProgression("Dragon.VoidSaving"); } } } [HarmonyPatch(typeof(GameSessionManager), "LoadGameSessionNetworkedAssets")] [HarmonyPrefix] private static void ShipLoadPatch(GameSessionManager __instance) { if (SaveHandler.LoadSavedData) { __instance.activeGameSession.ToLoadShipData = ShipLoadout.FromJObject(SaveHandler.ActiveData.ShipLoadout); } } [HarmonyPatch(typeof(AbstractPlayerControlledShip), "Start")] [HarmonyPostfix] private static void PostShipLoadPatch(AbstractPlayerControlledShip __instance) { //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Expected O, but got Unknown if (!SaveHandler.LoadSavedData) { return; } SaveGameData activeData = SaveHandler.ActiveData; ((OrbitObject)__instance).hitPoints = activeData.ShipHealth; HullDamageController componentInChildren = ((Component)__instance).GetComponentInChildren<HullDamageController>(); componentInChildren.State.repairableHp = activeData.RepairableShipHealth; Helpers.LoadBreachStates(componentInChildren, activeData.Breaches); Helpers.AddBlueprintsToFabricator(__instance, activeData.UnlockedBPs); Helpers.AddRelicsToShip(__instance, activeData.Relics); ((Component)__instance).GetComponentInChildren<FabricatorModule>().CurrentTier = activeData.FabricatorTier; ProtectedPowerSystem val = (ProtectedPowerSystem)__instance.ShipsPowerSystem; if (activeData.ShipPowered) { ((PowerSystem)val).PowerOn(); } Helpers.LoadBreakers(val, activeData.BreakerData); int num = 0; CellModule[] coreSystems = __instance.CoreSystems; foreach (CellModule val2 in coreSystems) { if (activeData.ShipSystemPowerStates[num]) { val2.TurnOn(); } num++; } BuildSocketController component = ((Component)__instance).GetComponent<BuildSocketController>(); num = 0; int num2 = 0; int num3 = 0; int num4 = 0; int num5 = 0; foreach (BuildSocket socket in component.Sockets) { if ((Object)(object)socket.InstalledModule == (Object)null) { continue; } if (activeData.ModulePowerStates[num]) { socket.InstalledModule.TurnOn(); } CellModule installedModule = socket.InstalledModule; CompositeWeaponModule val3 = (CompositeWeaponModule)(object)((installedModule is CompositeWeaponModule) ? installedModule : null); if (val3 != null) { WeaponMagazine magazine = val3.InsideElementsCollection.Magazine; BulletMagazine val4 = (BulletMagazine)(object)((magazine is BulletMagazine) ? magazine : null); if (val4 != null) { val4.ammoLoaded = activeData.WeaponBullets[num2].AmmoLoaded; val4.reservoirAmmoCount = activeData.WeaponBullets[num2].AmmoReservoir; num2++; goto IL_0260; } } CellModule installedModule2 = socket.InstalledModule; KineticPointDefenseModule val5 = (KineticPointDefenseModule)(object)((installedModule2 is KineticPointDefenseModule) ? installedModule2 : null); if (val5 != null) { val5.AmmoCount = activeData.KPDBullets[num3++]; } else { CellModule installedModule3 = socket.InstalledModule; AutoMechanicModule val6 = (AutoMechanicModule)(object)((installedModule3 is AutoMechanicModule) ? installedModule3 : null); if (val6 != null) { ((ChangeResponsive<byte>)(object)val6.TriSwitch).ForceChange(activeData.AutoMechanicSwitches[num4++]); } else { CellModule installedModule4 = socket.InstalledModule; ((ChangeResponsive<byte>)(object)((LifeSupportModule)(((installedModule4 is LifeSupportModule) ? installedModule4 : null)?)).TemperatureSwitch).ForceChange(activeData.LifeSupportModeSwitches[num5++]); } } goto IL_0260; IL_0260: num++; } if (activeData.SaveDataVersion >= 1) { Helpers.LoadBuildSocketPayloads(component, SaveHandler.ActiveData.BuildSocketCarryables); } Helpers.LoadEnhancements(__instance, activeData.Enhancements); Helpers.LoadBoosterStates(__instance, activeData.BoosterStates); Helpers.LoadAtmosphereValues(__instance, activeData.AtmosphereValues, activeData.AtmosphereBufferValues); Helpers.LoadDoorStates(__instance, activeData.DoorStates); Helpers.LoadAirlockSafeties(__instance, activeData.AirlockSafeties); SaveHandler.CompleteLoadingStage(SaveHandler.LoadingStage.AbstractPlayerShipStart); } [HarmonyPatch(typeof(VoidJumpSpinningUp), "OnEnter")] [HarmonyPrefix] private static void GetInterdictionChancesPatch(VoidJumpSpinningUp __instance) { Quest obj = GameSessionManager.ActiveSession?.ActiveQuest; EndlessQuest val = (EndlessQuest)(object)((obj is EndlessQuest) ? obj : null); if (val != null) { if (SaveHandler.LoadSavedData) { ((Quest)val).CurrentInterdictionChance = SaveHandler.ActiveData.CurrentInterdictionChance; ((Quest)val).JumpCounter = SaveHandler.ActiveData.JumpCounter; ((Quest)val).InterdictionCounter = SaveHandler.ActiveData.InterdictionCounter; } else { SaveHandler.LatestData.CurrentInterdictionChance = ((Quest)val).CurrentInterdictionChance; SaveHandler.LatestData.JumpCounter = ((Quest)val).JumpCounter; SaveHandler.LatestData.InterdictionCounter = ((Quest)val).InterdictionCounter; } } } [HarmonyPatch(typeof(GameSessionManager), "LoadActiveSector")] [HarmonyPrefix] private static bool LoadCurrentSectionPatch(GameSessionManager __instance) { //IL_0046: 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) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Expected I4, but got Unknown //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Expected I4, but got Unknown if (!SaveHandler.LoadSavedData) { return true; } int num = SaveHandler.ActiveData.CompletedSectors.Length; FullSectorData fullSectorData = default(FullSectorData); for (int i = 0; i < num; i++) { fullSectorData = SaveHandler.ActiveData.CompletedSectors[i]; SectorCompletionStatus val = (SectorCompletionStatus)0; ObjectiveState state = fullSectorData.State; ObjectiveState val2 = state; switch ((int)val2) { case 0: case 1: case 2: case 4: val = (SectorCompletionStatus)2; break; case 3: val = (SectorCompletionStatus)4; break; case 5: val = (SectorCompletionStatus)1; break; } ((MonoBehaviourPun)EndlessQuestManager.Instance).photonView.RPC("CompleteSector", (RpcTarget)3, new object[2] { fullSectorData.SectorID, (byte)(int)val }); } GameSessionSector sectorById = GameSessionManager.ActiveSession.GetSectorById(fullSectorData.SectorID, false); if (sectorById.SectorObjective != null) { sectorById.SectorObjective.Objective.State = fullSectorData.State; } SessionManagerPropertiesFix.BlockLoadingExecution = true; GameSessionSectorManager.Instance.EnterSector(fullSectorData.SectorID); GameSessionSectorManager.Instance.SetDestinationSector(-1); SaveHandler.CompleteLoadingStage(SaveHandler.LoadingStage.SectorLoad); return false; } [HarmonyPatch(typeof(EndlessQuestManager), "SectorExited")] [HarmonyPrefix] private static bool StopFirstSectorCompletionPatch() { if (FirstLoadJump) { FirstLoadJump = false; return false; } return true; } [HarmonyPatch(typeof(GSIngame), "OnEnter")] [HarmonyPostfix] private static void PostInGameLoadPatch() { //IL_01c0: Unknown result type (might be due to invalid IL or missing references) //IL_01c7: Expected O, but got Unknown if (!SaveHandler.LoadSavedData) { return; } GameSessionSuppliesManager.Instance.AlloyAmount = SaveHandler.ActiveData.Alloy; GameSessionSuppliesManager.Instance.BiomassAmount = SaveHandler.ActiveData.Biomass; AbstractPlayerControlledShip playerShip = ClientGame.Current.PlayerShip; ShieldSystem component = ((Component)playerShip).GetComponent<ShieldSystem>(); for (int i = 0; i < 4; i++) { ((OrbitObject)component._shields[i]).hitPoints = SaveHandler.ActiveData.ShieldHealths[i]; component._shields[i].UpdateShieldState(); } BuildSocketController component2 = ((Component)playerShip).GetComponent<BuildSocketController>(); int num = 0; foreach (BuildSocket socket in component2.Sockets) { if (!((Object)(object)socket.InstalledModule == (Object)null)) { CellModule installedModule = socket.InstalledModule; ShieldModule val = (ShieldModule)(object)((installedModule is ShieldModule) ? installedModule : null); if (val != null) { ((ChangeResponsive<bool>)(object)val.IsClockwise).ForceChange(SaveHandler.ActiveData.ShieldDirections[num++]); ((ChangeResponsive<bool>)(object)val.IsForward).ForceChange(SaveHandler.ActiveData.ShieldDirections[num++]); ((ChangeResponsive<bool>)(object)val.IsCounterClockwise).ForceChange(SaveHandler.ActiveData.ShieldDirections[num++]); } } } Helpers.LoadDefectStates(((Component)playerShip).GetComponent<PlayerShipDefectDamageController>(), SaveHandler.ActiveData.Defects); ((Component)playerShip).GetComponentInChildren<HomunculusAndBiomassSocket>().SwitchToBiomassSocket(); FirstLoadJump = true; AutoSavePatch.FirstJump = true; VoidJumpSystem component3 = ((Component)playerShip).GetComponent<VoidJumpSystem>(); component3.DebugTransitionToExitVectorSetState(); component3.DebugTransitionToRotatingState(); component3.DebugTransitionToSpinningUpState(); BlockSpinUpSignalResolution = true; VoidJumpSpinningUp val2 = (VoidJumpSpinningUp)component3.activeState; val2.enterTimestamp -= 3000; Helpers.LoadVoidDriveModule(ClientGame.Current.PlayerShip, SaveHandler.ActiveData.JumpModule); GameSessionTracker.Instance._statistics = SaveHandler.ActiveData.SessionStats; SaveHandler.CompleteLoadingStage(SaveHandler.LoadingStage.InGameLoad); } [HarmonyPatch(typeof(VoidJumpSpinningUp), "ResolveSignal")] private static bool Prefix() { return !BlockSpinUpSignalResolution; } [HarmonyPatch(typeof(VoidJumpSpinningUp), "OnExit")] private static void Postfix() { BlockSpinUpSignalResolution = false; } } [HarmonyPatch] internal class ModuleSocketsLoadPatches { private static CodeInstruction[] targetSequence = (CodeInstruction[])(object)new CodeInstruction[1] {