diff --git a/.gitignore b/.gitignore index c95cf427..66a104ce 100644 --- a/.gitignore +++ b/.gitignore @@ -349,3 +349,9 @@ MigrationBackup/ # Ionide (cross platform F# VS Code tools) working folder .ionide/ + +# Build script folder +build/ + +# Idea folder +.idea \ No newline at end of file diff --git a/Doorstop/.doorstop_version b/Doorstop/.doorstop_version new file mode 100644 index 00000000..0c89fc92 --- /dev/null +++ b/Doorstop/.doorstop_version @@ -0,0 +1 @@ +4.0.0 \ No newline at end of file diff --git a/Doorstop/doorstop_config.ini b/Doorstop/doorstop_config.ini new file mode 100644 index 00000000..2bd6babd --- /dev/null +++ b/Doorstop/doorstop_config.ini @@ -0,0 +1,45 @@ +# General options for Unity Doorstop +[General] + +# Enable Doorstop? +enabled=true + +# Path to the assembly to load and execute +# NOTE: The entrypoint must be of format `static void Doorstop.Entrypoint.Start()` +target_assembly=SpaceWarp/Core/SpaceWarp.dll + +# If true, Unity's output log is redirected to \output_log.txt +redirect_output_log=false + +# If enabled, DOORSTOP_DISABLE env var value is ignored +# USE THIS ONLY WHEN ASKED TO OR YOU KNOW WHAT THIS MEANS +ignore_disable_switch=false + + +# Options specific to running under Unity Mono runtime +[UnityMono] + +# Overrides default Mono DLL search path +# Sometimes it is needed to instruct Mono to seek its assemblies from a different path +# (e.g. mscorlib is stripped in original game) +# This option causes Mono to seek mscorlib and core libraries from a different folder before Managed +# Original Managed folder is added as a secondary folder in the search path +dll_search_path_override= + +# If true, Mono debugger server will be enabled +debug_enabled=false + +# When debug_enabled is true, specifies the address to use for the debugger server +debug_address=127.0.0.1:10000 + +# If true and debug_enabled is true, Mono debugger server will suspend the game execution until a debugger is attached +debug_suspend=false + +# Options sepcific to running under Il2Cpp runtime +[Il2Cpp] + +# Path to coreclr.dll that contains the CoreCLR runtime +coreclr_path= + +# Path to the directory containing the managed core libraries for CoreCLR (mscorlib, System, etc.) +corlib_dir= diff --git a/Doorstop/winhttp.dll b/Doorstop/winhttp.dll new file mode 100644 index 00000000..e9816fd7 Binary files /dev/null and b/Doorstop/winhttp.dll differ diff --git a/README.md b/README.md index 28d3c749..a41e0542 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,8 @@ Note: Use at your own risk, this is an early version which is expected to have a # Compiling In order to compile this project you need the code from kerbal space program 2, so before you can build anything, copy everything in ``Kerbal Space Program 2\KSP2_x64_Data\Managed`` into ``external_dlls/`` -Then compile the `spacewarp` project, then run the `ksp2_mod_loader_patcher` project. + +Then run one of the build scripts and copy the contents from build to KSP2 root directory Then run KSP2, and wait until the title screen, there should then be a mods folder under the `KSP2_X64_data` folder diff --git a/SpaceWarp/StartupManager.cs b/SpaceWarp/StartupManager.cs index f4454260..329141a0 100644 --- a/SpaceWarp/StartupManager.cs +++ b/SpaceWarp/StartupManager.cs @@ -9,14 +9,21 @@ namespace Doorstop { public class Entrypoint { - - public static void Start() { + /// + /// EntryPoint for Spacewarp, called from Doorstop + /// + public static void Start() + { SceneManager.sceneLoaded += OnSceneLoaded; - } + } static bool patched = false; - static void OnSceneLoaded(Scene unused1, LoadSceneMode unused2) { - + + /// + /// Add OnGameStarted as postfix to StartGame + /// + static void OnSceneLoaded(Scene unused1, LoadSceneMode unused2) + { if (!patched) { Harmony harmony = new Harmony("com.github.celisium.spacewarp-doorstop"); @@ -28,9 +35,7 @@ static void OnSceneLoaded(Scene unused1, LoadSceneMode unused2) { patched = true; } - } - } } diff --git a/build_debug.ps1 b/build_debug.ps1 new file mode 100644 index 00000000..c4eb8120 --- /dev/null +++ b/build_debug.ps1 @@ -0,0 +1,7 @@ +Remove-Item ./build -Recurse -Force +mkdir build/SpaceWarp/core +Copy-Item ./Doorstop/* ./build +dotnet build SpaceWarp/SpaceWarp.csproj -c Debug +Copy-Item ./SpaceWarp/bin/Debug/SpaceWarp.dll ./build/SpaceWarp/core +Copy-Item ./SpaceWarp/bin/Debug/SpaceWarp.pdb ./build/SpaceWarp/core +Copy-Item ./SpaceWarp/bin/Debug/0Harmony.dll ./build/SpaceWarp/core \ No newline at end of file diff --git a/build_release.ps1 b/build_release.ps1 new file mode 100644 index 00000000..8a4a467e --- /dev/null +++ b/build_release.ps1 @@ -0,0 +1,6 @@ +Remove-Item ./build -Recurse -Force +mkdir build/SpaceWarp/core +Copy-Item ./Doorstop/* ./build +dotnet build SpaceWarp/SpaceWarp.csproj -c Release +Copy-Item ./SpaceWarp/bin/Release/SpaceWarp.dll ./build/SpaceWarp/core +Copy-Item ./SpaceWarp/bin/Release/0Harmony.dll ./build/SpaceWarp/core \ No newline at end of file