diff --git a/Directory.Build.targets b/Directory.Build.targets index ec17595c..9dc760d9 100644 --- a/Directory.Build.targets +++ b/Directory.Build.targets @@ -18,7 +18,8 @@ $(GameFolderActive)/UnityEngine.InputLegacyModule.dll $(GameFolderActive)/Unity.TextMeshPro.dll ^ $(GameFolderActive)/UnityEngine.TextRenderingModule.dll $(GameFolderActive)/UnityEngine.UI.dll ^ $(GameFolderActive)/UnityEngine.UIModule.dll $(GameFolderActive)/UnityEngine.UnityWebRequestModule.dll ^ - $(GameFolderActive)/Ionic.Zip.dll $(GameFolderActive)/Newtonsoft.Json.dll $(GameFolderActive)/com.rlabrecque.steamworks.net.dll" /> + $(GameFolderActive)/Ionic.Zip.dll $(GameFolderActive)/Newtonsoft.Json.dll $(GameFolderActive)/com.rlabrecque.steamworks.net.dll" + IgnoreExitCode="true"/> @@ -68,6 +69,7 @@ staticID: PeterHan.$(AssemblyName) true + diff --git a/Lib/Assembly-CSharp-firstpass.dll b/Lib/Assembly-CSharp-firstpass.dll index 223d418a..9281d8e5 100644 Binary files a/Lib/Assembly-CSharp-firstpass.dll and b/Lib/Assembly-CSharp-firstpass.dll differ diff --git a/Lib/Assembly-CSharp-firstpass_public.dll b/Lib/Assembly-CSharp-firstpass_public.dll index e2f0b65c..ad786e25 100644 Binary files a/Lib/Assembly-CSharp-firstpass_public.dll and b/Lib/Assembly-CSharp-firstpass_public.dll differ diff --git a/Lib/Assembly-CSharp.dll b/Lib/Assembly-CSharp.dll index 9c7b9e2e..e9096a6b 100644 Binary files a/Lib/Assembly-CSharp.dll and b/Lib/Assembly-CSharp.dll differ diff --git a/Lib/Assembly-CSharp_public.dll b/Lib/Assembly-CSharp_public.dll index 863e7a28..dbead924 100644 Binary files a/Lib/Assembly-CSharp_public.dll and b/Lib/Assembly-CSharp_public.dll differ diff --git a/Lib/README.md b/Lib/README.md new file mode 100644 index 00000000..6c7a5ae6 --- /dev/null +++ b/Lib/README.md @@ -0,0 +1 @@ +The libraries in this folder are automatically generated Reference Assemblies. They do not contain the actual game code, only stubs of it with the implementations removed. This usage has been allowed by Klei for the game DLLs; other dependency DLLs are used under their license. diff --git a/README.md b/README.md index c25c9a86..a9e86241 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Peter Han's Mods for Oxygen Not Included -Last tested on game version: **U51-596100** +Last tested on game version: **U52-623711** **No support** for Public Testing branches, including the rolled back Legacy Vanilla (CS-469300). @@ -42,7 +42,6 @@ Mods should remain in their own subfolder. | [Food Supply Tooltips](https://steamcommunity.com/sharedfiles/filedetails/?id=1914501780) | Adds tooltips to food sources indicating their calorie production per cycle | Yes | Yes | | [Mismatched Wire Finder](https://steamcommunity.com/sharedfiles/filedetails/?id=2607620648) | Finds wires and pipes that do not match the rest of their network | Yes | Yes | | [Mod Updater](https://steamcommunity.com/sharedfiles/filedetails/?id=2018291283) | Updates mods that Steam leaves at old versions | Yes | Yes | -| [No Splash Screen](https://steamcommunity.com/sharedfiles/filedetails/?id=2361698345) | Hides the Early Access splash screen | Yes | Yes | | [Not Enough Tags](https://steamcommunity.com/sharedfiles/filedetails/?id=2230218796) | Deprecated! No longer supported. | No | No | | [Pip Plant Overlay](https://steamcommunity.com/sharedfiles/filedetails/?id=2493100777) | Adds an overlay showing where Pips can plant seeds | Yes | Yes | | [Popup Control](https://steamcommunity.com/sharedfiles/filedetails/?id=2032187035) | Shows or hides text info popups for each source | Yes | Yes | @@ -80,21 +79,24 @@ Mods should remain in their own subfolder. | **Name** | **Description** | **Vanilla** | **Spaced Out! DLC** | | :--------: | :---------------: | :-----------: | :-------------------: | | [Decor Reimagined](https://steamcommunity.com/sharedfiles/filedetails/?id=1892161928) | Reimagines decor, rewarding bases with consistent, unique decor items | Yes | Yes | -| [Diseases Restored](https://steamcommunity.com/sharedfiles/filedetails/?id=1911357229) | Restores diseases making germs more dangerous again, and adds methods to deal with germ spread | Yes | No | -| [Traits Reworked](https://steamcommunity.com/sharedfiles/filedetails/?id=1905214098) | Reworks Duplicant traits to make all traits meaningful and the most extreme traits more sensible | Yes | No | +| [Diseases Restored](https://steamcommunity.com/sharedfiles/filedetails/?id=1911357229) | Restores diseases making germs more dangerous again, and adds methods to deal with germ spread | Yes | Yes | +| [Traits Reworked](https://steamcommunity.com/sharedfiles/filedetails/?id=1905214098) | Deprecated! No longer supported. | No | No | # Compiling this repository -This repository requires an installed copy of Oxygen Not Included to compile. The project is currently built against Visual Studio 2022, the .NET Framework 4.7.1 (as required by the game), and [Refasmer](https://github.com/JetBrains/Refasmer). Make sure that the correct targeting packs, as well as MSBuild support, are installed to build. +This repository requires an installed copy of Oxygen Not Included to compile. +The project is currently built against Visual Studio 2022, the .NET Framework 4.7.1 (as required by the game), and optionally [Refasmer](https://github.com/JetBrains/Refasmer) to regenerate the CI assemblies. +Make sure that the correct targeting packs, as well as MSBuild support, are installed to build. To install the .NET runtime, targeting pack, and external build tools, run the following commands in a terminal. ```sh > winget install Microsoft.DotNet.Framework.DeveloperPack_4 -v 4.7.1 > winget install Microsoft.DotNet.SDK.8 -> dotnet tool install -g JetBrains.Refasmer.CliTool ``` -The build scripts will automatically detect most Steam installations of Oxygen Not Included. To customize paths for other distribution platforms or operating systems, create a copy of `Directory.Build.props.default` named `Directory.Build.props.user`. Modify the values in it to match the correct folder locations. The "legacy" game folder is only used for pre-Mergedown versions of the game and can usually be safely ignored. +The build scripts will automatically detect most Steam installations of Oxygen Not Included. +To customize paths for other distribution platforms or operating systems, create a copy of `Directory.Build.props.default` named `Directory.Build.props.user`. +Modify the values in it to match the correct folder locations. The "legacy" game folder is only used for pre-Mergedown versions of the game and can usually be safely ignored. *Note that ReSharper may have issues with the Steam build auto-detection; users of this plugin will need to manually specify paths to any custom Steam installations* diff --git a/StockBugFix/StockBugFix.csproj b/StockBugFix/StockBugFix.csproj index 01fe9b7c..c480469e 100644 --- a/StockBugFix/StockBugFix.csproj +++ b/StockBugFix/StockBugFix.csproj @@ -2,7 +2,7 @@ Stock Bug Fix - 4.2.0.0 + 4.3.0.0 PeterHan.StockBugFix Fixes bugs and annoyances in the stock game. 3.2.0.0 diff --git a/StockBugFix/StockBugFixOptions.cs b/StockBugFix/StockBugFixOptions.cs index a476b586..812ec068 100644 --- a/StockBugFix/StockBugFixOptions.cs +++ b/StockBugFix/StockBugFixOptions.cs @@ -58,6 +58,13 @@ public sealed class StockBugFixOptions : SingletonOptions { [JsonProperty] public bool FixTraits { get; set; } + /// + /// If true, fixes a bug where generator minimum output temperatures are ignored. + /// + [Option("Minimum Output Temperatures", "Corrects the minimum output exhaust temperatures of many generators.")] + [JsonProperty] + public bool MinOutputTemperature { get; set; } + /// /// If true, locks out the Mods button until the race condition which reinstalls all /// mods clears out, or until the timeout passes. @@ -75,17 +82,18 @@ public sealed class StockBugFixOptions : SingletonOptions { public StockBugFixOptions() { AllowTepidizerPulsing = false; - DelayModsMenu = false; + DelayModsMenu = true; FixMultipleAttributes = true; FixOverheat = true; FixTraits = true; + MinOutputTemperature = false; StoreFoodChoreType = StoreFoodCategory.Store; } public override string ToString() { - return "StockBugFixOptions[allowTepidizer={1},fixOverheat={0},foodChoreType={2},fixAttributes={3},fixTraits={4},delayModsMenu={5}]".F( + return "StockBugFixOptions[allowTepidizer={1},fixOverheat={0},foodChoreType={2},fixAttributes={3},fixTraits={4},delayModsMenu={5},minOutput={6}]".F( FixOverheat, AllowTepidizerPulsing, StoreFoodChoreType, FixMultipleAttributes, - FixTraits, DelayModsMenu); + FixTraits, DelayModsMenu, MinOutputTemperature); } } diff --git a/StockBugFix/StockBugsPatches.cs b/StockBugFix/StockBugsPatches.cs index f81b0340..40e1b0f1 100644 --- a/StockBugFix/StockBugsPatches.cs +++ b/StockBugFix/StockBugsPatches.cs @@ -469,6 +469,58 @@ internal static bool Prefix(Diggable __instance, Worker worker, ref bool __resul } } + /// + /// Applied to EnergyGenerator to use the correct building output temperature. + /// + [HarmonyPatch(typeof(EnergyGenerator), "Emit")] + public static class EnergyGenerator_Emit_Patch { + /// + /// Allow this patch to be turned off in the config. + /// + internal static bool Prepare() { + return StockBugFixOptions.Instance.MinOutputTemperature; + } + + /// + /// Transpiles Emit to add a call to Mathf.Max on each attempt to access the building + /// temperature with the output minimum temperature. + /// + internal static TranspiledMethod Transpiler(TranspiledMethod method, + ILGenerator generator) { + var targetMethod = typeof(PrimaryElement).GetPropertySafe(nameof( + PrimaryElement.Temperature), false)?.GetGetMethod(); + var maxMethod = typeof(Mathf).GetMethodSafe(nameof(Mathf.Max), true, typeof(float), + typeof(float)); + var emitOffset = typeof(EnergyGenerator.OutputItem).GetFieldSafe(nameof( + EnergyGenerator.OutputItem.emitOffset), false); + var minTempField = typeof(EnergyGenerator.OutputItem).GetFieldSafe( + nameof(EnergyGenerator.OutputItem.minTemperature), false); + if (maxMethod != null && targetMethod != null) { + var local = generator.DeclareLocal(typeof(float)); + bool emitCase = false; + // Store the min temperature into local + yield return new CodeInstruction(OpCodes.Ldarg_1); + yield return new CodeInstruction(OpCodes.Ldfld, minTempField); + yield return new CodeInstruction(OpCodes.Stloc_S, local.LocalIndex); + foreach (var instr in method) { + yield return instr; + if (!emitCase && instr.opcode == OpCodes.Callvirt && instr.operand is + MethodBase getter && getter == targetMethod) { + // Patch all cases until the emit offset is used + yield return new CodeInstruction(OpCodes.Ldloc_S, local.LocalIndex); + yield return new CodeInstruction(OpCodes.Call, maxMethod); + } + if (instr.operand is FieldInfo info && info == emitOffset) + emitCase = true; + } + } else { + PUtil.LogWarning("Target PrimaryElement method not found."); + foreach (var instr in method) + yield return instr; + } + } + } + /// /// Applied to ExobaseHeadquartersConfig to ban them from being built in rockets. They /// already cannot be built there in the base game, but this greatly improves the diff --git a/StockBugFix/StockQOLPatches.cs b/StockBugFix/StockQOLPatches.cs index 36e8373a..467a68c4 100644 --- a/StockBugFix/StockQOLPatches.cs +++ b/StockBugFix/StockQOLPatches.cs @@ -59,25 +59,6 @@ internal static void Postfix(BuildingDef __result) { } } - /// - /// Applied to IceMachineConfig to give it a sensible overheat temperature. - /// - [HarmonyPatch(typeof(IceMachineConfig), "CreateBuildingDef")] - public static class IceMachineConfig_CreateBuildingDef_Patch { - internal static bool Prepare() { - return StockBugFixOptions.Instance.FixOverheat; - } - - /// - /// Applied after CreateBuildingDef runs. - /// - internal static void Postfix(BuildingDef __result) { - // Overheat at 125 C - __result.Overheatable = true; - __result.OverheatTemperature = TUNING.BUILDINGS.OVERHEAT_TEMPERATURES.HIGH_2; - } - } - /// /// Applied to KilnConfig to give it a sensible overheat temperature. ///