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;
}
// 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))]

View File

@@ -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;
}

View File

@@ -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<Syncable>();
// delete all sub syncables