holster sync fixes and gun sync fixes
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
using StressLevelZero.Combat;
|
||||
using StressLevelZero.Pool;
|
||||
using StressLevelZero.Props;
|
||||
using StressLevelZero.Props.Weapons;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
@@ -31,6 +32,13 @@ namespace BoneSync.Patching
|
||||
allowPatchedMethodCall = false;
|
||||
}
|
||||
|
||||
public static void FireGun(Gun __instance)
|
||||
{
|
||||
allowPatchedMethodCall = true;
|
||||
__instance.Fire();
|
||||
allowPatchedMethodCall = false;
|
||||
}
|
||||
|
||||
public static Poolee InstantiatePoolee(Pool pool, Vector3 position, Quaternion rotation, Vector3 scale)
|
||||
{
|
||||
allowPatchedMethodCall = true;
|
||||
|
||||
@@ -26,9 +26,8 @@ namespace BoneSync.Patching
|
||||
Syncable syncable = ObjectSync.MakeOrGetSyncable(__instance.gameObject);
|
||||
if (syncable == null) return true;
|
||||
if (!syncable.Registered) return true;
|
||||
if (!syncable.isOwner) return false; // only allow owner to fire
|
||||
|
||||
if (syncable.isOwner)
|
||||
{
|
||||
MelonLogger.Msg("Sending gun fire message: " + __instance.name);
|
||||
GunSyncInfo gunSyncInfo = new GunSyncInfo()
|
||||
{
|
||||
@@ -36,11 +35,11 @@ namespace BoneSync.Patching
|
||||
hammerState = __instance.hammerState,
|
||||
syncId = syncable.GetSyncId(),
|
||||
messageType = GunSyncMessageType.Fire,
|
||||
bulletObject = __instance.chamberedCartridge
|
||||
};
|
||||
|
||||
GunSyncMessage gunSyncMessage = new GunSyncMessage(gunSyncInfo);
|
||||
gunSyncMessage.Broadcast();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -49,7 +48,7 @@ namespace BoneSync.Patching
|
||||
[HarmonyPatch(nameof(Gun.OnFire)), HarmonyPrefix]
|
||||
public static bool OnFirePatch(Gun __instance)
|
||||
{
|
||||
if (CallPatchedMethods.allowPatchedMethodCall) return true;
|
||||
//if (CallPatchedMethods.allowPatchedMethodCall) return true; // this patch should always be called
|
||||
MelonLoader.MelonLogger.Msg("Gun.OnFire: " + __instance.name);
|
||||
if (!BoneSync.lobby.IsConnected()) return true;
|
||||
|
||||
|
||||
@@ -12,9 +12,10 @@ using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
namespace BoneSync.Patching
|
||||
{
|
||||
[HarmonyPatch(typeof(HandWeaponSlotReciever))]
|
||||
internal class HolsterSlotPatches
|
||||
{
|
||||
[HarmonyPatch(typeof(HandWeaponSlotReciever), nameof(HandWeaponSlotReciever.MakeStatic))]
|
||||
[HarmonyPatch(nameof(HandWeaponSlotReciever.MakeStatic)), HarmonyPrefix]
|
||||
public static void StaticPatch(HandWeaponSlotReciever __instance)
|
||||
{
|
||||
MelonLogger.Msg("HandWeaponSlotReciever.MakeStatic: " + __instance.name);
|
||||
@@ -29,7 +30,7 @@ namespace BoneSync.Patching
|
||||
syncable?.SetInHolster(true);
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(HandWeaponSlotReciever), nameof(HandWeaponSlotReciever.MakeDynamic))]
|
||||
[HarmonyPatch(nameof(HandWeaponSlotReciever.MakeDynamic)), HarmonyPrefix]
|
||||
public static void DynamicPatch(HandWeaponSlotReciever __instance)
|
||||
{
|
||||
MelonLogger.Msg("HandWeaponSlotReciever.MakeDynamic: " + __instance.name);
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using BoneSync.Networking.Messages;
|
||||
using BoneSync.Patching;
|
||||
using StressLevelZero.Combat;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@@ -54,7 +55,7 @@ namespace BoneSync.Sync.Components
|
||||
|
||||
if (gunSyncInfo.messageType == GunSyncMessageType.Fire)
|
||||
{
|
||||
gun.Fire();
|
||||
CallPatchedMethods.FireGun(gun);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user