diff --git a/Dependencies/BelowZero.stable/FMODUnity.dll b/Dependencies/BelowZero.stable/FMODUnity.dll new file mode 100644 index 000000000..a1dd222c4 Binary files /dev/null and b/Dependencies/BelowZero.stable/FMODUnity.dll differ diff --git a/Example mod/mod.json b/Example mod/mod.json index ae08fa861..4e716067b 100644 --- a/Example mod/mod.json +++ b/Example mod/mod.json @@ -2,11 +2,11 @@ "Id": "SMLHelperExampleMod", "DisplayName": "Example Mod For SMLHelper", "Author": "The SMLHelper Dev Team", - "Version": "2.14.0", + "Version": "2.14.1", "Enable": true, "AssemblyName": "Example mod.dll", "VersionDependencies": { - "SMLHelper": "2.14.0" + "SMLHelper": "2.14.1" }, "Game": "Both", "NitroxCompat": true diff --git a/SMLHelper/Assets/Spawnable.cs b/SMLHelper/Assets/Spawnable.cs index 1ccc0b24a..3eca5a1d2 100644 --- a/SMLHelper/Assets/Spawnable.cs +++ b/SMLHelper/Assets/Spawnable.cs @@ -41,7 +41,7 @@ public abstract class Spawnable: ModPrefab /// By default, this will point to the same folder where your mod DLL is. /// /// "MyModAssembly/Assets" - public virtual string AssetsFolder => modFolderLocation; + public virtual string AssetsFolder => ModFolderLocation; /// /// Override with the file name for this item's icon. @@ -181,7 +181,7 @@ private IEnumerator RegisterSpriteAsync() /// protected PatchEvent OnFinishedPatching; - private readonly string modFolderLocation = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); + private string ModFolderLocation => Path.GetDirectoryName(Mod.Location); /// /// Starts all patching code in SMLHelper. @@ -222,7 +222,7 @@ internal virtual void PatchTechType() protected virtual Sprite GetItemSprite() { // This is for backwards compatibility with mods that were using the "ModName/Assets" format - string path = this.AssetsFolder != modFolderLocation + string path = this.AssetsFolder != ModFolderLocation ? IOUtilities.Combine(".", "QMods", this.AssetsFolder.Trim('/'), this.IconFileName) : Path.Combine(this.AssetsFolder, this.IconFileName); diff --git a/SMLHelper/Patchers/CustomSoundPatcher.cs b/SMLHelper/Patchers/CustomSoundPatcher.cs index ba540873e..16b4ba7fc 100644 --- a/SMLHelper/Patchers/CustomSoundPatcher.cs +++ b/SMLHelper/Patchers/CustomSoundPatcher.cs @@ -401,8 +401,12 @@ public static bool SoundQueue_Update_Prefix(SoundQueue __instance) { var instanceCurrent = __instance._current ?? default; if (string.IsNullOrEmpty(instanceCurrent.sound) || !PlayedChannels.TryGetValue(instanceCurrent.sound, out var channel)) return true; +#if BELOWZERO + if (SoundQueue.GetPlaybackState(__instance.eventInstance) is not PLAYBACK_STATE.STARTING or PLAYBACK_STATE.PLAYING) return true; +#else if (!SoundQueue.GetIsStartingOrPlaying(__instance.eventInstance)) return true; - +#endif + ATTRIBUTES_3D attributes = Player.main.transform.To3DAttributes(); channel.set3DAttributes(ref attributes.position, ref attributes.velocity); channel.getPosition(out var position, TIMEUNIT.MS); @@ -412,15 +416,25 @@ public static bool SoundQueue_Update_Prefix(SoundQueue __instance) return false; } - [HarmonyPatch(typeof(SoundQueue), nameof(SoundQueue.GetIsStartingOrPlaying))] [HarmonyPrefix] - public static bool SoundQueue_GetIsStartingOrPlaying_Prefix( ref bool __result) +#if BELOWZERO + [HarmonyPatch(typeof(SoundQueue), nameof(SoundQueue.GetPlaybackState))] + public static bool SoundQueue_GetIsStartingOrPlaying_Prefix(ref PLAYBACK_STATE __result) +#else + [HarmonyPatch(typeof(SoundQueue), nameof(SoundQueue.GetIsStartingOrPlaying))] + public static bool SoundQueue_GetIsStartingOrPlaying_Prefix(ref bool __result) +#endif { var instanceCurrent = PDASounds.queue?._current ?? default; if (string.IsNullOrEmpty(instanceCurrent.sound) || !PlayedChannels.TryGetValue(instanceCurrent.sound, out var channel)) return true; +#if BELOWZERO + channel.isPlaying(out var isPlaying); + __result = isPlaying ? PLAYBACK_STATE.PLAYING : PLAYBACK_STATE.STOPPED; +#else var result = channel.isPlaying(out __result); __result = __result && result == RESULT.OK; +#endif return false; } diff --git a/SMLHelper/Patchers/TooltipPatcher.cs b/SMLHelper/Patchers/TooltipPatcher.cs index acfc7d10b..af12147a4 100644 --- a/SMLHelper/Patchers/TooltipPatcher.cs +++ b/SMLHelper/Patchers/TooltipPatcher.cs @@ -7,10 +7,13 @@ using System.IO; using System.Reflection; using System.Text; + using System.Linq; + using System.Collections.Generic; internal class TooltipPatcher { internal static bool DisableEnumIsDefinedPatch = false; + private static List vanillaTechTypes = new(); internal static void Patch(Harmony harmony) { @@ -104,7 +107,14 @@ internal static void WriteSpace(StringBuilder sb) internal static bool IsVanillaTechType(TechType type) { - return type <= TechType.Databox; + if (vanillaTechTypes is {Count: 0}) + { + var allTechTypes = (System.Enum.GetValues(typeof(TechType)) as TechType[])!.ToList(); + allTechTypes.RemoveAll(tt => TechTypePatcher.cacheManager.ModdedKeys.Contains(tt)); + vanillaTechTypes = allTechTypes; + } + + return vanillaTechTypes.Contains(type); } #region Options diff --git a/SMLHelper/SMLHelper.csproj b/SMLHelper/SMLHelper.csproj index e9c5d5dde..b949a24d4 100644 --- a/SMLHelper/SMLHelper.csproj +++ b/SMLHelper/SMLHelper.csproj @@ -97,7 +97,7 @@ $(Dependencies)\Unity.TextMeshPro.dll False - + $(Dependencies)\FMODUnity.dll False diff --git a/SMLHelper/ThunderstoreMetadata/BZ.EXP/manifest.json b/SMLHelper/ThunderstoreMetadata/BZ.EXP/manifest.json index b50b8a9dc..8a6ba169e 100644 --- a/SMLHelper/ThunderstoreMetadata/BZ.EXP/manifest.json +++ b/SMLHelper/ThunderstoreMetadata/BZ.EXP/manifest.json @@ -1,6 +1,6 @@ { "name": "SMLHelper_BZ_Experimental", - "version_number": "2.14.0", + "version_number": "2.14.1", "website_url": "https://github.com/SubnauticaModding/SMLHelper/wiki", "description": "SMLHelper is a modding library that helps making mods easier by helping with adding new items, changing items, adding models, sprites, etc.", "dependencies": [ "Subnautica_Modding-QModManager_BZ_Experimental-4.4.2" ] diff --git a/SMLHelper/ThunderstoreMetadata/BZ.STABLE/manifest.json b/SMLHelper/ThunderstoreMetadata/BZ.STABLE/manifest.json index 28921a2b9..8a4a98dbb 100644 --- a/SMLHelper/ThunderstoreMetadata/BZ.STABLE/manifest.json +++ b/SMLHelper/ThunderstoreMetadata/BZ.STABLE/manifest.json @@ -1,6 +1,6 @@ { "name": "SMLHelper_BZ", - "version_number": "2.14.0", + "version_number": "2.14.1", "website_url": "https://github.com/SubnauticaModding/SMLHelper/wiki", "description": "SMLHelper is a modding library that helps making mods easier by helping with adding new items, changing items, adding models, sprites, etc.", "dependencies": [ "Subnautica_Modding-QModManager_BZ-4.4.2" ] diff --git a/SMLHelper/ThunderstoreMetadata/SN.EXP/manifest.json b/SMLHelper/ThunderstoreMetadata/SN.EXP/manifest.json index de37fcafe..56113f4c0 100644 --- a/SMLHelper/ThunderstoreMetadata/SN.EXP/manifest.json +++ b/SMLHelper/ThunderstoreMetadata/SN.EXP/manifest.json @@ -1,6 +1,6 @@ { "name": "SMLHelper_Experimental", - "version_number": "2.14.0", + "version_number": "2.14.1", "website_url": "https://github.com/SubnauticaModding/SMLHelper/wiki", "description": "SMLHelper is a modding library that helps making mods easier by helping with adding new items, changing items, adding models, sprites, etc.", "dependencies": [ "Subnautica_Modding-QModManager_Experimental-4.4.2" ] diff --git a/SMLHelper/ThunderstoreMetadata/SN.STABLE/manifest.json b/SMLHelper/ThunderstoreMetadata/SN.STABLE/manifest.json index f58192983..a4605cc2a 100644 --- a/SMLHelper/ThunderstoreMetadata/SN.STABLE/manifest.json +++ b/SMLHelper/ThunderstoreMetadata/SN.STABLE/manifest.json @@ -1,6 +1,6 @@ { "name": "SMLHelper", - "version_number": "2.14.0", + "version_number": "2.14.1", "website_url": "https://github.com/SubnauticaModding/SMLHelper/wiki", "description": "SMLHelper is a modding library that helps making mods easier by helping with adding new items, changing items, adding models, sprites, etc.", "dependencies": [ "Subnautica_Modding-QModManager-4.4.0" ] diff --git a/SMLHelper/mod_BelowZero.json b/SMLHelper/mod_BelowZero.json index 3798d33ee..9094c33eb 100644 --- a/SMLHelper/mod_BelowZero.json +++ b/SMLHelper/mod_BelowZero.json @@ -2,7 +2,7 @@ "Id": "SMLHelper", "DisplayName": "SMLHelper", "Author": "The SMLHelper Dev Team", - "Version": "2.14.0", + "Version": "2.14.1", "Enable": true, "Game": "BelowZero", "AssemblyName": "SMLHelper.dll", diff --git a/SMLHelper/mod_Subnautica.json b/SMLHelper/mod_Subnautica.json index cbbdc1e4e..58160946d 100644 --- a/SMLHelper/mod_Subnautica.json +++ b/SMLHelper/mod_Subnautica.json @@ -2,7 +2,7 @@ "Id": "SMLHelper", "DisplayName": "SMLHelper", "Author": "The SMLHelper Dev Team", - "Version": "2.14.0", + "Version": "2.14.1", "Enable": true, "Game": "Subnautica", "AssemblyName": "SMLHelper.dll", diff --git a/Version.targets b/Version.targets index 229bcf9a9..abc9878bd 100644 --- a/Version.targets +++ b/Version.targets @@ -2,6 +2,6 @@ - 2.14.0 + 2.14.1 \ No newline at end of file