Skip to content

Commit

Permalink
Merge pull request #282 from SubnauticaModding/dev
Browse files Browse the repository at this point in the history
SMLHelper 2.14.1
  • Loading branch information
Metious committed Oct 31, 2022
2 parents 9ea3579 + f02f116 commit 4124baa
Show file tree
Hide file tree
Showing 13 changed files with 41 additions and 17 deletions.
Binary file added Dependencies/BelowZero.stable/FMODUnity.dll
Binary file not shown.
4 changes: 2 additions & 2 deletions Example mod/mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions SMLHelper/Assets/Spawnable.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public abstract class Spawnable: ModPrefab
/// By default, this will point to the same folder where your mod DLL is.
/// </summary>
/// <example>"MyModAssembly/Assets"</example>
public virtual string AssetsFolder => modFolderLocation;
public virtual string AssetsFolder => ModFolderLocation;

/// <summary>
/// Override with the file name for this item's icon.
Expand Down Expand Up @@ -181,7 +181,7 @@ private IEnumerator RegisterSpriteAsync()
/// </summary>
protected PatchEvent OnFinishedPatching;

private readonly string modFolderLocation = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
private string ModFolderLocation => Path.GetDirectoryName(Mod.Location);

/// <summary>
/// Starts all patching code in SMLHelper.
Expand Down Expand Up @@ -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);

Expand Down
20 changes: 17 additions & 3 deletions SMLHelper/Patchers/CustomSoundPatcher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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;
}

Expand Down
12 changes: 11 additions & 1 deletion SMLHelper/Patchers/TooltipPatcher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<TechType> vanillaTechTypes = new();

internal static void Patch(Harmony harmony)
{
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion SMLHelper/SMLHelper.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@
<HintPath>$(Dependencies)\Unity.TextMeshPro.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="FMODUnity" Condition="$(Configuration.Contains('.EXP'))">
<Reference Include="FMODUnity" Condition="$(Configuration.Contains('.EXP')) Or $(Configuration.Contains('BZ'))">
<HintPath>$(Dependencies)\FMODUnity.dll</HintPath>
<Private>False</Private>
</Reference>
Expand Down
2 changes: 1 addition & 1 deletion SMLHelper/ThunderstoreMetadata/BZ.EXP/manifest.json
Original file line number Diff line number Diff line change
@@ -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" ]
Expand Down
2 changes: 1 addition & 1 deletion SMLHelper/ThunderstoreMetadata/BZ.STABLE/manifest.json
Original file line number Diff line number Diff line change
@@ -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" ]
Expand Down
2 changes: 1 addition & 1 deletion SMLHelper/ThunderstoreMetadata/SN.EXP/manifest.json
Original file line number Diff line number Diff line change
@@ -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" ]
Expand Down
2 changes: 1 addition & 1 deletion SMLHelper/ThunderstoreMetadata/SN.STABLE/manifest.json
Original file line number Diff line number Diff line change
@@ -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" ]
Expand Down
2 changes: 1 addition & 1 deletion SMLHelper/mod_BelowZero.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion SMLHelper/mod_Subnautica.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion Version.targets
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<!-- The assembly uses this version number. !-->
<Version>2.14.0</Version>
<Version>2.14.1</Version>
</PropertyGroup>
</Project>

0 comments on commit 4124baa

Please sign in to comment.