loottable patches
This commit is contained in:
@@ -3,6 +3,7 @@ using BoneSync.Sync;
|
|||||||
using BoneSync.Sync.Components;
|
using BoneSync.Sync.Components;
|
||||||
using HarmonyLib;
|
using HarmonyLib;
|
||||||
using StressLevelZero.Combat;
|
using StressLevelZero.Combat;
|
||||||
|
using StressLevelZero.Data;
|
||||||
using StressLevelZero.Props;
|
using StressLevelZero.Props;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
@@ -39,6 +40,21 @@ namespace BoneSync.Patching
|
|||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 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)
|
||||||
|
{
|
||||||
|
if (!BoneSync.lobby.IsConnected()) return true;
|
||||||
|
Syncable syncable = ObjectSync.MakeOrGetSyncable(__instance.gameObject);
|
||||||
|
if (syncable != null && !BoneSync.lobby.IsHost)
|
||||||
|
{
|
||||||
|
__result = null;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[HarmonyPatch(typeof(Prop_Health))]
|
[HarmonyPatch(typeof(Prop_Health))]
|
||||||
@@ -64,5 +80,6 @@ namespace BoneSync.Patching
|
|||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -126,7 +126,7 @@ namespace BoneSync.Sync.Components
|
|||||||
private IEnumerator _OnEnableCo()
|
private IEnumerator _OnEnableCo()
|
||||||
{
|
{
|
||||||
yield return null; // wait a frame to make sure all components are initialized, I hate this but it works
|
yield return null; // wait a frame to make sure all components are initialized, I hate this but it works
|
||||||
FindComponents();
|
FindAndUpdateComponents();
|
||||||
CheckAutoSync();
|
CheckAutoSync();
|
||||||
yield break;
|
yield break;
|
||||||
}
|
}
|
||||||
@@ -135,7 +135,7 @@ namespace BoneSync.Sync.Components
|
|||||||
{
|
{
|
||||||
syncablesCache[gameObject] = this;
|
syncablesCache[gameObject] = this;
|
||||||
|
|
||||||
FindComponents();
|
FindAndUpdateComponents();
|
||||||
|
|
||||||
MelonCoroutines.Start(_OnEnableCo());
|
MelonCoroutines.Start(_OnEnableCo());
|
||||||
}
|
}
|
||||||
@@ -165,7 +165,7 @@ namespace BoneSync.Sync.Components
|
|||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
public void FindComponents()
|
public void FindAndUpdateComponents()
|
||||||
{
|
{
|
||||||
ObjectSyncCache.RemoveSyncable(this);
|
ObjectSyncCache.RemoveSyncable(this);
|
||||||
|
|
||||||
@@ -178,7 +178,7 @@ namespace BoneSync.Sync.Components
|
|||||||
magazine = GetComponent<Magazine>();
|
magazine = GetComponent<Magazine>();
|
||||||
plugs = GetComponentsInChildren<Plug>();
|
plugs = GetComponentsInChildren<Plug>();
|
||||||
spawnFragment = GetComponent<SpawnFragment>();
|
spawnFragment = GetComponent<SpawnFragment>();
|
||||||
//rigidbodies = GetComponentsInChildren<Rigidbody>();
|
|
||||||
UpdateTransformList();
|
UpdateTransformList();
|
||||||
|
|
||||||
ObjectSyncCache.AddSyncable(this);
|
ObjectSyncCache.AddSyncable(this);
|
||||||
@@ -194,7 +194,7 @@ namespace BoneSync.Sync.Components
|
|||||||
public bool CanBeSynced()
|
public bool CanBeSynced()
|
||||||
{
|
{
|
||||||
if (spawnFragment) return false; // if has spawn fragment, don't sync
|
if (spawnFragment) return false; // if has spawn fragment, don't sync
|
||||||
FindComponents();
|
FindAndUpdateComponents();
|
||||||
if (rigidbodies.Length > 0) return true;
|
if (rigidbodies.Length > 0) return true;
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
@@ -230,7 +230,10 @@ namespace BoneSync.Sync.Components
|
|||||||
{
|
{
|
||||||
gameObject?.SetActive(false);
|
gameObject?.SetActive(false);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnRegister()
|
||||||
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user