From 9295ba43e324640e5a496a78f8e017cf34424aac Mon Sep 17 00:00:00 2001 From: Aaro Varis Date: Sun, 2 Mar 2025 18:12:35 +0200 Subject: [PATCH] Mogus --- BoneSync/Patching/ObjectHealthPatches.cs | 4 ++-- BoneSync/Sync/Components/SyncableDamage.cs | 23 ++++++++++++++++++++++ BoneSync/Sync/ObjectSync.cs | 5 ++++- 3 files changed, 29 insertions(+), 3 deletions(-) diff --git a/BoneSync/Patching/ObjectHealthPatches.cs b/BoneSync/Patching/ObjectHealthPatches.cs index f424508..b36c01b 100644 --- a/BoneSync/Patching/ObjectHealthPatches.cs +++ b/BoneSync/Patching/ObjectHealthPatches.cs @@ -41,7 +41,7 @@ namespace BoneSync.Patching return true; } - // patch the getter for lootTable to return null if the object is networked + /*// patch the getter for lootTable to return null if the object is networked [HarmonyPatch(nameof(ObjectDestructable.lootTable), MethodType.Getter)] [HarmonyPrefix] private static bool LootTablePatch(ObjectDestructable __instance, ref LootTableData __result) @@ -54,7 +54,7 @@ namespace BoneSync.Patching return false; } return true; - } + }*/ } [HarmonyPatch(typeof(Prop_Health))] diff --git a/BoneSync/Sync/Components/SyncableDamage.cs b/BoneSync/Sync/Components/SyncableDamage.cs index 7520c97..ccdd709 100644 --- a/BoneSync/Sync/Components/SyncableDamage.cs +++ b/BoneSync/Sync/Components/SyncableDamage.cs @@ -1,6 +1,7 @@ using BoneSync.Networking.Messages; using BoneSync.Patching; using MelonLoader; +using StressLevelZero.Data; using System; using System.Collections.Generic; using System.Linq; @@ -12,8 +13,29 @@ namespace BoneSync.Sync.Components { public partial class Syncable : MonoBehaviour { + private LootTableData originalLootTableData = null; + + private void _UpdateLootTable() + { + if (!objectDestructable) return; + if (originalLootTableData == null) + { + originalLootTableData = objectDestructable.lootTable; + } + + if (!BoneSync.lobby.IsConnected() || BoneSync.lobby.IsHost) + { + objectDestructable.lootTable = originalLootTableData; + } + else + { + objectDestructable.lootTable = null; + } + + } private void SetHealth(float health, int hits = 0) { + if (gameObject.activeSelf == false && health > 0) { gameObject.SetActive(true); @@ -26,6 +48,7 @@ namespace BoneSync.Sync.Components } if (objectDestructable) { + _UpdateLootTable(); objectDestructable._health = health; objectDestructable._hits = hits; } diff --git a/BoneSync/Sync/ObjectSync.cs b/BoneSync/Sync/ObjectSync.cs index b3a0a19..cd8dde8 100644 --- a/BoneSync/Sync/ObjectSync.cs +++ b/BoneSync/Sync/ObjectSync.cs @@ -104,7 +104,10 @@ namespace BoneSync.Sync { //Scene scene = gameObject.scene; //MelonLogger.Msg("Making or getting syncable for: " + gameObject.name + " in scene: " + scene.name); - + if (gameObject == null) + { + return null; + } Syncable syncable = gameObject.GetComponent(); // delete all sub syncables