From d05ed654c03c1a60a350e4656fd49dd54fa8fce0 Mon Sep 17 00:00:00 2001 From: sars Date: Fri, 26 Dec 2025 07:57:32 -0600 Subject: [PATCH] Fix: Update for Nautilus compatibility and build on Linux This commit addresses several issues to make the CyclopsDockingMod compatible with modern Subnautica versions using Nautilus: - Corrected RecipeData.Ingredients assignment for Nautilus compatibility. - Updated project references in .csproj to use correct Linux paths (now commented for Windows default) and forward slashes. - Added Polyfills.cs to support C# 11+ attributes on netstandard2.0. - Uncommented MySignFixerComponent.cs. - Commented out deprecated API usages (CraftData.GetPoweredPrefabName and CyclopsEngineChangeState.mouseHover). - Replaced SetRecipe() with CraftDataHandler.SetRecipeData(). - Updated BaseItem to use Sprite instead of Atlas.Sprite. --- CyclopsDockingMod/BaseItem.cs | 2 +- CyclopsDockingMod/CyclopsDockingMod.csproj | 62 ++++++++++--------- CyclopsDockingMod/CyclopsHatchConnector.cs | 11 +++- CyclopsDockingMod/Fixers/BuilderFixer.cs | 18 +++--- .../Fixers/MySignFixerComponent.cs | 4 +- CyclopsDockingMod/Polyfills.cs | 28 +++++++++ CyclopsDockingMod/Routing/AutoPilot.cs | 4 +- 7 files changed, 84 insertions(+), 45 deletions(-) create mode 100644 CyclopsDockingMod/Polyfills.cs diff --git a/CyclopsDockingMod/BaseItem.cs b/CyclopsDockingMod/BaseItem.cs index b712be3..aeb4c67 100644 --- a/CyclopsDockingMod/BaseItem.cs +++ b/CyclopsDockingMod/BaseItem.cs @@ -20,7 +20,7 @@ public BaseItem(string classID, string name, string desc, string icon) : this(Pr } [SetsRequiredMembers] - public BaseItem(string classID, string name, string desc, Atlas.Sprite icon) : this(PrefabInfo.WithTechType(classID, name, desc, unlockAtStart: true).WithFileName(DefaultResourcePath + classID).WithIcon(icon)) + public BaseItem(string classID, string name, string desc, Sprite icon) : this(PrefabInfo.WithTechType(classID, name, desc, unlockAtStart: true).WithFileName(DefaultResourcePath + classID).WithIcon(icon)) { } diff --git a/CyclopsDockingMod/CyclopsDockingMod.csproj b/CyclopsDockingMod/CyclopsDockingMod.csproj index 43bbc45..c86dc88 100644 --- a/CyclopsDockingMod/CyclopsDockingMod.csproj +++ b/CyclopsDockingMod/CyclopsDockingMod.csproj @@ -31,7 +31,8 @@ prompt 4 C:\Program Files (x86)\Steam\steamapps\common\Subnautica - $(SubnauticaDir)\Subnautica_Data\Managed + + $(SubnauticaDir)/Subnautica_Data/Managed true @@ -42,7 +43,8 @@ prompt 4 C:\Program Files (x86)\Steam\steamapps\common\Subnautica - $(SubnauticaDir)\Subnautica_Data\Managed + + $(SubnauticaDir)/Subnautica_Data/Managed true @@ -53,7 +55,8 @@ prompt 4 C:\Program Files (x86)\Steam\steamapps\common\Subnautica - $(SubnauticaDir)\Subnautica_Data\Managed + + $(SubnauticaDir)/Subnautica_Data/Managed none @@ -63,7 +66,8 @@ prompt 2 C:\Program Files (x86)\Steam\steamapps\common\Subnautica - $(SubnauticaDir)\Subnautica_Data\Managed + + $(SubnauticaDir)/Subnautica_Data/Managed none @@ -73,7 +77,8 @@ prompt 2 C:\Program Files (x86)\Steam\steamapps\common\Subnautica - $(SubnauticaDir)\Subnautica_Data\Managed + + $(SubnauticaDir)/Subnautica_Data/Managed none @@ -83,71 +88,72 @@ prompt 2 C:\Program Files (x86)\Steam\steamapps\common\Subnautica - $(SubnauticaDir)\Subnautica_Data\Managed + + $(SubnauticaDir)/Subnautica_Data/Managed - $(SubnauticaDir)\BepInEx\core\BepInEx.dll + $(SubnauticaDir)/BepInEx/core/BepInEx.dll - $(SubnauticaDir)\BepInEx\core\0Harmony.dll + $(SubnauticaDir)/BepInEx/core/0Harmony.dll - $(Dependencies)\publicized_assemblies\Assembly-CSharp_publicized.dll - + + $(Dependencies)/Assembly-CSharp.dll - $(Dependencies)\publicized_assemblies\Assembly-CSharp-firstpass_publicized.dll - + + $(Dependencies)/Assembly-CSharp-firstpass.dll - $(SubnauticaDir)\BepInEx\plugins\Modding Helper\SMLHelper.dll + $(SubnauticaDir)/BepInEx/plugins/Modding Helper/SMLHelper.dll - $(SubnauticaDir)\BepInEx\plugins\Nautilus\Nautilus.dll + $(SubnauticaDir)/BepInEx/plugins/Nautilus-1262-1-0-0-pre-34-1735432432/Nautilus/Nautilus.dll False - $(Dependencies)\Unity.Addressables.dll + $(Dependencies)/Unity.Addressables.dll - $(Dependencies)\UnityEngine.dll + $(Dependencies)/UnityEngine.dll False - $(Dependencies)\UnityEngine.AnimationModule.dll + $(Dependencies)/UnityEngine.AnimationModule.dll - $(Dependencies)\UnityEngine.AssetBundleModule.dll + $(Dependencies)/UnityEngine.AssetBundleModule.dll - $(Dependencies)\UnityEngine.CoreModule.dll + $(Dependencies)/UnityEngine.CoreModule.dll - $(Dependencies)\UnityEngine.InputLegacyModule.dll + $(Dependencies)/UnityEngine.InputLegacyModule.dll - $(Dependencies)\UnityEngine.PhysicsModule.dll + $(Dependencies)/UnityEngine.PhysicsModule.dll False - $(Dependencies)\UnityEngine.TextRenderingModule.dll + $(Dependencies)/UnityEngine.TextRenderingModule.dll False - $(Dependencies)\Unity.TextMeshPro.dll + $(Dependencies)/Unity.TextMeshPro.dll False - $(Dependencies)\UnityEngine.UI.dll + $(Dependencies)/UnityEngine.UI.dll False - $(Dependencies)\Unity.ResourceManager.dll + $(Dependencies)/Unity.ResourceManager.dll False - $(Dependencies)\UnityEngine.IMGUIModule.dll + $(Dependencies)/UnityEngine.IMGUIModule.dll @@ -191,6 +197,7 @@ + @@ -198,7 +205,4 @@ - - - \ No newline at end of file diff --git a/CyclopsDockingMod/CyclopsHatchConnector.cs b/CyclopsDockingMod/CyclopsHatchConnector.cs index a0829c6..f773afe 100644 --- a/CyclopsDockingMod/CyclopsHatchConnector.cs +++ b/CyclopsDockingMod/CyclopsHatchConnector.cs @@ -8,7 +8,7 @@ using SMLHelper.V2.Crafting; using SMLHelper.V2.Handlers; #endif -using Ingredient = CraftData.Ingredient; +// using Ingredient = CraftData.Ingredient; using UnityEngine; namespace CyclopsDockingMod @@ -69,13 +69,20 @@ public CyclopsHatchConnector() this.IsHabitatBuilder = true; #if SUBNAUTICA_NAUTI base.Recipe = new RecipeData + { + craftAmount = 1 + }; + foreach (var ingredient in this.SortIngredients()) + { + base.Recipe.Ingredients.Add(ingredient); + } #else base.Recipe = new TechData -#endif { craftAmount = 1, Ingredients = this.SortIngredients() }; +#endif } private List SortIngredients() diff --git a/CyclopsDockingMod/Fixers/BuilderFixer.cs b/CyclopsDockingMod/Fixers/BuilderFixer.cs index b5ab8b2..e85deed 100644 --- a/CyclopsDockingMod/Fixers/BuilderFixer.cs +++ b/CyclopsDockingMod/Fixers/BuilderFixer.cs @@ -114,15 +114,15 @@ public static bool CreateGhost_Prefix(ref bool __result) for (int i = 0; i < componentsInChildren.Length; i++) UnityEngine.Object.Destroy(componentsInChildren[i]); BuilderFixer._renderers.SetValue(null, MaterialExtensions.AssignMaterial((GameObject)BuilderFixer._ghostModel.GetValue(null), (Material)BuilderFixer._ghostStructureMaterial.GetValue(null), true)); - string poweredPrefabName = CraftData.GetPoweredPrefabName((TechType)BuilderFixer._constructableTechType.GetValue(null)); - if (!string.IsNullOrEmpty(poweredPrefabName)) - { - CoroutineHost.StartCoroutine((IEnumerator)BuilderFixer._CreatePowerPreviewAsync.Invoke(null, new object[] - { - (GameObject)BuilderFixer._ghostModel.GetValue(null), - poweredPrefabName - })); - } + // string poweredPrefabName = CraftData.GetPoweredPrefabName((TechType)BuilderFixer._constructableTechType.GetValue(null)); + // if (!string.IsNullOrEmpty(poweredPrefabName)) + // { + // CoroutineHost.StartCoroutine((IEnumerator)BuilderFixer._CreatePowerPreviewAsync.Invoke(null, new object[] + // { + // (GameObject)BuilderFixer._ghostModel.GetValue(null), + // poweredPrefabName + // })); + // } BuilderFixer._InitBounds.Invoke(null, new object[] { (GameObject)BuilderFixer._prefab.GetValue(null) }); } __result = true; diff --git a/CyclopsDockingMod/Fixers/MySignFixerComponent.cs b/CyclopsDockingMod/Fixers/MySignFixerComponent.cs index 2db3d11..8ca15ca 100644 --- a/CyclopsDockingMod/Fixers/MySignFixerComponent.cs +++ b/CyclopsDockingMod/Fixers/MySignFixerComponent.cs @@ -1,4 +1,3 @@ -/* using UnityEngine; namespace CyclopsDockingMod.Fixers @@ -21,5 +20,4 @@ public void Awake() base.Invoke("MyRestoreSignState", 1f); } } -} -*/ +} \ No newline at end of file diff --git a/CyclopsDockingMod/Polyfills.cs b/CyclopsDockingMod/Polyfills.cs new file mode 100644 index 0000000..24c91d0 --- /dev/null +++ b/CyclopsDockingMod/Polyfills.cs @@ -0,0 +1,28 @@ +namespace System.Runtime.CompilerServices +{ + internal static class IsExternalInit { } + + [AttributeUsage(AttributeTargets.All, AllowMultiple = true, Inherited = false)] + public sealed class CompilerFeatureRequiredAttribute : Attribute + { + public CompilerFeatureRequiredAttribute(string featureName) + { + FeatureName = featureName; + } + + public string FeatureName { get; } + public bool IsOptional { get; set; } + + public const string RefStructs = "RefStructs"; + public const string RequiredMembers = "RequiredMembers"; + } + + [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Field | AttributeTargets.Property, AllowMultiple = false, Inherited = false)] + public sealed class RequiredMemberAttribute : Attribute { } +} + +namespace System.Diagnostics.CodeAnalysis +{ + [AttributeUsage(AttributeTargets.Constructor, AllowMultiple = false, Inherited = false)] + public sealed class SetsRequiredMembersAttribute : Attribute { } +} diff --git a/CyclopsDockingMod/Routing/AutoPilot.cs b/CyclopsDockingMod/Routing/AutoPilot.cs index 0070879..8ca1b8a 100644 --- a/CyclopsDockingMod/Routing/AutoPilot.cs +++ b/CyclopsDockingMod/Routing/AutoPilot.cs @@ -330,7 +330,9 @@ internal static void ResetHudTooltips(Transform cyclopsHud) if (allEngineChangeState != null && allEngineChangeState.Length > 0) foreach (var engineChangeState in allEngineChangeState) if (engineChangeState != null) - engineChangeState.mouseHover = false; + { + // engineChangeState.mouseHover = false; + } } internal static void StopPlayingRoute(string pid, Transform cyclopsHud = null, bool reachedEnd = true, bool endsOnNothing = false)