scenemanager sync

This commit is contained in:
2025-03-13 20:46:57 +02:00
parent 1843410a4d
commit f1f8f1cbcf

View File

@@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using BoneSync.Data;
using BoneSync.Sync; using BoneSync.Sync;
using HarmonyLib; using HarmonyLib;
using MelonLoader; using MelonLoader;
@@ -13,8 +14,8 @@ namespace BoneSync.Patching
[HarmonyPatch(typeof(BoneworksSceneManager))] [HarmonyPatch(typeof(BoneworksSceneManager))]
internal class SceneManagerPatches internal class SceneManagerPatches
{ {
/*[HarmonyPatch(nameof(BoneworksSceneManager.LoadScene)), HarmonyPostfix] [HarmonyPatch(nameof(BoneworksSceneManager.LoadScene), new Type[] { typeof(int) }), HarmonyPrefix]
private static void LoadScenePrefix(int sceneBuildIndex) private static void LoadSceneIndexPrefix(int sceneBuildIndex)
{ {
SyncLogger.Msg("LoadScenePrefix: " + sceneBuildIndex); SyncLogger.Msg("LoadScenePrefix: " + sceneBuildIndex);
if (!BoneSync.IsConnected) return; if (!BoneSync.IsConnected) return;
@@ -23,6 +24,18 @@ namespace BoneSync.Patching
SyncLogger.Msg("Host is loading scene, sending message to clients..."); SyncLogger.Msg("Host is loading scene, sending message to clients...");
SceneSync.SendSceneSyncMessage(sceneBuildIndex); 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);
}
}
} }
} }