From f1f8f1cbcf2ac84beb819c8aac02e6fffda3f4a9 Mon Sep 17 00:00:00 2001 From: Aaro Varis Date: Thu, 13 Mar 2025 20:46:57 +0200 Subject: [PATCH] scenemanager sync --- BoneSync/Patching/SceneManagerPatches.cs | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/BoneSync/Patching/SceneManagerPatches.cs b/BoneSync/Patching/SceneManagerPatches.cs index d1a606b..3d92bdc 100644 --- a/BoneSync/Patching/SceneManagerPatches.cs +++ b/BoneSync/Patching/SceneManagerPatches.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; +using BoneSync.Data; using BoneSync.Sync; using HarmonyLib; using MelonLoader; @@ -13,8 +14,8 @@ namespace BoneSync.Patching [HarmonyPatch(typeof(BoneworksSceneManager))] internal class SceneManagerPatches { - /*[HarmonyPatch(nameof(BoneworksSceneManager.LoadScene)), HarmonyPostfix] - private static void LoadScenePrefix(int sceneBuildIndex) + [HarmonyPatch(nameof(BoneworksSceneManager.LoadScene), new Type[] { typeof(int) }), HarmonyPrefix] + private static void LoadSceneIndexPrefix(int sceneBuildIndex) { SyncLogger.Msg("LoadScenePrefix: " + sceneBuildIndex); if (!BoneSync.IsConnected) return; @@ -23,6 +24,18 @@ namespace BoneSync.Patching SyncLogger.Msg("Host is loading scene, sending message to clients..."); SceneSync.SendSceneSyncMessage(sceneBuildIndex); } - }*/ + } + + [HarmonyPatch(nameof(BoneworksSceneManager.LoadScene), new Type[] { typeof(string) }), HarmonyPostfix] + private static void LoadSceneStringPrefix(string sceneName) + { + SyncLogger.Msg("LoadScenePrefix: " + sceneName); + if (!BoneSync.IsConnected) return; + if (BoneSync.lobby.IsHost) + { + //SyncLogger.Msg("Host is loading scene, sending message to clients..."); + //SceneSync.SendSceneSyncMessage(sceneName); + } + } } }