This commit is contained in:
Aaro Varis
2025-03-02 18:12:35 +02:00
parent b7bd646520
commit 9295ba43e3
3 changed files with 29 additions and 3 deletions

View File

@@ -41,7 +41,7 @@ namespace BoneSync.Patching
return true; 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)] [HarmonyPatch(nameof(ObjectDestructable.lootTable), MethodType.Getter)]
[HarmonyPrefix] [HarmonyPrefix]
private static bool LootTablePatch(ObjectDestructable __instance, ref LootTableData __result) private static bool LootTablePatch(ObjectDestructable __instance, ref LootTableData __result)
@@ -54,7 +54,7 @@ namespace BoneSync.Patching
return false; return false;
} }
return true; return true;
} }*/
} }
[HarmonyPatch(typeof(Prop_Health))] [HarmonyPatch(typeof(Prop_Health))]

View File

@@ -1,6 +1,7 @@
using BoneSync.Networking.Messages; using BoneSync.Networking.Messages;
using BoneSync.Patching; using BoneSync.Patching;
using MelonLoader; using MelonLoader;
using StressLevelZero.Data;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
@@ -12,8 +13,29 @@ namespace BoneSync.Sync.Components
{ {
public partial class Syncable : MonoBehaviour 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) private void SetHealth(float health, int hits = 0)
{ {
if (gameObject.activeSelf == false && health > 0) if (gameObject.activeSelf == false && health > 0)
{ {
gameObject.SetActive(true); gameObject.SetActive(true);
@@ -26,6 +48,7 @@ namespace BoneSync.Sync.Components
} }
if (objectDestructable) if (objectDestructable)
{ {
_UpdateLootTable();
objectDestructable._health = health; objectDestructable._health = health;
objectDestructable._hits = hits; objectDestructable._hits = hits;
} }

View File

@@ -104,7 +104,10 @@ namespace BoneSync.Sync
{ {
//Scene scene = gameObject.scene; //Scene scene = gameObject.scene;
//MelonLogger.Msg("Making or getting syncable for: " + gameObject.name + " in scene: " + scene.name); //MelonLogger.Msg("Making or getting syncable for: " + gameObject.name + " in scene: " + scene.name);
if (gameObject == null)
{
return null;
}
Syncable syncable = gameObject.GetComponent<Syncable>(); Syncable syncable = gameObject.GetComponent<Syncable>();
// delete all sub syncables // delete all sub syncables