diff --git a/Runtimes/NET/BepisLoader/LinuxBootstrap.sh b/Runtimes/NET/BepisLoader/LinuxBootstrap.sh old mode 100644 new mode 100755 index 36fa5031..569db132 --- a/Runtimes/NET/BepisLoader/LinuxBootstrap.sh +++ b/Runtimes/NET/BepisLoader/LinuxBootstrap.sh @@ -58,15 +58,6 @@ RENDERER_SCRIPT="Renderer/Renderite.Renderer.sh" # # "$*" 2>/dev/null # } -# Overload the 'dotnet' command so that it calls the version which was -# downloaded by the script rather than potentially call (or fail to call) -# the system's main dotnet runtime. - -dotnet() -{ - "$DOTNET_EXECUTABLE" "$@" -} - main() { # Make sure the dotnet installer is executable, grab the .NET 9.0 runtime and @@ -110,10 +101,56 @@ main() EOF fi + echo "Parsing hookfxr parameters" + HOOKFXR_STATUS="" + TARGET_ASSEMBLY="" + + # CLI arg takes priority + for arg in "$@" ; do + if [ "$arg" = "--hookfxr-enable" ] ; then + HOOKFXR_STATUS="ENABLED" + echo "hookfxr is enabled by CLI" + fi + if [ "$arg" = "--hookfxr-disable" ] ; then + HOOKFXR_STATUS="DISABLED" + echo "hookfxr is disabled by CLI" + fi + TARGET_ARG=${arg#"--hookfxr-target="} + if [ ! "$arg" = "$TARGET_ARG" ] ; then + TARGET_ASSEMBLY="$TARGET_ARG" + echo "hookfxr target forced to $TARGET_ASSEMBLY by CLI" + fi + done + + # If not specified in CLI args, check INI + if [ -z $HOOKFXR_STATUS ] ; then + if grep -q "enable=true" hookfxr.ini ; then + HOOKFXR_STATUS="ENABLED" + echo "hookfxr is enabled by INI" + fi + if grep -q "enable=false" hookfxr.ini ; then + HOOKFXR_STATUS="DISABLED" + echo "hookfxr is disabled by INI" + fi + fi + + ENTRY_POINT="Renderite.Host.dll" + + # If hookfxr is enabled, change the entry point + if [ "$HOOKFXR_STATUS" = "ENABLED" ] ; then + # Only read from INI if it was not already found in CLI + if [ -z $TARGET_ASSEMBLY ]; then + TARGET_ASSEMBLY=$(sed -n "s/^\s*target_assembly=\(.*\S\)\s*$/\1/p" hookfxr.ini) + fi + + if [ -n $TARGET_ASSEMBLY ]; then + ENTRY_POINT="$TARGET_ASSEMBLY" + fi + fi + echo "Entry point: $ENTRY_POINT" # ~ Launch Resonite! :) ~ - - dotnet BepisLoader.dll "$@" + exec "$DOTNET_EXECUTABLE" "$ENTRY_POINT" "$@" } main "$@" diff --git a/Runtimes/NET/BepisLoader/README.md b/Runtimes/NET/BepisLoader/README.md index 9d736989..58fa109f 100644 --- a/Runtimes/NET/BepisLoader/README.md +++ b/Runtimes/NET/BepisLoader/README.md @@ -5,15 +5,23 @@ A mod loader which allows using BepInEx with [Resonite](https://resonite.com/). ## Installation (Manual) -1. Download the latest release ZIP file (e.g., `ResoniteModding-BepisLoader-1.3.1.zip`) from [Thunderstore](https://thunderstore.io/c/resonite/p/ResoniteModding/BepisLoader/). +1. Download the latest release ZIP file (e.g., `ResoniteModding-BepisLoader-1.4.1.zip`) from [Thunderstore](https://thunderstore.io/c/resonite/p/ResoniteModding/BepisLoader/). 2. Extract the contents of the `BepInExPack` folder from the ZIP into your Resonite installation directory: - **Windows Default:** `C:\Program Files (x86)\Steam\steamapps\common\Resonite\` - **Linux Default:** `~/.steam/steam/steamapps/common/Resonite/` 3. **Linux Users Only:** The included `LinuxBootstrap.sh` file needs to be used instead of the default one: - The package includes a modified `LinuxBootstrap.sh` that launches `BepisLoader.dll` instead of `Renderite.Host.dll` - - **Important:** Resonite updates could replace this file, breaking the mod loader. If this happens, you'll need to manually replace `LinuxBootstrap.sh` with the one from the BepisLoader package -4. Start the game normally. -5. If you want to verify that the mod loader is working, check the `BepInEx\LogOutput.log` file after launching the game. + - **Important:** Resonite updates could replace this file, breaking the mod loader. If this happens, you'll need to manually replace `LinuxBootstrap.sh` with the one from the BepisLoader package. + - Some mod managers - including Gale - will copy the script from their managed profile folder to the Resonite install directory on every game launch. In which case, you do not need to replace it manually. +4. Enable the modded entry point by replacing `enable=false` with `enable=true` in the file `hookfxr.ini` + - Alternatively, add `--hookfxr-enable` to your launch arguments. +5. Start the game normally. +6. If you want to verify that the mod loader is working, check the `BepInEx\LogOutput.log` file after launching the game. + +### Disabling temporarily +1. Set `enable=false` in the file `hookfxr.ini` + - Alternatively, add `--hookfxr-disable` to your launch arguments. +2. If you had added `--hookfxr-enable` to your launch arguments before, you must remove it. ### Uninstallation @@ -24,15 +32,13 @@ A mod loader which allows using BepInEx with [Resonite](https://resonite.com/). - **Common Files:** - `hookfxr.ini` - All `BepisLoader*` files - - **Linux Only:** - - Restore the original `LinuxBootstrap.sh` (or verify game files through Steam) 2. Delete the `BepInEx` folder. ## Package Contents The BepisLoader package contains: - **Windows Entry Point:** `hostfxr.dll` and `hookfxr.ini` for hooking into the .NET runtime -- **Linux Entry Point:** Modified `LinuxBootstrap.sh` that launches BepisLoader +- **Linux Entry Point:** Modified `LinuxBootstrap.sh` that launches BepisLoader if hookfxr is enabled (in `hookfxr.ini` or with launch options) - **BepisLoader:** Core loader files (`BepisLoader.dll`, etc.) - **BepInEx:** The BepInEx framework and all required dependencies