diff --git a/.gitignore b/.gitignore
index 9491a2f..dc0b9a9 100644
--- a/.gitignore
+++ b/.gitignore
@@ -360,4 +360,7 @@ MigrationBackup/
.ionide/
# Fody - auto-generated XML schema
-FodyWeavers.xsd
\ No newline at end of file
+FodyWeavers.xsd
+
+# Thunderstore CLI builds
+/build
\ No newline at end of file
diff --git a/BepInExResoniteShim.cs b/BepInExResoniteShim.cs
index 7735e3b..96bdb78 100644
--- a/BepInExResoniteShim.cs
+++ b/BepInExResoniteShim.cs
@@ -70,6 +70,7 @@ void RunPatches()
HarmonyInstance.SafePatchCategory(nameof(GraphicalClientPatch));
HarmonyInstance.SafePatchCategory(nameof(WindowTitlePatcher));
HarmonyInstance.SafePatchCategory(nameof(LogAlerter));
+ HarmonyInstance.SafePatchCategory(nameof(RelativePathFixer));
}
[HarmonyPatch]
diff --git a/BepInExResoniteShim.csproj b/BepInExResoniteShim.csproj
index d04ac7b..62a57a9 100644
--- a/BepInExResoniteShim.csproj
+++ b/BepInExResoniteShim.csproj
@@ -15,14 +15,14 @@
enable
true
false
- true
+ false
true
true
embedded
- $(ResonitePath)/
- $(MSBuildProgramFiles32)\Steam\steamapps\common\Resonite\
- $(HOME)/.steam/steam/steamapps/common/Resonite/
- $(GamePath)BepInEx\plugins\$(AssemblyName)
+ $(ResonitePath)/
+ $(MSBuildProgramFiles32)\Steam\steamapps\common\Resonite\
+ $(HOME)/.steam/steam/steamapps/common/Resonite/
+ $(GamePath)BepInEx\plugins\$(AssemblyName)
$(AssemblyName)
https://nuget-modding.resonite.net/v3/index.json
@@ -30,18 +30,22 @@
-
-
-
-
-
-
-
-
-
+
+
+
+
+ all
+ runtime; build; native; contentfiles; analyzers; buildtransitive
+
+
-
-
+
+
+
+
+
+
+
$(GamePath)FrooxEngine.dll
False
@@ -50,15 +54,19 @@
$(GamePath)Elements.Core.dll
False
-
- $(GamePath)Renderite.Host.dll
- False
-
+
+ $(GamePath)Renderite.Host.dll
+ False
+
$(GamePath)Renderite.Shared.dll
False
+
+
+
+
diff --git a/RelativePathFixer.cs b/RelativePathFixer.cs
new file mode 100644
index 0000000..726877a
--- /dev/null
+++ b/RelativePathFixer.cs
@@ -0,0 +1,65 @@
+using BepInEx;
+using FrooxEngine;
+using HarmonyLib;
+using System.Reflection;
+using System.Reflection.Emit;
+
+namespace BepInExResoniteShim;
+
+class RelativePathFixer
+{
+ [HarmonyPatchCategory(nameof(RelativePathFixer))]
+ [HarmonyPatch(typeof(Program), "$", MethodType.Async)]
+ class RenderiteHostPathFixes
+ {
+ public static IEnumerable Transpiler(IEnumerable codes)
+ {
+ foreach (var code in codes)
+ {
+ if (code.Is(OpCodes.Ldstr, "Logs"))
+ {
+ yield return new(OpCodes.Ldstr, Path.Combine(Paths.GameRootPath, "Logs"));
+ continue;
+ }
+ if (code.Is(OpCodes.Ldstr, "Icon.png"))
+ {
+ yield return new(OpCodes.Ldstr, Path.Combine(Paths.GameRootPath, "Icon.png"));
+ continue;
+ }
+ if(code.operand is MethodInfo mf && mf.Name == nameof(File.WriteAllText))
+ {
+ yield return new(OpCodes.Call, AccessTools.Method(typeof(RenderiteHostPathFixes), nameof(FileWriteInjected)));
+ continue;
+ }
+ yield return code;
+ }
+ }
+
+ public static void FileWriteInjected(string path, string? contents)
+ {
+ if (!Path.IsPathRooted(path))
+ {
+ path = Path.Combine(Paths.GameRootPath, path);
+ }
+ File.WriteAllText(path, contents);
+ }
+ }
+
+ [HarmonyPatchCategory(nameof(RelativePathFixer))]
+ [HarmonyPatch(typeof(RenderSystem), "StartRenderer", MethodType.Async)]
+ public class RenderiteWorkingDirectoryFix
+ {
+ public static IEnumerable Transpiler(IEnumerable codes)
+ {
+ foreach (var code in codes)
+ {
+ if(code.Is(OpCodes.Ldstr, "Renderer"))
+ {
+ yield return new(OpCodes.Ldstr, Path.Combine(Paths.GameRootPath, "Renderer"));
+ continue;
+ }
+ yield return code;
+ }
+ }
+ }
+}