diff --git a/BoneSync/BoneSync.csproj b/BoneSync/BoneSync.csproj
index 88bd138..da32c39 100644
--- a/BoneSync/BoneSync.csproj
+++ b/BoneSync/BoneSync.csproj
@@ -279,6 +279,9 @@
+
+
+
xcopy /Y "$(TargetPath)" "A:\SteamLibrary\steamapps\common\BONEWORKS\BONEWORKS\Mods\"
diff --git a/BoneSync/Networking/Messages/GunSyncMessage.cs b/BoneSync/Networking/Messages/GunSyncMessage.cs
index c10399c..df19d02 100644
--- a/BoneSync/Networking/Messages/GunSyncMessage.cs
+++ b/BoneSync/Networking/Messages/GunSyncMessage.cs
@@ -1,5 +1,6 @@
using BoneSync.Sync;
using BoneSync.Sync.Components;
+using MelonLoader;
using StressLevelZero.Combat;
using StressLevelZero.Props.Weapons;
using System;
@@ -25,7 +26,7 @@ namespace BoneSync.Networking.Messages
public Gun.CartridgeStates cartridgeState;
}
- [PacketType(PacketType.GunSync)]
+ [PacketType(PacketType.GunSync), PacketReliability(PacketReliability.Unreliable)]
public class GunSyncMessage : NetworkMessage
{
GunSyncInfo gunSyncInfo;
@@ -54,6 +55,7 @@ namespace BoneSync.Networking.Messages
{
Syncable syncable = ObjectSyncCache.GetSyncable(gunSyncInfo.syncId);
if (syncable == null) return;
+ MelonLogger.Msg("GunSyncMessage.Execute: " + gunSyncInfo.syncId + ":" + syncable.name);
syncable.OnWeaponSyncData(gunSyncInfo);
}
}
diff --git a/BoneSync/Patching/GunPatches.cs b/BoneSync/Patching/GunPatches.cs
index 2c1b6c7..354bff7 100644
--- a/BoneSync/Patching/GunPatches.cs
+++ b/BoneSync/Patching/GunPatches.cs
@@ -19,28 +19,6 @@ namespace BoneSync.Patching
[HarmonyPatch(nameof(Gun.Fire)), HarmonyPrefix]
public static bool FirePatch(Gun __instance)
{
- if (CallPatchedMethods.allowPatchedMethodCall) return true;
- MelonLoader.MelonLogger.Msg("Gun fired: " + __instance.name);
- if (!BoneSync.lobby.IsConnected()) return true;
-
- 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
-
- MelonLogger.Msg("Sending gun fire message: " + __instance.name);
- GunSyncInfo gunSyncInfo = new GunSyncInfo()
- {
- cartridgeState = __instance.cartridgeState,
- hammerState = __instance.hammerState,
- syncId = syncable.GetSyncId(),
- messageType = GunSyncMessageType.Fire,
- bulletObject = __instance.chamberedCartridge
- };
-
- GunSyncMessage gunSyncMessage = new GunSyncMessage(gunSyncInfo);
- gunSyncMessage.Broadcast();
-
return true;
}
@@ -48,14 +26,30 @@ namespace BoneSync.Patching
[HarmonyPatch(nameof(Gun.OnFire)), HarmonyPrefix]
public static bool OnFirePatch(Gun __instance)
{
- //if (CallPatchedMethods.allowPatchedMethodCall) return true; // this patch should always be called
+ if (CallPatchedMethods.allowPatchedMethodCall) return true; // this patch should always be called
MelonLoader.MelonLogger.Msg("Gun.OnFire: " + __instance.name);
if (!BoneSync.lobby.IsConnected()) return true;
Syncable syncable = ObjectSync.MakeOrGetSyncable(__instance.gameObject);
if (syncable == null) return true;
if (!syncable.Registered) return true;
- return syncable.isOwner; // only allow owner to fire
+ if (syncable.isOwner)
+ {
+ MelonLogger.Msg("Gun.OnFire: " + __instance.name + " is owner");
+ GunSyncInfo gunSyncInfo = new GunSyncInfo()
+ {
+ cartridgeState = __instance.cartridgeState,
+ hammerState = __instance.hammerState,
+ syncId = syncable.GetSyncId(),
+ messageType = GunSyncMessageType.Fire,
+ bulletObject = __instance.chamberedCartridge
+ };
+
+ GunSyncMessage gunSyncMessage = new GunSyncMessage(gunSyncInfo);
+ gunSyncMessage.Broadcast();
+ MelonLogger.Msg("Gun.OnFire: " + __instance.name + " sent message");
+ }
+ return true;
}
}
diff --git a/BoneSync/Sync/Components/SyncableBase.cs b/BoneSync/Sync/Components/SyncableBase.cs
index e68c012..e6dface 100644
--- a/BoneSync/Sync/Components/SyncableBase.cs
+++ b/BoneSync/Sync/Components/SyncableBase.cs
@@ -177,6 +177,8 @@ namespace BoneSync.Sync.Components
return "";
}
+
+
public void FindAndUpdateComponents()
{
ObjectSyncCache.RemoveSyncable(this);
@@ -189,8 +191,14 @@ namespace BoneSync.Sync.Components
objectDestructable = GetComponent();
gun = GetComponent();
magazine = GetComponent();
- plugs = GetComponentsInChildren();
sockets = GetComponentsInChildren();
+ if (sockets.Length == 0)
+ {
+ plugs = GetComponentsInChildren();
+ } else {
+ plugs = new AlignPlug[0]; // don't use plugs if sockets are present
+ }
+
spawnFragment = GetComponent();
UpdateTransformList();
diff --git a/BoneSync/playerrep.eres b/BoneSync/playerrep.eres
new file mode 100644
index 0000000..5a06a34
Binary files /dev/null and b/BoneSync/playerrep.eres differ