Button event sync and custom logger stuff
This commit is contained in:
@@ -89,6 +89,7 @@
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Data\ByteEncoder.cs" />
|
||||
<Compile Include="Data\Debugger.cs" />
|
||||
<Compile Include="Data\EmebeddedAssetBundle.cs" />
|
||||
<Compile Include="Data\PlayerScripts.cs" />
|
||||
<Compile Include="Data\SpawnableManager.cs" />
|
||||
@@ -114,6 +115,7 @@
|
||||
<Compile Include="Patching\InteractableHostPatches.cs" />
|
||||
<Compile Include="Patching\ObjectHealthPatches.cs" />
|
||||
<Compile Include="Patching\PlugPatches.cs" />
|
||||
<Compile Include="Patching\PrefabSpawnerPatches.cs" />
|
||||
<Compile Include="Patching\SceneManagerPatches.cs" />
|
||||
<Compile Include="Patching\SkeletonHandPatches.cs" />
|
||||
<Compile Include="Patching\ZonePatches.cs" />
|
||||
|
||||
39
BoneSync/Data/Debugger.cs
Normal file
39
BoneSync/Data/Debugger.cs
Normal file
@@ -0,0 +1,39 @@
|
||||
using MelonLoader;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BoneSync.Data
|
||||
{
|
||||
internal static class SyncLogger
|
||||
{
|
||||
public static void Msg(string message, ConsoleColor color = ConsoleColor.White)
|
||||
{
|
||||
StackTrace stackTrace = new StackTrace();
|
||||
StackFrame stackFrame = stackTrace.GetFrame(1);
|
||||
string methodName = stackFrame.GetMethod().Name;
|
||||
string className = stackFrame.GetMethod().DeclaringType.Name;
|
||||
MelonLogger.Msg(color, $"[{className}.{methodName}] {message}");
|
||||
}
|
||||
|
||||
public static void Warning(string message)
|
||||
{
|
||||
Msg(message, ConsoleColor.Yellow);
|
||||
}
|
||||
|
||||
public static void Error(string message)
|
||||
{
|
||||
Msg(message, ConsoleColor.Red);
|
||||
}
|
||||
|
||||
internal static void Debug(string v)
|
||||
{
|
||||
#if TRACE
|
||||
Msg(v, ConsoleColor.Gray);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -20,7 +20,7 @@ namespace BoneSync.Data
|
||||
|
||||
if (manifestResources.Contains(name))
|
||||
{
|
||||
MelonLogger.Msg($"Loading embedded bundle data {name}...");
|
||||
SyncLogger.Msg($"Loading embedded bundle data {name}...");
|
||||
|
||||
byte[] bytes;
|
||||
using (Stream str = assembly.GetManifestResourceStream(name))
|
||||
@@ -30,9 +30,9 @@ namespace BoneSync.Data
|
||||
bytes = memoryStream.ToArray();
|
||||
}
|
||||
|
||||
MelonLogger.Msg($"Loading bundle from data {name}, please be patient...");
|
||||
SyncLogger.Msg($"Loading bundle from data {name}, please be patient...");
|
||||
AssetBundle temp = AssetBundle.LoadFromMemory(bytes);
|
||||
MelonLogger.Msg($"Done!");
|
||||
SyncLogger.Msg($"Done!");
|
||||
return temp;
|
||||
}
|
||||
|
||||
|
||||
@@ -50,7 +50,7 @@ namespace BoneSync.Data
|
||||
playerAnimatorController = playerRig.gameWorldSkeletonRig.characterAnimationManager.animator.runtimeAnimatorController;
|
||||
} catch
|
||||
{
|
||||
MelonLogger.Warning("Failed to get physicsRig player scripts!");
|
||||
SyncLogger.Warning("Failed to get physicsRig player scripts!");
|
||||
}
|
||||
|
||||
GetHandPoses();
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
using StressLevelZero.Data;
|
||||
using BoneSync.Patching;
|
||||
using MelonLoader;
|
||||
using StressLevelZero.Data;
|
||||
using StressLevelZero.Pool;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@@ -7,7 +9,7 @@ using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using UnhollowerBaseLib;
|
||||
using UnhollowerRuntimeLib;
|
||||
|
||||
using UnityEngine;
|
||||
using UnityObject = UnityEngine.Object;
|
||||
|
||||
namespace BoneSync.Data
|
||||
@@ -15,6 +17,7 @@ namespace BoneSync.Data
|
||||
public static class SpawnableManager
|
||||
{
|
||||
private static Dictionary<string, SpawnableObject> _spawnableCache = new Dictionary<string, SpawnableObject>();
|
||||
private static Dictionary<string, SpawnableObject> _spawnablePrefabNameCache = new Dictionary<string, SpawnableObject>();
|
||||
|
||||
public static void AddUnregisteredSpawnables()
|
||||
{
|
||||
@@ -29,11 +32,14 @@ namespace BoneSync.Data
|
||||
private static void _ClearCache()
|
||||
{
|
||||
_spawnableCache.Clear();
|
||||
_spawnablePrefabNameCache.Clear();
|
||||
}
|
||||
public static void RegisterSpawnable(SpawnableObject spawnable)
|
||||
{
|
||||
if (!_spawnableCache.ContainsKey(spawnable.title))
|
||||
_spawnableCache.Add(spawnable.title, spawnable);
|
||||
if (!_spawnableCache.ContainsKey(spawnable?.title))
|
||||
_spawnableCache.Add(spawnable?.title, spawnable);
|
||||
if (spawnable?.prefab?.name != null && !_spawnablePrefabNameCache.ContainsKey(spawnable.prefab.name))
|
||||
_spawnablePrefabNameCache.Add(spawnable.prefab.name, spawnable);
|
||||
}
|
||||
public static SpawnableObject GetSpawnable(string title)
|
||||
{
|
||||
@@ -42,11 +48,33 @@ namespace BoneSync.Data
|
||||
return null;
|
||||
}
|
||||
|
||||
public static SpawnableObject GetSpawnableByPrefabName(string prefabName)
|
||||
{
|
||||
if (_spawnablePrefabNameCache.ContainsKey(prefabName))
|
||||
return _spawnablePrefabNameCache[prefabName];
|
||||
return null;
|
||||
}
|
||||
|
||||
public static Pool GetPool(SpawnableObject spawnable) {
|
||||
PoolManager.RegisterPool(spawnable);
|
||||
return PoolManager.GetPool(spawnable.title);
|
||||
}
|
||||
|
||||
public static Poolee SpawnPoolee(SpawnableObject spawnableObject, Vector3 position, Quaternion rotation)
|
||||
{
|
||||
if (spawnableObject == null) return null;
|
||||
Pool pool = GetPool(spawnableObject);
|
||||
if (pool == null)
|
||||
{
|
||||
SyncLogger.Warning("[SpawnPooleeAndMakeSyncable] Failed to find pool: " + spawnableObject.title);
|
||||
return null;
|
||||
}
|
||||
Poolee poolee = CallPatchedMethods.InstantiatePoolee(pool, position, rotation, pool.Prefab.transform.localScale);
|
||||
|
||||
return poolee;
|
||||
|
||||
}
|
||||
|
||||
public static void Initialize()
|
||||
{
|
||||
_ClearCache();
|
||||
|
||||
@@ -59,19 +59,19 @@ namespace BoneSync
|
||||
|
||||
public override void OnSceneWasLoaded(int buildIndex, string sceneName)
|
||||
{
|
||||
//MelonLogger.Msg("OnLevelWasLoaded: " + sceneName);
|
||||
//SyncLogger.Msg("OnLevelWasLoaded: " + sceneName);
|
||||
}
|
||||
|
||||
public override void OnSceneWasInitialized(int buildIndex, string sceneName)
|
||||
{
|
||||
//MelonLogger.Msg("OnLevelWasInitialized: " + sceneName);
|
||||
//SyncLogger.Msg("OnLevelWasInitialized: " + sceneName);
|
||||
SceneSync.OnSceneInit(buildIndex);
|
||||
PlayerScripts.GetPlayerScripts();
|
||||
}
|
||||
|
||||
public override void OnSceneWasUnloaded(int buildIndex, string sceneName)
|
||||
{
|
||||
//MelonLogger.Msg("OnLevelWasLoaded: " + sceneName);
|
||||
//SyncLogger.Msg("OnLevelWasLoaded: " + sceneName);
|
||||
}
|
||||
|
||||
public override void OnUpdate()
|
||||
@@ -83,7 +83,7 @@ namespace BoneSync
|
||||
|
||||
if (Input.GetKeyDown(KeyCode.P))
|
||||
{
|
||||
MelonLogger.Msg("P key pressed");
|
||||
SyncLogger.Msg("P key pressed");
|
||||
//PlayerRig playerRig = PlayerRig.InstantiatePlayerRigPrefab();
|
||||
}
|
||||
if (Input.GetKeyDown(KeyCode.I))
|
||||
@@ -93,12 +93,12 @@ namespace BoneSync
|
||||
|
||||
if (Input.GetKeyDown(KeyCode.N))
|
||||
{
|
||||
MelonLogger.Msg("Creating debug player rig");
|
||||
SyncLogger.Msg("Creating debug player rig");
|
||||
PlayerRig debugRig = PlayerRig.GetPlayerRig(0);
|
||||
PlayerSyncInfo? playerSyncInfo = PlayerRig.GetLocalSyncInfo();
|
||||
if (!playerSyncInfo.HasValue)
|
||||
{
|
||||
MelonLogger.Msg("PlayerSyncInfo is null");
|
||||
SyncLogger.Msg("PlayerSyncInfo is null");
|
||||
}
|
||||
debugRig.UpdatePlayerSync(playerSyncInfo.Value);
|
||||
}
|
||||
@@ -119,22 +119,22 @@ namespace BoneSync
|
||||
|
||||
public override void OnLateUpdate()
|
||||
{
|
||||
//MelonLogger.Msg("OnLateUpdate");
|
||||
//SyncLogger.Msg("OnLateUpdate");
|
||||
}
|
||||
|
||||
public override void OnGUI()
|
||||
{
|
||||
//MelonLogger.Msg("OnGUI");
|
||||
//SyncLogger.Msg("OnGUI");
|
||||
}
|
||||
|
||||
public override void OnApplicationQuit()
|
||||
{
|
||||
//MelonLogger.Msg("OnApplicationQuit");
|
||||
//SyncLogger.Msg("OnApplicationQuit");
|
||||
}
|
||||
|
||||
public override void OnPreferencesLoaded()
|
||||
{
|
||||
//MelonLogger.Msg("OnPreferencesLoaded");
|
||||
//SyncLogger.Msg("OnPreferencesLoaded");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using BoneSync.Player;
|
||||
using BoneSync.Data;
|
||||
using BoneSync.Player;
|
||||
using BoneSync.Sync;
|
||||
using Facepunch.Steamworks;
|
||||
using Facepunch.Steamworks.Data;
|
||||
@@ -18,43 +19,43 @@ namespace BoneSync.Networking.LobbyManager
|
||||
SteamMatchmaking.OnLobbyCreated += (Result result, Lobby lobby) =>
|
||||
{
|
||||
_lobbyInstance = lobby;
|
||||
MelonLogger.Msg("Created lobby " + lobby.Id);
|
||||
SyncLogger.Msg("Created lobby " + lobby.Id);
|
||||
UpdateLobbyData();
|
||||
_lobbyInstance.SetPublic();
|
||||
};
|
||||
SteamMatchmaking.OnLobbyEntered += (Lobby lobby) =>
|
||||
{
|
||||
_lobbyInstance = lobby;
|
||||
MelonLogger.Msg("Entered lobby " + lobby.Id);
|
||||
SyncLogger.Msg("Entered lobby " + lobby.Id);
|
||||
UpdateLobbyData();
|
||||
};
|
||||
SteamMatchmaking.OnLobbyMemberLeave += (Lobby lobby, Friend friend) =>
|
||||
{
|
||||
if (friend.Id == SteamClient.SteamId)
|
||||
{
|
||||
MelonLogger.Msg("Left lobby " + lobby.Id);
|
||||
SyncLogger.Msg("Left lobby " + lobby.Id);
|
||||
_lobbyInstance = new Lobby();
|
||||
}
|
||||
MelonLogger.Msg("Member left " + friend.Id);
|
||||
SyncLogger.Msg("Member left " + friend.Id);
|
||||
UpdateLobbyData();
|
||||
};
|
||||
SteamMatchmaking.OnLobbyMemberJoined += (Lobby lobby, Friend friend) =>
|
||||
{
|
||||
MelonLogger.Msg("Member joined " + friend.Id);
|
||||
SyncLogger.Msg("Member joined " + friend.Id);
|
||||
SteamFriends.SetPlayedWith(friend.Id);
|
||||
UpdateLobbyData();
|
||||
};
|
||||
MelonLogger.Msg("SteamLobbyManager initialized");
|
||||
SyncLogger.Msg("SteamLobbyManager initialized");
|
||||
|
||||
SteamFriends.OnGameLobbyJoinRequested += (Lobby lobby, SteamId friend) =>
|
||||
{
|
||||
MelonLogger.Msg("Joining lobby " + lobby.Id);
|
||||
SyncLogger.Msg("Joining lobby " + lobby.Id);
|
||||
JoinLobby(lobby.Id.Value);
|
||||
};
|
||||
|
||||
SteamFriends.OnGameRichPresenceJoinRequested += (Friend friend, string connectString) =>
|
||||
{
|
||||
MelonLogger.Msg("Joining lobby " + connectString);
|
||||
SyncLogger.Msg("Joining lobby " + connectString);
|
||||
ulong lobbyId = ulong.Parse(connectString.Split(':')[1]);
|
||||
JoinLobby(lobbyId);
|
||||
};
|
||||
@@ -111,7 +112,7 @@ namespace BoneSync.Networking.LobbyManager
|
||||
public override void CreateLobby()
|
||||
{
|
||||
LeaveLobby();
|
||||
MelonLogger.Msg("Trying to create lobby");
|
||||
SyncLogger.Msg("Trying to create lobby");
|
||||
_ = SteamMatchmaking.CreateLobbyAsync(16);
|
||||
|
||||
}
|
||||
@@ -119,7 +120,7 @@ namespace BoneSync.Networking.LobbyManager
|
||||
public override void JoinLobby(ulong lobbyId)
|
||||
{
|
||||
LeaveLobby();
|
||||
MelonLogger.Msg("Trying to join lobby " + lobbyId);
|
||||
SyncLogger.Msg("Trying to join lobby " + lobbyId);
|
||||
_ = SteamMatchmaking.JoinLobbyAsync(lobbyId);
|
||||
}
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using BoneSync.Data;
|
||||
using BoneSync.Sync;
|
||||
using BoneSync.Sync.Components;
|
||||
using MelonLoader;
|
||||
@@ -42,7 +43,7 @@ namespace BoneSync.Networking.Messages
|
||||
syncable.DiscardSyncable(true, _data.despawn);
|
||||
} else
|
||||
{
|
||||
MelonLogger.Warning(senderId + " tried to discard a syncable that doesn't exist (syncId: " + _data.syncId + ")");
|
||||
SyncLogger.Warning(senderId + " tried to discard a syncable that doesn't exist (syncId: " + _data.syncId + ")");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -61,7 +61,7 @@ namespace BoneSync.Networking.Messages
|
||||
{
|
||||
Syncable syncable = ObjectSyncCache.GetSyncable(gunSyncInfo.syncId);
|
||||
if (syncable == null) return;
|
||||
//MelonLogger.Msg("GunSyncMessage.Execute: " + gunSyncInfo.syncId + ":" + syncable.name + " hasBulletObject: " + (gunSyncInfo.bulletObject != null));
|
||||
//SyncLogger.Msg("GunSyncMessage.Execute: " + gunSyncInfo.syncId + ":" + syncable.name + " hasBulletObject: " + (gunSyncInfo.bulletObject != null));
|
||||
syncable.OnWeaponSyncData(gunSyncInfo);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using BoneSync.Sync;
|
||||
using BoneSync.Data;
|
||||
using BoneSync.Sync;
|
||||
using BoneSync.Sync.Components;
|
||||
using MelonLoader;
|
||||
using StressLevelZero.Interaction;
|
||||
@@ -42,28 +43,28 @@ namespace BoneSync.Networking.Messages
|
||||
|
||||
public override void Execute()
|
||||
{
|
||||
//MelonLogger.Msg("Got PlugSyncMessage " + messageData.plugSyncId + ":" + messageData.plugIndex + " " + messageData.socketSyncId + ":" + messageData.socketIndex);
|
||||
//SyncLogger.Msg("Got PlugSyncMessage " + messageData.plugSyncId + ":" + messageData.plugIndex + " " + messageData.socketSyncId + ":" + messageData.socketIndex);
|
||||
Syncable plugSyncable = ObjectSyncCache.GetSyncable(messageData.plugSyncId);
|
||||
Syncable socketSyncable = ObjectSyncCache.GetSyncable(messageData.socketSyncId);
|
||||
|
||||
if (!plugSyncable || messageData.plugIndex == byte.MaxValue)
|
||||
{
|
||||
MelonLogger.Warning("PlugSyncable not found");
|
||||
SyncLogger.Warning("PlugSyncable not found");
|
||||
return;
|
||||
}
|
||||
AlignPlug plug = plugSyncable.GetPlugFromId(messageData.plugIndex);
|
||||
|
||||
if (plug == null) {
|
||||
MelonLogger.Warning("Plug not found, " + plugSyncable.transform.GetPath());
|
||||
SyncLogger.Warning("Plug not found, " + plugSyncable.transform.GetPath());
|
||||
return;
|
||||
}
|
||||
if (plug == null) {
|
||||
MelonLogger.Warning("Plug is not an AlignPlug");
|
||||
SyncLogger.Warning("Plug is not an AlignPlug");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!socketSyncable || messageData.socketIndex == byte.MaxValue) {
|
||||
MelonLogger.Warning("SocketSyncable not found");
|
||||
SyncLogger.Warning("SocketSyncable not found");
|
||||
plug.SafeEject();
|
||||
return;
|
||||
}
|
||||
@@ -71,12 +72,12 @@ namespace BoneSync.Networking.Messages
|
||||
Socket socket = socketSyncable.GetSocketFromId(messageData.socketIndex);
|
||||
if (socket == null)
|
||||
{
|
||||
MelonLogger.Warning("Unable to find socket from ID");
|
||||
SyncLogger.Warning("Unable to find socket from ID");
|
||||
plug.SafeEject();
|
||||
return;
|
||||
}
|
||||
|
||||
//MelonLogger.Msg("Inserting networked plug");
|
||||
//SyncLogger.Msg("Inserting networked plug");
|
||||
|
||||
plug.SafeInsert(socket);
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using BoneSync.Data;
|
||||
using BoneSync.Sync;
|
||||
using MelonLoader;
|
||||
using StressLevelZero.Utilities;
|
||||
@@ -67,7 +68,7 @@ namespace BoneSync.Networking.Messages
|
||||
|
||||
public override void Execute()
|
||||
{
|
||||
MelonLogger.Msg("SceneChangeMessage: " + _sceneChangeInfo.sceneName + " " + _sceneChangeInfo.sceneIndex);
|
||||
SyncLogger.Msg("SceneChangeMessage: " + _sceneChangeInfo.sceneName + " " + _sceneChangeInfo.sceneIndex);
|
||||
BoneworksSceneManager.LoadScene(_sceneChangeInfo.sceneIndex);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,9 +21,10 @@ namespace BoneSync.Networking.Messages
|
||||
public ushort syncId;
|
||||
public SimpleEventType eventType;
|
||||
public byte index;
|
||||
public byte length;
|
||||
//public object[] args;
|
||||
}
|
||||
[PacketType(PacketType.SimpleObjectEventSync)]
|
||||
[PacketType(PacketType.SimpleObjectEventSync), PacketReliability(PacketReliability.ReliableFast), PacketCatchup(20)]
|
||||
public class SimpleSyncableEventMessage : NetworkMessage
|
||||
{
|
||||
private SimpleSyncableEvent eventData;
|
||||
@@ -33,6 +34,7 @@ namespace BoneSync.Networking.Messages
|
||||
byteEncoder.WriteUShort(simpleSyncableEvent.syncId);
|
||||
byteEncoder.WriteByte((byte)simpleSyncableEvent.eventType);
|
||||
byteEncoder.WriteByte(simpleSyncableEvent.index);
|
||||
byteEncoder.WriteByte(simpleSyncableEvent.length);
|
||||
}
|
||||
|
||||
public SimpleSyncableEventMessage(Packet packet)
|
||||
@@ -41,6 +43,7 @@ namespace BoneSync.Networking.Messages
|
||||
eventData.syncId = byteEncoder.ReadUShort();
|
||||
eventData.eventType = (SimpleEventType)byteEncoder.ReadByte();
|
||||
eventData.index = byteEncoder.ReadByte();
|
||||
eventData.length = byteEncoder.ReadByte();
|
||||
}
|
||||
|
||||
public override void Execute()
|
||||
|
||||
@@ -142,7 +142,7 @@ namespace BoneSync.Networking
|
||||
}
|
||||
public static NetworkMessage ParsePacket(Packet packet)
|
||||
{
|
||||
//MelonLogger.Msg("Received packet of type " + packet.Info.packetType + " from " + packet.Info.senderId + " Length: " + packet.Data.Length);
|
||||
//SyncLogger.Msg("Received packet of type " + packet.Info.packetType + " from " + packet.Info.senderId + " Length: " + packet.Data.Length);
|
||||
// find a class that can parse this packet using Reflection
|
||||
// and return it
|
||||
if (!PacketTypeMap.ContainsKey(packet.Info.packetType))
|
||||
@@ -179,7 +179,7 @@ namespace BoneSync.Networking
|
||||
{
|
||||
if (BoneSync.IsConnected == false)
|
||||
{
|
||||
MelonLogger.Warning("Cannot send packet, not connected to lobby");
|
||||
SyncLogger.Warning("Cannot send packet, not connected to lobby");
|
||||
return;
|
||||
}
|
||||
ulong senderId = BoneSync.lobby.GetLocalId();
|
||||
@@ -189,7 +189,7 @@ namespace BoneSync.Networking
|
||||
|
||||
public virtual void Execute()
|
||||
{
|
||||
MelonLogger.Warning("Execute not implemented for " + GetType().Name);
|
||||
SyncLogger.Warning("Execute not implemented for " + GetType().Name);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -146,7 +146,7 @@ namespace BoneSync.Networking
|
||||
{
|
||||
bool addToQueue = networkMessage.GetCatchupOrder() > 0;
|
||||
if (!addToQueue) return false;
|
||||
MelonLogger.Msg("Adding packet to queue for scene " + packet._packetInfo.sceneIndex);
|
||||
SyncLogger.Msg("Adding packet to queue for scene " + packet._packetInfo.sceneIndex);
|
||||
EnsureQueueForScene(packet._packetInfo.sceneIndex);
|
||||
_packetQueues[packet._packetInfo.sceneIndex].Enqueue(networkMessage);
|
||||
return true;
|
||||
@@ -178,7 +178,7 @@ namespace BoneSync.Networking
|
||||
}
|
||||
if (processed > 0)
|
||||
{
|
||||
MelonLogger.Msg("Processed " + processed + " queued packets for scene " + sceneIndex);
|
||||
SyncLogger.Msg("Processed " + processed + " queued packets for scene " + sceneIndex);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ namespace BoneSync.Networking.Transport
|
||||
private List<SteamId> OpenP2PConnections = new List<SteamId>();
|
||||
private void OnP2PSessionRequest(SteamId steamId)
|
||||
{
|
||||
MelonLogger.Msg("P2P Request from " + steamId);
|
||||
SyncLogger.Msg("P2P Request from " + steamId);
|
||||
if (BoneSync.lobby.GetPeers().Contains(steamId))
|
||||
{
|
||||
SteamNetworking.AcceptP2PSessionWithUser(steamId);
|
||||
@@ -92,7 +92,7 @@ namespace BoneSync.Networking.Transport
|
||||
|
||||
if (peer == BoneSync.lobby.GetLocalId())
|
||||
{
|
||||
//MelonLogger.Msg("Trying to send packet to self");
|
||||
//SyncLogger.Msg("Trying to send packet to self");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -115,7 +115,7 @@ namespace BoneSync.Networking.Transport
|
||||
LobbyManager.LobbyManager _instance = BoneSync.lobby;
|
||||
if (_instance == null)
|
||||
{
|
||||
MelonLogger.Msg("Lobby instance is null");
|
||||
SyncLogger.Msg("Lobby instance is null");
|
||||
return;
|
||||
}
|
||||
if (packet.Info.receiverId == BORADCAST_ID)
|
||||
|
||||
@@ -8,37 +8,67 @@ using BoneSync.Sync.Components;
|
||||
using HarmonyLib;
|
||||
using MelonLoader;
|
||||
using StressLevelZero.Interaction;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Events;
|
||||
|
||||
namespace BoneSync.Patching
|
||||
{
|
||||
public class UnityEventPatch<T>
|
||||
{
|
||||
private static Dictionary<int, UnityEventPatch<T>> patches = new Dictionary<int, UnityEventPatch<T>>();
|
||||
|
||||
private T arg;
|
||||
private UnityEvent unityEvent;
|
||||
private Action<T> handler;
|
||||
private UnityEventPatch(T arg, UnityEvent unityEvent, Action<T> handler)
|
||||
private Func<T, bool> handler;
|
||||
//private UnityAction listener;
|
||||
//private float lastInvokeTime = 0f;
|
||||
//private float invokeCooldown = 0.05f;
|
||||
private UnityEventPatch(T arg, UnityEvent unityEvent, Func<T, bool> handler)
|
||||
{
|
||||
this.arg = arg;
|
||||
this.unityEvent = unityEvent;
|
||||
this.handler = handler;
|
||||
|
||||
//listener = (UnityAction)Listener;
|
||||
}
|
||||
|
||||
private void Listener()
|
||||
public bool TryInvoke()
|
||||
{
|
||||
handler(arg);
|
||||
bool allowInvokeResult = handler(arg);
|
||||
Debug.Log("TryInvoke " + allowInvokeResult);
|
||||
return allowInvokeResult;
|
||||
}
|
||||
|
||||
private void PatchUnityEvent()
|
||||
{
|
||||
if (unityEvent == null) return;
|
||||
unityEvent.AddListener((UnityAction)Listener);
|
||||
patches[unityEvent.GetHashCode()] = this;
|
||||
//unityEvent.AddListener(listener);
|
||||
|
||||
}
|
||||
|
||||
public static void Patch(T arg, UnityEvent unityEvent, Action<T> handler)
|
||||
private void UnpatchUnityEvent()
|
||||
{
|
||||
if (unityEvent == null) return;
|
||||
patches.Remove(unityEvent.GetHashCode());
|
||||
}
|
||||
|
||||
public static UnityEventPatch<T> Patch(T arg, UnityEvent unityEvent, Func<T, bool> handler)
|
||||
{
|
||||
if (patches.TryGetValue(unityEvent.GetHashCode(), out UnityEventPatch<T> oldPatch))
|
||||
{
|
||||
oldPatch.UnpatchUnityEvent();
|
||||
}
|
||||
UnityEventPatch<T> patch = new UnityEventPatch<T>(arg, unityEvent, handler);
|
||||
patch.PatchUnityEvent();
|
||||
|
||||
return patch;
|
||||
}
|
||||
|
||||
public static UnityEventPatch<T> TryGetPatch(UnityEvent unityEvent)
|
||||
{
|
||||
if (!patches.ContainsKey(unityEvent.GetHashCode())) return null;
|
||||
return patches[unityEvent.GetHashCode()];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -51,4 +81,20 @@ namespace BoneSync.Patching
|
||||
Syncable syncable = ObjectSync.MakeOrGetSyncable(__instance);
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(UnityEvent))]
|
||||
internal class UnityEventPatches
|
||||
{
|
||||
[HarmonyPatch(nameof(UnityEvent.Invoke)), HarmonyPrefix]
|
||||
private static bool InvokePrefix(UnityEvent __instance)
|
||||
{
|
||||
int hash = __instance.GetHashCode();
|
||||
UnityEventPatch<ButtonToggle> patch = UnityEventPatch<ButtonToggle>.TryGetPatch(__instance);
|
||||
if (patch != null)
|
||||
{
|
||||
return patch.TryInvoke();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Events;
|
||||
|
||||
namespace BoneSync.Patching
|
||||
{
|
||||
@@ -39,6 +40,13 @@ namespace BoneSync.Patching
|
||||
allowPatchedMethodCall = false;
|
||||
}
|
||||
|
||||
public static void BypassPatchInvoke(this UnityEvent e)
|
||||
{
|
||||
allowPatchedMethodCall = true;
|
||||
e.Invoke();
|
||||
allowPatchedMethodCall = false;
|
||||
}
|
||||
|
||||
public static Poolee InstantiatePoolee(Pool pool, Vector3 position, Quaternion rotation, Vector3 scale)
|
||||
{
|
||||
allowPatchedMethodCall = true;
|
||||
|
||||
@@ -18,7 +18,7 @@ namespace BoneSync.Patching
|
||||
[HarmonyPatch(nameof(PoolSpawner.SpawnProjectile)), HarmonyPrefix]
|
||||
private static void SpawnProjectilePrefix(Vector3 position, Quaternion rotation, BulletObject bulletObject, string weaponName, TriggerRefProxy proxy)
|
||||
{
|
||||
MelonLoader.MelonLogger.Msg("PoolSpawner.SpawnProjectile " + weaponName);
|
||||
MelonLoader.SyncLogger.Msg("PoolSpawner.SpawnProjectile " + weaponName);
|
||||
}
|
||||
}*/
|
||||
|
||||
|
||||
@@ -25,12 +25,12 @@ namespace BoneSync.Patching
|
||||
if (!(__instance.pullCoroutine != null && !__state))
|
||||
return;
|
||||
|
||||
MelonLogger.Msg("ForcePullGrip.OnFarHandHoverUpdate: " + __instance.name + " Hand: " + hand.name);
|
||||
SyncLogger.Msg("ForcePullGrip.OnFarHandHoverUpdate: " + __instance.name + " Hand: " + hand.name);
|
||||
|
||||
InteractableHost interactableHost = __instance?.grip?.host;
|
||||
if (interactableHost == null)
|
||||
{
|
||||
MelonLogger.Error("InteractableHost is null for " + __instance.name);
|
||||
SyncLogger.Error("InteractableHost is null for " + __instance.name);
|
||||
return;
|
||||
}
|
||||
Syncable syncable = ObjectSync.MakeOrGetSyncable(interactableHost);
|
||||
|
||||
@@ -26,7 +26,7 @@ namespace BoneSync.Patching
|
||||
[HarmonyPatch(nameof(Gun.OnFire)), HarmonyPrefix]
|
||||
public static void OnFirePatch(Gun __instance)
|
||||
{
|
||||
MelonLoader.MelonLogger.Msg("Gun.OnFire: " + __instance.name);
|
||||
MelonLoader.SyncLogger.Msg("Gun.OnFire: " + __instance.name);
|
||||
if (!BoneSync.IsConnected) return;
|
||||
|
||||
Syncable syncable = ObjectSync.MakeOrGetSyncable(__instance.gameObject);
|
||||
@@ -34,7 +34,7 @@ namespace BoneSync.Patching
|
||||
if (!syncable.Registered) return;
|
||||
if (syncable.isOwner)
|
||||
{
|
||||
MelonLogger.Msg("Gun.OnFire: " + __instance.name + " is owner");
|
||||
SyncLogger.Msg("Gun.OnFire: " + __instance.name + " is owner");
|
||||
GunSyncInfo gunSyncInfo = new GunSyncInfo()
|
||||
{
|
||||
cartridgeState = __instance.cartridgeState,
|
||||
@@ -46,7 +46,7 @@ namespace BoneSync.Patching
|
||||
|
||||
GunSyncMessage gunSyncMessage = new GunSyncMessage(gunSyncInfo);
|
||||
gunSyncMessage.Broadcast();
|
||||
MelonLogger.Msg("Gun.OnFire: " + __instance.name + " sent message");
|
||||
SyncLogger.Msg("Gun.OnFire: " + __instance.name + " sent message");
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -18,11 +18,11 @@ namespace BoneSync.Patching
|
||||
[HarmonyPatch(nameof(HandWeaponSlotReciever.MakeStatic)), HarmonyPrefix]
|
||||
public static void StaticPatch(HandWeaponSlotReciever __instance)
|
||||
{
|
||||
MelonLogger.Msg("HandWeaponSlotReciever.MakeStatic: " + __instance.name);
|
||||
SyncLogger.Msg("HandWeaponSlotReciever.MakeStatic: " + __instance.name);
|
||||
InteractableHost interactableHost = __instance.m_WeaponHost;
|
||||
if (interactableHost == null)
|
||||
{
|
||||
MelonLogger.Error("InteractableHost is null for " + __instance.transform.GetPath());
|
||||
SyncLogger.Error("InteractableHost is null for " + __instance.transform.GetPath());
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -33,11 +33,11 @@ namespace BoneSync.Patching
|
||||
[HarmonyPatch(nameof(HandWeaponSlotReciever.MakeDynamic)), HarmonyPrefix]
|
||||
public static void DynamicPatch(HandWeaponSlotReciever __instance)
|
||||
{
|
||||
MelonLogger.Msg("HandWeaponSlotReciever.MakeDynamic: " + __instance.name);
|
||||
SyncLogger.Msg("HandWeaponSlotReciever.MakeDynamic: " + __instance.name);
|
||||
InteractableHost interactableHost = __instance.m_WeaponHost;
|
||||
if (interactableHost == null)
|
||||
{
|
||||
MelonLogger.Error("InteractableHost is null for " + __instance.transform.GetPath());
|
||||
SyncLogger.Error("InteractableHost is null for " + __instance.transform.GetPath());
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ namespace BoneSync.Patching
|
||||
[HarmonyPatch(nameof(InteractableHost.OnEnable)), HarmonyPostfix]
|
||||
public static void OnEnablePatch(InteractableHost __instance)
|
||||
{
|
||||
//MelonLoader.MelonLogger.Msg("InteractableHost enabled: " + __instance.name + " Manager: " + __instance?.manager?.name);
|
||||
//MelonLoader.SyncLogger.Msg("InteractableHost enabled: " + __instance.name + " Manager: " + __instance?.manager?.name);
|
||||
Syncable syncable = ObjectSync.MakeOrGetSyncable(__instance);
|
||||
|
||||
}
|
||||
@@ -26,11 +26,11 @@ namespace BoneSync.Patching
|
||||
[HarmonyPatch(nameof(InteractableHost.AttachHand)), HarmonyPostfix]
|
||||
public static void AttachHandPatch(InteractableHost __instance, Hand hand)
|
||||
{
|
||||
MelonLogger.Msg("InteractableHost attached to hand: " + __instance.name + " Hand: " + hand.name);
|
||||
SyncLogger.Msg("InteractableHost attached to hand: " + __instance.name + " Hand: " + hand.name);
|
||||
Syncable syncable = ObjectSync.MakeOrGetSyncable(__instance);
|
||||
if (syncable == null)
|
||||
{
|
||||
MelonLogger.Error("Syncable is null for " + __instance.name);
|
||||
SyncLogger.Error("Syncable is null for " + __instance.name);
|
||||
return;
|
||||
}
|
||||
syncable.RegisterSyncable();
|
||||
@@ -40,7 +40,7 @@ namespace BoneSync.Patching
|
||||
/*[HarmonyPatch(nameof(InteractableHost.AddForcePullGrip)), HarmonyPostfix]
|
||||
public static void AddForcePullGripPatch(InteractableHost __instance, ForcePullGrip grip)
|
||||
{
|
||||
MelonLoader.MelonLogger.Msg("AddForcePullGrip to hand: " + __instance.name + " Hand: " + grip.name);
|
||||
MelonLoader.SyncLogger.Msg("AddForcePullGrip to hand: " + __instance.name + " Hand: " + grip.name);
|
||||
}*/
|
||||
|
||||
}
|
||||
@@ -51,7 +51,7 @@ namespace BoneSync.Patching
|
||||
[HarmonyPatch(nameof(InteractableHostManager.Start)), HarmonyPostfix]
|
||||
public static void OnEnablePatch(InteractableHostManager __instance)
|
||||
{
|
||||
MelonLoader.MelonLogger.Msg("InteractableHostManager started: " + __instance.transform.GetPath());
|
||||
MelonLoader.SyncLogger.Msg("InteractableHostManager started: " + __instance.transform.GetPath());
|
||||
ObjectSync.MakeOrGetSyncable(__instance);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,13 +26,13 @@ namespace BoneSync.Patching
|
||||
if (CallPatchedMethods.allowPatchedMethodCall) return true;
|
||||
if (!BoneSync.IsConnected) return true;
|
||||
if (damage < 0.05f) return true; // ignore small damage (e.g. a little bit of fall damage)
|
||||
//MelonLoader.MelonLogger.Msg("ObjectDestructable.TakeDamage: " + damage);
|
||||
//MelonLoader.SyncLogger.Msg("ObjectDestructable.TakeDamage: " + damage);
|
||||
Syncable syncable = ObjectSync.MakeOrGetSyncable(__instance.gameObject);
|
||||
if (syncable != null)
|
||||
{
|
||||
if (damage > 0.5f) syncable.RegisterSyncable(); // register syncable if damage is very significant, e.g. a bullet hit
|
||||
if (syncable.Registered && !syncable.isOwner) return false;
|
||||
//MelonLoader.MelonLogger.Msg("Patch: ObjectDestructable.TakeDamage: " + damage + " " + syncable.gameObject.name);
|
||||
//MelonLoader.SyncLogger.Msg("Patch: ObjectDestructable.TakeDamage: " + damage + " " + syncable.gameObject.name);
|
||||
ObjectHealthInfo objectHealthInfo = new ObjectHealthInfo(__instance._health, __instance._hits, normal, damage, crit, attackType);
|
||||
|
||||
ObjectSync.SendObjectDamageMessage(syncable, ObjectDamageType.DestructibleTakeDamage, objectHealthInfo);
|
||||
@@ -67,13 +67,13 @@ namespace BoneSync.Patching
|
||||
{
|
||||
if (CallPatchedMethods.allowPatchedMethodCall) return true;
|
||||
if (!BoneSync.IsConnected) return true;
|
||||
//MelonLoader.MelonLogger.Msg("Prop_Health.TAKEDAMAGE: " + damage);
|
||||
//MelonLoader.SyncLogger.Msg("Prop_Health.TAKEDAMAGE: " + damage);
|
||||
Syncable syncable = ObjectSync.MakeOrGetSyncable(__instance.gameObject);
|
||||
if (syncable != null)
|
||||
{
|
||||
if (damage > 0.5f) syncable.RegisterSyncable();
|
||||
if (syncable.Registered && !syncable.isOwner) return false;
|
||||
//MelonLoader.MelonLogger.Msg("Patch: Prop_Health.TAKEDAMAGE: " + damage + " " + syncable.gameObject.name);
|
||||
//MelonLoader.SyncLogger.Msg("Patch: Prop_Health.TAKEDAMAGE: " + damage + " " + syncable.gameObject.name);
|
||||
ObjectHealthInfo objectHealthInfo = new ObjectHealthInfo(__instance.cur_Health, __instance.hits, Vector3.zero, damage, crit, attackType);
|
||||
|
||||
ObjectSync.SendObjectDamageMessage(syncable, ObjectDamageType.PropHealthTakeDamage, objectHealthInfo);
|
||||
|
||||
@@ -9,7 +9,7 @@ using BoneSync.Sync.Components;
|
||||
using HarmonyLib;
|
||||
using MelonLoader;
|
||||
using StressLevelZero.Interaction;
|
||||
using static MelonLoader.MelonLogger;
|
||||
using static MelonLoader.SyncLogger;
|
||||
|
||||
namespace BoneSync.Patching
|
||||
{
|
||||
@@ -24,7 +24,7 @@ namespace BoneSync.Patching
|
||||
|
||||
if (!plugSyncable)
|
||||
{
|
||||
MelonLogger.Warning("PlugSyncable not found");
|
||||
SyncLogger.Warning("PlugSyncable not found");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -32,13 +32,13 @@ namespace BoneSync.Patching
|
||||
|
||||
if (!plugSyncable.Registered)
|
||||
{
|
||||
MelonLogger.Warning("PlugSyncable not registered");
|
||||
SyncLogger.Warning("PlugSyncable not registered");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!socketSyncable)
|
||||
{
|
||||
MelonLogger.Warning("SocketSyncable not found");
|
||||
SyncLogger.Warning("SocketSyncable not found");
|
||||
} else
|
||||
{
|
||||
socketSyncable.FindAndUpdateComponents();
|
||||
@@ -54,7 +54,7 @@ namespace BoneSync.Patching
|
||||
byte plugId = plugSyncable.GetPlugId(plug);
|
||||
byte socketId = socketSyncable != null ? socketSyncable.GetSocketId(socket) : byte.MaxValue;
|
||||
|
||||
//MelonLogger.Msg("AlignPlug state:" + plug.transform.GetPath() + " Socket:" + socket?.transform?.GetPath() + " PlugID:" + plugId + " SocketID:" + socketId);
|
||||
//SyncLogger.Msg("AlignPlug state:" + plug.transform.GetPath() + " Socket:" + socket?.transform?.GetPath() + " PlugID:" + plugId + " SocketID:" + socketId);
|
||||
|
||||
if (!plugSyncable.isOwner) return;
|
||||
|
||||
@@ -75,7 +75,7 @@ namespace BoneSync.Patching
|
||||
[HarmonyPatch(nameof(AlignPlug.OnPlugExitComplete)), HarmonyPostfix]
|
||||
public static void AlignPlugEjectPatch(AlignPlug __instance)
|
||||
{
|
||||
MelonLogger.Msg("AlignPlug ejected: " + __instance.transform.GetPath());
|
||||
SyncLogger.Msg("AlignPlug ejected: " + __instance.transform.GetPath());
|
||||
OnPlugSocketChange(__instance, null);
|
||||
}*/
|
||||
|
||||
@@ -87,14 +87,14 @@ namespace BoneSync.Patching
|
||||
[HarmonyPatch(nameof(MagazinePlug.OnPlugInsertComplete)), HarmonyPostfix]
|
||||
public static void MagazinePlugInsertPatch(MagazinePlug __instance)
|
||||
{
|
||||
MelonLogger.Msg("MagazinePlug inserted: " + __instance.transform.GetPath());
|
||||
SyncLogger.Msg("MagazinePlug inserted: " + __instance.transform.GetPath());
|
||||
AlignPlugPatches.OnPlugSocketChange(__instance, __instance.GetSocket());
|
||||
}
|
||||
|
||||
[HarmonyPatch(nameof(MagazinePlug.OnPlugExitComplete)), HarmonyPostfix]
|
||||
public static void MagazinePlugEjectPatch(MagazinePlug __instance)
|
||||
{
|
||||
MelonLogger.Msg("MagazinePlug ejected: " + __instance.transform.GetPath());
|
||||
SyncLogger.Msg("MagazinePlug ejected: " + __instance.transform.GetPath());
|
||||
AlignPlugPatches.OnPlugSocketChange(__instance, null);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using BoneSync.Data;
|
||||
using BoneSync.Networking.Messages;
|
||||
using BoneSync.Sync;
|
||||
using BoneSync.Sync.Components;
|
||||
@@ -77,7 +78,7 @@ namespace BoneSync.Patching
|
||||
if (CallPatchedMethods.allowPatchedMethodCall) return;
|
||||
if (__instance == null) return;
|
||||
if (PoolBlacklist.isBlacklistedPool(__instance)) return;
|
||||
//MelonLogger.Msg("Patched Instantiating object in pool: " + __instance.name);
|
||||
//SyncLogger.Msg("Patched Instantiating object in pool: " + __instance.name);
|
||||
__result.onSpawnDelegate = Il2CppSystem.Delegate.Combine(__result.onSpawnDelegate, (Il2CppSystem.Action<GameObject>)((g) => { PooleePatches.OnSpawnPatchPost(__result); })).Cast<Il2CppSystem.Action<GameObject>>();
|
||||
__result.onDespawnDelegate = Il2CppSystem.Delegate.Combine(__result.onDespawnDelegate, (Il2CppSystem.Action<GameObject>)((g) => { PooleePatches.OnDespawnPatchPost(__result); })).Cast<Il2CppSystem.Action<GameObject>>();
|
||||
|
||||
@@ -94,7 +95,7 @@ namespace BoneSync.Patching
|
||||
if (PoolBlacklist.isBlacklistedPool(__instance)) return;
|
||||
if (BoneSync.IsConnected)
|
||||
{
|
||||
MelonLogger.Msg("Patched Spawning object in pool: " + __instance.name);
|
||||
SyncLogger.Msg("Patched Spawning object in pool: " + __instance.name);
|
||||
bool isHost = BoneSync.lobby.IsHost;
|
||||
if (!isHost) GameObject.DestroyImmediate(__result);
|
||||
}
|
||||
@@ -110,7 +111,7 @@ namespace BoneSync.Patching
|
||||
if (PoolBlacklist.isBlacklistedPool(__instance)) return true;
|
||||
if (BoneSync.IsConnected)
|
||||
{
|
||||
MelonLogger.Msg("Patched Spawning object in pool: " + __instance.name);
|
||||
SyncLogger.Msg("Patched Spawning object in pool: " + __instance.name);
|
||||
return BoneSync.lobby.IsHost; // only allow host to spawn objects naturally
|
||||
}
|
||||
__instance.
|
||||
@@ -128,12 +129,14 @@ namespace BoneSync.Patching
|
||||
if (CallPatchedMethods.allowPatchedMethodCall) return;
|
||||
if (!BoneSync.IsConnected) return;
|
||||
|
||||
MelonLogger.Msg("Poolee.OnSpawn: " + __instance.gameObject.transform.GetPath());
|
||||
SyncLogger.Msg("Poolee.OnSpawn: " + __instance.gameObject.transform.GetPath());
|
||||
|
||||
Syncable syncable = ObjectSync.MakeOrGetSyncable(__instance);
|
||||
|
||||
bool spawnNormally = BoneSync.lobby.IsHost || PoolBlacklist.IsClientSpawnPool(__instance.pool);
|
||||
|
||||
SyncLogger.Msg("Poolee.OnSpawn: " + __instance.gameObject.transform.GetPath() + " syncid:" + syncable?.GetSyncId() + " spawnNormally" + spawnNormally);
|
||||
|
||||
if (!spawnNormally) {
|
||||
MelonCoroutines.Start(OnSpawnClient(__instance)); // block object from spawning
|
||||
return;
|
||||
@@ -141,7 +144,10 @@ namespace BoneSync.Patching
|
||||
|
||||
if (syncable == null) return;
|
||||
|
||||
//MelonLogger.Msg("Poolee.OnSpawn: " + __instance.gameObject.transform.GetPath() + " " + syncable.GetSyncId());
|
||||
//
|
||||
//
|
||||
//
|
||||
//.Msg("Poolee.OnSpawn: " + __instance.gameObject.transform.GetPath() + " " + syncable.GetSyncId());
|
||||
|
||||
|
||||
}
|
||||
@@ -151,7 +157,7 @@ namespace BoneSync.Patching
|
||||
if (CallPatchedMethods.allowPatchedMethodCall) return;
|
||||
if (!BoneSync.IsConnected) return;
|
||||
|
||||
MelonLogger.Msg("Poolee.OnDespawn: " + __instance.gameObject.transform.GetPath());
|
||||
SyncLogger.Msg("Poolee.OnDespawn: " + __instance.gameObject.transform.GetPath());
|
||||
|
||||
//Syncable syncable = ObjectSync.MakeOrGetSyncable(__instance);
|
||||
|
||||
|
||||
56
BoneSync/Patching/PrefabSpawnerPatches.cs
Normal file
56
BoneSync/Patching/PrefabSpawnerPatches.cs
Normal file
@@ -0,0 +1,56 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using BoneSync.Data;
|
||||
using BoneSync.Sync;
|
||||
using BoneSync.Sync.Components;
|
||||
using HarmonyLib;
|
||||
using MelonLoader;
|
||||
using StressLevelZero.Data;
|
||||
using StressLevelZero.Pool;
|
||||
using UnityEngine;
|
||||
using static StressLevelZero.VFX.ParticleSpreadManager;
|
||||
|
||||
namespace BoneSync.Patching
|
||||
{
|
||||
[HarmonyPatch(typeof(PrefabSpawner))]
|
||||
internal class PrefabSpawnerPatches
|
||||
{
|
||||
[HarmonyPatch(nameof(PrefabSpawner.SpawnPrefab), new Type[] { typeof(Transform), typeof(Vector3), typeof(Quaternion) }), HarmonyPrefix]
|
||||
private static bool SpawnPrefabPrefix(PrefabSpawner __instance, Transform AttachTo, Vector3 Position, Quaternion Rotation)
|
||||
{
|
||||
if (!BoneSync.IsConnected) return true;
|
||||
if (!BoneSync.lobby.IsHost) return false;
|
||||
|
||||
Syncable syncable = SpawnPrefabSyncable(__instance, AttachTo, Position, Rotation);
|
||||
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
[HarmonyPatch(nameof(PrefabSpawner.SpawnPrefab), new Type[] { }), HarmonyPrefix]
|
||||
private static bool SpawnPrefabSimplePrefix(PrefabSpawner __instance)
|
||||
{
|
||||
return SpawnPrefabPrefix(__instance, null, __instance.transform.position, __instance.transform.rotation);
|
||||
}
|
||||
|
||||
public static Syncable SpawnPrefabSyncable(PrefabSpawner __instance, Transform AttachTo, Vector3 Position, Quaternion Rotation)
|
||||
{
|
||||
SyncLogger.Msg("Spawning prefab: " + __instance.Prefab.name);
|
||||
SpawnableObject spawnable = SpawnableManager.GetSpawnableByPrefabName(__instance.Prefab.name);
|
||||
if (spawnable == null)
|
||||
{
|
||||
SyncLogger.Error("Spawnable not found for prefab: " + __instance.Prefab.name);
|
||||
return null;
|
||||
}
|
||||
|
||||
Poolee poolee = SpawnableManager.SpawnPoolee(spawnable, Position, Rotation);
|
||||
Syncable syncable = ObjectSync.MakeOrGetSyncable(poolee);
|
||||
syncable.RegisterSyncable();
|
||||
|
||||
return syncable;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -16,11 +16,11 @@ namespace BoneSync.Patching
|
||||
/*[HarmonyPatch(nameof(BoneworksSceneManager.LoadScene)), HarmonyPostfix]
|
||||
private static void LoadScenePrefix(int sceneBuildIndex)
|
||||
{
|
||||
MelonLogger.Msg("LoadScenePrefix: " + sceneBuildIndex);
|
||||
SyncLogger.Msg("LoadScenePrefix: " + sceneBuildIndex);
|
||||
if (!BoneSync.IsConnected) return;
|
||||
if (BoneSync.lobby.IsHost)
|
||||
{
|
||||
MelonLogger.Msg("Host is loading scene, sending message to clients...");
|
||||
SyncLogger.Msg("Host is loading scene, sending message to clients...");
|
||||
SceneSync.SendSceneSyncMessage(sceneBuildIndex);
|
||||
}
|
||||
}*/
|
||||
|
||||
@@ -30,19 +30,19 @@ namespace BoneSync.Patching
|
||||
|
||||
if (PlayerScripts.playerHandPoses == null)
|
||||
{
|
||||
MelonLogger.Error("PlayerScripts.playerHandPoses is null!");
|
||||
SyncLogger.Error("PlayerScripts.playerHandPoses is null!");
|
||||
return 0;
|
||||
}
|
||||
if (PlayerScripts.playerHandPoses.Count == 0)
|
||||
{
|
||||
MelonLogger.Msg("PlayerScripts.playerHandPoses is empty, getting hand poses...");
|
||||
SyncLogger.Msg("PlayerScripts.playerHandPoses is empty, getting hand poses...");
|
||||
PlayerScripts.GetHandPoses();
|
||||
}
|
||||
|
||||
bool found = PlayerScripts.playerHandPoses.Contains(handPoseName);
|
||||
if (!found)
|
||||
{
|
||||
//MelonLogger.Error($"Hand pose {handPoseName} not found in playerHandPoses!");
|
||||
//SyncLogger.Error($"Hand pose {handPoseName} not found in playerHandPoses!");
|
||||
return 0;
|
||||
}
|
||||
byte index = (byte)PlayerScripts.playerHandPoses.IndexOf(handPoseName);
|
||||
@@ -55,7 +55,7 @@ namespace BoneSync.Patching
|
||||
private static void SetHandPosePostfix(SkeletonHand __instance, string handPoseName)
|
||||
{
|
||||
if (!__instance.GetCharacterAnimationManager()) return;
|
||||
MelonLogger.Msg($"SetHandPosePostfix: {handPoseName}");
|
||||
SyncLogger.Msg($"SetHandPosePostfix: {handPoseName}");
|
||||
|
||||
int poseIndex = GetHandPoseIndex(handPoseName);
|
||||
switch (__instance.handedness)
|
||||
@@ -75,18 +75,18 @@ namespace BoneSync.Patching
|
||||
{
|
||||
if (!__instance.GetCharacterAnimationManager()) return;
|
||||
|
||||
//MelonLogger.Msg($"SetCylinderRadiusPrefix: {radius}");
|
||||
//SyncLogger.Msg($"SetCylinderRadiusPrefix: {radius}");
|
||||
|
||||
switch (__instance.handedness)
|
||||
{
|
||||
case Handedness.LEFT:
|
||||
if (radiusLeft == radius) return;
|
||||
MelonLogger.Msg($"SetCylinderRadiusPrefixLeft: {radius}");
|
||||
SyncLogger.Msg($"SetCylinderRadiusPrefixLeft: {radius}");
|
||||
radiusLeft = radius;
|
||||
break;
|
||||
case Handedness.RIGHT:
|
||||
if (radiusRight == radius) return;
|
||||
MelonLogger.Msg($"SetCylinderRadiusPrefixRight: {radius}");
|
||||
SyncLogger.Msg($"SetCylinderRadiusPrefixRight: {radius}");
|
||||
radiusRight = radius;
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -3,11 +3,10 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using BoneSync.Data;
|
||||
using BoneSync.Player;
|
||||
using BoneSync.Sync.Components;
|
||||
using HarmonyLib;
|
||||
using MelonLoader;
|
||||
using StressLevelZero.Pool;
|
||||
using StressLevelZero.Zones;
|
||||
using UnityEngine;
|
||||
|
||||
@@ -23,7 +22,11 @@ namespace BoneSync.Patching
|
||||
{
|
||||
if (!BoneSync.IsConnected) return true; // do not block if not connected
|
||||
|
||||
//MelonLogger.Msg("ZoneSpawner.Spawn: " + __instance.transform.GetPath());
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
//.Msg("ZoneSpawner.Spawn: " + __instance.transform.GetPath());
|
||||
|
||||
if (BoneSync.lobby.IsHost)
|
||||
{
|
||||
@@ -43,7 +46,7 @@ namespace BoneSync.Patching
|
||||
{
|
||||
if (!BoneSync.IsConnected) return true;
|
||||
|
||||
MelonLogger.Msg("ZoneEncounter.StartEncounter: " + __instance.transform.GetPath());
|
||||
SyncLogger.Msg("ZoneEncounter.StartEncounter: " + __instance.transform.GetPath());
|
||||
|
||||
if (BoneSync.lobby.IsHost)
|
||||
{
|
||||
@@ -59,7 +62,7 @@ namespace BoneSync.Patching
|
||||
[HarmonyPatch(typeof(SceneZone))]
|
||||
public static class SceneZonePatch
|
||||
{
|
||||
[HarmonyPatch(nameof(SceneZone.OnTriggerEnter)), HarmonyPrefix]
|
||||
/*[HarmonyPatch(nameof(SceneZone.OnTriggerEnter)), HarmonyPrefix]
|
||||
public static bool EnterPrefix(SceneZone __instance, Collider other)
|
||||
{
|
||||
if (other.CompareTag("Player"))
|
||||
@@ -69,7 +72,7 @@ namespace BoneSync.Patching
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
*/
|
||||
[HarmonyPatch(nameof(SceneZone.OnTriggerExit)), HarmonyPrefix]
|
||||
public static bool ExitPrefix(SceneZone __instance, Collider other)
|
||||
{
|
||||
@@ -85,7 +88,7 @@ namespace BoneSync.Patching
|
||||
[HarmonyPatch(typeof(PlayerTrigger))]
|
||||
public static class PlayerTriggerPatch
|
||||
{
|
||||
[HarmonyPatch(nameof(PlayerTrigger.OnTriggerEnter)), HarmonyPrefix]
|
||||
/*[HarmonyPatch(nameof(PlayerTrigger.OnTriggerEnter)), HarmonyPrefix]
|
||||
public static bool EnterPrefix(PlayerTrigger __instance, Collider other)
|
||||
{
|
||||
if (other.CompareTag("Player"))
|
||||
@@ -95,8 +98,9 @@ namespace BoneSync.Patching
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}*/
|
||||
|
||||
// only patch exit, as we want to allow activating a trigger always
|
||||
[HarmonyPatch(nameof(PlayerTrigger.OnTriggerExit)), HarmonyPrefix]
|
||||
public static bool ExitPrefix(PlayerTrigger __instance, Collider other)
|
||||
{
|
||||
|
||||
@@ -50,7 +50,7 @@ namespace BoneSync.Player
|
||||
throw new NullReferenceException("playerRepBundle is null! Did you forget to compile the player bundle into the dll?");
|
||||
|
||||
|
||||
MelonLogger.Msg("Loaded playerRepBundle success");
|
||||
SyncLogger.Msg("Loaded playerRepBundle success");
|
||||
}
|
||||
|
||||
public static void Tick()
|
||||
@@ -79,7 +79,7 @@ namespace BoneSync.Player
|
||||
public void UpdatePlayerSync(PlayerSyncInfo playerSyncInfo)
|
||||
{
|
||||
EnsurePlayerRig();
|
||||
//MelonLogger.Msg("Updating player sync for " + _ownerId);
|
||||
//SyncLogger.Msg("Updating player sync for " + _ownerId);
|
||||
playerRig.transform.position = playerSyncInfo.rootPos;
|
||||
|
||||
headTransform.ApplySimpleTransform(playerSyncInfo.headPos);
|
||||
@@ -132,14 +132,14 @@ namespace BoneSync.Player
|
||||
|
||||
if (localPlayerRig == null)
|
||||
{
|
||||
MelonLogger.Msg("Local player rig not found");
|
||||
SyncLogger.Msg("Local player rig not found");
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
if (localRigHeadTransform == null || localRigLeftHandTransform == null || localRigRightHandTransform == null)
|
||||
{
|
||||
MelonLogger.Msg("Local player rig components not found");
|
||||
SyncLogger.Msg("Local player rig components not found");
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -169,7 +169,7 @@ namespace BoneSync.Player
|
||||
private static void SendLocalPlayerSync()
|
||||
{
|
||||
if (!BoneSync.IsConnected) return;
|
||||
//MelonLogger.Msg("Sending local player sync");
|
||||
//SyncLogger.Msg("Sending local player sync");
|
||||
PlayerSyncInfo? playerSyncInfo = GetLocalSyncInfo();
|
||||
if (!playerSyncInfo.HasValue) return;
|
||||
PlayerSyncMessage playerSyncMessage = new PlayerSyncMessage(playerSyncInfo.Value);
|
||||
@@ -180,13 +180,13 @@ namespace BoneSync.Player
|
||||
{
|
||||
if (_playerRigs.ContainsKey(ownerId))
|
||||
{
|
||||
//MelonLogger.Msg("PlayerRig already exists for " + ownerId);
|
||||
//SyncLogger.Msg("PlayerRig already exists for " + ownerId);
|
||||
return _playerRigs[ownerId];
|
||||
}
|
||||
|
||||
if (rigBundle == null)
|
||||
{
|
||||
MelonLogger.Msg("playerRepBundle is null! Did you forget to load the bundle?");
|
||||
SyncLogger.Msg("playerRepBundle is null! Did you forget to load the bundle?");
|
||||
return null;
|
||||
}
|
||||
//PlayerScripts.GetPlayerScripts();
|
||||
@@ -237,8 +237,8 @@ namespace BoneSync.Player
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
MelonLogger.Warning("Failed to update player rig " + _ownerId);
|
||||
MelonLogger.Warning(e.ToString());
|
||||
SyncLogger.Warning("Failed to update player rig " + _ownerId);
|
||||
SyncLogger.Warning(e.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -251,7 +251,7 @@ namespace BoneSync.Player
|
||||
|
||||
public static void OnPlayerSync(PlayerSyncMessage playerSyncMessage)
|
||||
{
|
||||
//MelonLogger.Msg("Player Sync Received " + playerSyncMessage.senderId);
|
||||
//SyncLogger.Msg("Player Sync Received " + playerSyncMessage.senderId);
|
||||
PlayerRig playerRig = PlayerRig.GetPlayerRig(playerSyncMessage.senderId);
|
||||
if (playerRig == null) return;
|
||||
playerRig.UpdatePlayerSync(playerSyncMessage.playerSyncInfo);
|
||||
|
||||
@@ -18,6 +18,7 @@ using StressLevelZero.Props.Weapons;
|
||||
using StressLevelZero.AI;
|
||||
using PuppetMasta;
|
||||
using UnityEngine.SceneManagement;
|
||||
using BoneSync.Data;
|
||||
|
||||
|
||||
namespace BoneSync.Sync.Components
|
||||
@@ -84,7 +85,7 @@ namespace BoneSync.Sync.Components
|
||||
|
||||
public void SetInHolster(bool val)
|
||||
{
|
||||
MelonLogger.Msg(transform.GetPath() + " hosterState:" + val);
|
||||
SyncLogger.Msg(transform.GetPath() + " hosterState:" + val);
|
||||
_isInHolster = val;
|
||||
FindAndUpdateComponents();
|
||||
}
|
||||
@@ -125,12 +126,14 @@ namespace BoneSync.Sync.Components
|
||||
|
||||
private SpawnFragment spawnFragment;
|
||||
|
||||
public bool IsStatic() => rigidbodies.Length == 0;
|
||||
private void CheckAutoSync()
|
||||
{
|
||||
FindAndUpdateComponents();
|
||||
bool shouldAutoSync = ShouldAutoSync();
|
||||
if (shouldAutoSync && (BoneSync.lobby.IsHost || ClientSpawningAllowed()))
|
||||
{
|
||||
MelonLogger.Msg("AutoSyncing: " + transform.GetPath());
|
||||
SyncLogger.Msg("AutoSyncing: " + transform.GetPath());
|
||||
RegisterSyncable();
|
||||
}
|
||||
}
|
||||
@@ -140,9 +143,9 @@ namespace BoneSync.Sync.Components
|
||||
yield return null;
|
||||
yield return null;
|
||||
yield return null;
|
||||
FindAndUpdateComponents();
|
||||
CheckAutoSync();
|
||||
yield break;
|
||||
yield return new WaitForSeconds(SceneSync.MAP_LOAD_GRACE_PERIOD);
|
||||
CheckAutoSync(); // check again after grace period
|
||||
}
|
||||
|
||||
public void OnEnable()
|
||||
@@ -162,6 +165,7 @@ namespace BoneSync.Sync.Components
|
||||
if (poolee && poolee.pool) {
|
||||
return true;
|
||||
}
|
||||
if (IsStatic() && buttonToggles.Length != 0) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -265,13 +269,15 @@ namespace BoneSync.Sync.Components
|
||||
if (!this) return; // if object is destroyed, don't do anything
|
||||
bool isRegistered = Registered;
|
||||
|
||||
SyncLogger.Debug("Discarding syncable: " + transform.GetPath() + " force:" + force + " registered:" + isRegistered + " despawn:" + despawn + " isPlugged:" + IsPlugged());
|
||||
|
||||
if (isRegistered)
|
||||
{
|
||||
bool isPlugged = IsPlugged();
|
||||
|
||||
bool canDiscard = isOwner && (!isPlugged || force); // only owner can discard
|
||||
//MelonLogger.Msg("Discarding syncable: " + transform.GetPath() + " force:" + force + " registered:" + isRegistered + " despawn:" + despawn + " isPlugged:" + isPlugged + " canDiscard:" + canDiscard);
|
||||
//MelonLogger.Warning("Discarding registered syncable: " + transform.GetPath() + " force: " + force);
|
||||
//SyncLogger.Msg("Discarding syncable: " + transform.GetPath() + " force:" + force + " registered:" + isRegistered + " despawn:" + despawn + " isPlugged:" + isPlugged + " canDiscard:" + canDiscard);
|
||||
//SyncLogger.Warning("Discarding registered syncable: " + transform.GetPath() + " force: " + force);
|
||||
|
||||
if (canDiscard)
|
||||
{
|
||||
@@ -281,14 +287,14 @@ namespace BoneSync.Sync.Components
|
||||
if (!canDiscard && !force) return;
|
||||
}
|
||||
|
||||
//MelonLogger.Msg("Discarding syncable: " + transform.GetPath() + " force:" + force + " registered:" + isRegistered + " despawn:" + despawn + " isPlugged:" + IsPlugged());
|
||||
//SyncLogger.Msg("Discarding syncable: " + transform.GetPath() + " force:" + force + " registered:" + isRegistered + " despawn:" + despawn + " isPlugged:" + IsPlugged());
|
||||
|
||||
try
|
||||
{
|
||||
EjectAllPlugs(true);
|
||||
}
|
||||
catch {
|
||||
MelonLogger.Warning("Failed to eject plugs (should be fine)");
|
||||
SyncLogger.Warning("Failed to eject plugs (should be fine)");
|
||||
}
|
||||
|
||||
|
||||
@@ -307,13 +313,17 @@ namespace BoneSync.Sync.Components
|
||||
{
|
||||
if (Registered)
|
||||
{
|
||||
MelonLogger.Warning("Destroying registered syncable: " + transform.GetPath());
|
||||
SyncLogger.Warning("Destroying registered syncable: " + transform.GetPath());
|
||||
}
|
||||
DiscardSyncableImmediate(true, Registered);
|
||||
//MelonLogger.Msg("Syncable destroyed: " + transform.GetPath());
|
||||
//SyncLogger.Msg("Syncable destroyed: " + transform.GetPath());
|
||||
}
|
||||
|
||||
private IEnumerator _FlagForDiscardCo(bool force, bool despawn) { yield return null; _DiscardSyncable(force, despawn); } // delay discard to prevent silly behavior
|
||||
private IEnumerator _FlagForDiscardCo(bool force, bool despawn) {
|
||||
yield return null;
|
||||
yield return null;
|
||||
_DiscardSyncable(force, despawn);
|
||||
} // delay discard to prevent silly behavior
|
||||
|
||||
public void DiscardSyncable(bool force = false, bool despawn = false)
|
||||
{
|
||||
@@ -334,7 +344,7 @@ namespace BoneSync.Sync.Components
|
||||
{
|
||||
if (Registered && !isOwner)
|
||||
{
|
||||
MelonLogger.Warning("tried to disable non-owner syncable: " + transform.GetPath());
|
||||
SyncLogger.Warning("tried to disable non-owner syncable: " + transform.GetPath());
|
||||
gameObject.SetActive(true);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using BoneSync.Networking.Messages;
|
||||
using BoneSync.Data;
|
||||
using BoneSync.Networking.Messages;
|
||||
using BoneSync.Patching;
|
||||
using MelonLoader;
|
||||
using StressLevelZero.Data;
|
||||
@@ -64,14 +65,14 @@ namespace BoneSync.Sync.Components
|
||||
|
||||
if (eventType == ObjectDamageType.DestructibleTakeDamage && objectDestructable)
|
||||
{
|
||||
MelonLogger.Msg("NetworkDestructableTakeDamage: " + healthInfo.damage);
|
||||
SyncLogger.Msg("NetworkDestructableTakeDamage: " + healthInfo.damage);
|
||||
CallPatchedMethods.TakeDamage(objectDestructable, healthInfo.normal, healthInfo.damage, healthInfo.crit, healthInfo.attackType);
|
||||
return;
|
||||
}
|
||||
|
||||
if (eventType == ObjectDamageType.PropHealthTakeDamage && propHealth)
|
||||
{
|
||||
MelonLogger.Msg("NetworkPropHealthTakeDamage: " + healthInfo.damage);
|
||||
SyncLogger.Msg("NetworkPropHealthTakeDamage: " + healthInfo.damage);
|
||||
CallPatchedMethods.TakeDamage(propHealth, healthInfo.damage, healthInfo.crit, healthInfo.attackType);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
using BoneSync.Networking.Messages;
|
||||
using BoneSync.Data;
|
||||
using BoneSync.Networking.Messages;
|
||||
using BoneSync.Patching;
|
||||
using MelonLoader;
|
||||
using StressLevelZero.Zones;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
@@ -26,7 +28,7 @@ namespace BoneSync.Sync.Components
|
||||
}
|
||||
public IEnumerator SyncCoroutineAsync()
|
||||
{
|
||||
MelonLogger.Msg("Running sync coroutine for: " + transform.GetPath());
|
||||
SyncLogger.Msg("Running sync coroutine for: " + transform.GetPath());
|
||||
if (_syncCoroutineRunning) yield break;
|
||||
_syncCoroutineRunning = true;
|
||||
while (isOwner)
|
||||
@@ -41,7 +43,7 @@ namespace BoneSync.Sync.Components
|
||||
}
|
||||
public void SetOwner(ulong ownerId)
|
||||
{
|
||||
MelonLogger.Msg("Setting owner for " + _syncId + " to " + ownerId);
|
||||
SyncLogger.Msg("Setting owner for " + _syncId + " to " + ownerId);
|
||||
_ownerId = ownerId;
|
||||
FindAndUpdateComponents();
|
||||
MelonCoroutines.Start(SyncCoroutineAsync());
|
||||
@@ -67,13 +69,13 @@ namespace BoneSync.Sync.Components
|
||||
|
||||
private void _SendRegisterSync()
|
||||
{
|
||||
MelonLogger.Msg("Registering syncable object: " + gameObject.name);
|
||||
SyncLogger.Msg("Registering syncable object: " + gameObject.name);
|
||||
MelonCoroutines.Start(__SendRegisterSyncCo());
|
||||
}
|
||||
|
||||
private void _SendDiscard(bool despawn = false)
|
||||
{
|
||||
MelonLogger.Msg("Sending discard for " + _syncId + " despawn: " + despawn);
|
||||
SyncLogger.Msg("Sending discard for " + _syncId + " despawn: " + despawn);
|
||||
DiscardSyncableMessageData discardSyncableMessageData = new DiscardSyncableMessageData()
|
||||
{
|
||||
syncId = _syncId,
|
||||
@@ -84,10 +86,10 @@ namespace BoneSync.Sync.Components
|
||||
}
|
||||
public void OnOwnershipTransferRequest(ulong newOwnerId)
|
||||
{
|
||||
//MelonLogger.Msg("Ownership transfer request for " + _syncId + " to " + newOwnerId);
|
||||
//SyncLogger.Msg("Ownership transfer request for " + _syncId + " to " + newOwnerId);
|
||||
if (isOwner && !IsHolding() && !_isInHolster)
|
||||
{
|
||||
MelonLogger.Msg("Sending ownership transfer for " + _syncId + " to " + newOwnerId);
|
||||
SyncLogger.Msg("Sending ownership transfer for " + _syncId + " to " + newOwnerId);
|
||||
OwnershipTransferMessageData data = new OwnershipTransferMessageData()
|
||||
{
|
||||
syncId = _syncId,
|
||||
@@ -105,7 +107,7 @@ namespace BoneSync.Sync.Components
|
||||
if (Registered && !isOwner)
|
||||
{
|
||||
ulong localId = BoneSync.lobby.GetLocalId();
|
||||
MelonLogger.Msg("Attempting to become owner of " + _syncId + " force: " + force);
|
||||
SyncLogger.Msg("Attempting to become owner of " + _syncId + " force: " + force);
|
||||
OwnershipTransferMessageData data = new OwnershipTransferMessageData()
|
||||
{
|
||||
syncId = _syncId,
|
||||
@@ -131,26 +133,39 @@ namespace BoneSync.Sync.Components
|
||||
return true;
|
||||
}
|
||||
|
||||
private void _SendSimpleEvent(SimpleEventType eType, byte index = 0)
|
||||
private void _SendSimpleEvent(SimpleEventType eType, byte index = 0, byte len = 0)
|
||||
{
|
||||
MelonLogger.Msg("Sending simple event: " + eType);
|
||||
SyncLogger.Msg("Sending simple event: " + eType);
|
||||
SimpleSyncableEvent data = new SimpleSyncableEvent()
|
||||
{
|
||||
syncId = _syncId,
|
||||
eventType = eType,
|
||||
index = index
|
||||
index = index,
|
||||
length = len
|
||||
};
|
||||
|
||||
SimpleSyncableEventMessage simpleSyncEvent = new SimpleSyncableEventMessage(data);
|
||||
simpleSyncEvent.Broadcast();
|
||||
}
|
||||
|
||||
private void DestroyZoneTrackers()
|
||||
{
|
||||
/*ZoneTracker[] zoneTrackers = GetComponentsInChildren<ZoneTracker>(true);
|
||||
foreach (ZoneTracker zoneTracker in zoneTrackers)
|
||||
{
|
||||
//Destroy(zoneTracker);
|
||||
}*/
|
||||
}
|
||||
|
||||
public ushort GetSyncId() => _syncId;
|
||||
public void SetSyncId(ushort id)
|
||||
{
|
||||
|
||||
_syncId = id;
|
||||
ObjectSyncCache.UpdateSyncId(this);
|
||||
if (id != 0)
|
||||
{
|
||||
DestroyZoneTrackers();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,23 +16,28 @@ namespace BoneSync.Sync.Components
|
||||
{
|
||||
public partial class Syncable : MonoBehaviour
|
||||
{
|
||||
private HashSet<ButtonToggle> patchedButtonToggles = new HashSet<ButtonToggle>();
|
||||
private HashSet<int> patchedButtonToggles = new HashSet<int>();
|
||||
private bool pullDevicePatched = false;
|
||||
|
||||
void ButtonOnPress(ButtonToggle toggle)
|
||||
bool ButtonOnPress(ButtonToggle toggle)
|
||||
{
|
||||
MelonLogger.Msg("ButtonToggle:OnPress " + toggle.transform.GetPath());
|
||||
SyncLogger.Msg("ButtonToggle:OnPress " + toggle.transform.GetPath());
|
||||
byte index = (byte)Array.IndexOf(buttonToggles, toggle);
|
||||
MelonLogger.Msg("ButtonToggle:OnPress");
|
||||
if (!isOwner) { return; }
|
||||
RegisterSyncable();
|
||||
if (!Registered) return false;
|
||||
if (!isOwner) return false;
|
||||
_SendSimpleEvent(SimpleEventType.OnButtonPress, index);
|
||||
return true;
|
||||
}
|
||||
void ButtonOnRelease(ButtonToggle toggle)
|
||||
bool ButtonOnRelease(ButtonToggle toggle)
|
||||
{
|
||||
MelonLogger.Msg("ButtonToggle:OnRelease " + toggle.transform.GetPath());
|
||||
SyncLogger.Msg("ButtonToggle:OnRelease " + toggle.transform.GetPath());
|
||||
byte index = (byte)Array.IndexOf(buttonToggles, toggle);
|
||||
if (!isOwner) { return; }
|
||||
RegisterSyncable();
|
||||
if (!Registered) return false;
|
||||
if (!isOwner) return false;
|
||||
_SendSimpleEvent(SimpleEventType.OnButtonRelease, index);
|
||||
return true;
|
||||
}
|
||||
|
||||
void DeviceOnPull()
|
||||
@@ -57,7 +62,7 @@ namespace BoneSync.Sync.Components
|
||||
}
|
||||
} catch (Exception e)
|
||||
{
|
||||
MelonLogger.Error("Failed to patch UnityEvents: " + e);
|
||||
SyncLogger.Error("Failed to patch UnityEvents: " + e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -65,21 +70,22 @@ namespace BoneSync.Sync.Components
|
||||
{
|
||||
if (pullDevicePatched) return;
|
||||
if (!pullDevice) return;
|
||||
pullDevice.OnHandlePull.AddListener((UnityAction)DeviceOnPull);
|
||||
pullDevice.OnHandleReturn.AddListener((UnityAction)DeviceOnRelease);
|
||||
//pullDevice.OnHandlePull.AddListener((UnityAction)DeviceOnPull);
|
||||
//pullDevice.OnHandleReturn.AddListener((UnityAction)DeviceOnRelease);
|
||||
|
||||
pullDevicePatched = true;
|
||||
}
|
||||
|
||||
private void _TryPatchButtonToggle(ButtonToggle buttonToggle)
|
||||
{
|
||||
if (patchedButtonToggles.Contains(buttonToggle)) return;
|
||||
MelonLogger.Msg("Patching ButtonToggle: " + buttonToggle.transform.GetPath());
|
||||
if (patchedButtonToggles.Contains(buttonToggle.GetHashCode())) return;
|
||||
SyncLogger.Msg("Patching ButtonToggle: " + buttonToggle.transform.GetPath());
|
||||
//buttonToggle.onPress.AddListenerWithArgs<ButtonToggle>((btn, args) => ButtonOnPress(btn), buttonToggle);
|
||||
//buttonToggle.onDepress.AddListenerWithArgs<ButtonToggle>((btn, args) => ButtonOnRelease(btn), buttonToggle);
|
||||
UnityEventPatch<ButtonToggle>.Patch(buttonToggle, buttonToggle.onPress, ButtonOnPress);
|
||||
UnityEventPatch<ButtonToggle>.Patch(buttonToggle, buttonToggle.onDepress, ButtonOnRelease);
|
||||
|
||||
patchedButtonToggles.Add(buttonToggle);
|
||||
patchedButtonToggles.Add(buttonToggle.GetHashCode());
|
||||
}
|
||||
|
||||
public bool AllRigidbodiesSleeping()
|
||||
@@ -117,7 +123,7 @@ namespace BoneSync.Sync.Components
|
||||
_SetKinematic(kinematic);
|
||||
}
|
||||
catch {
|
||||
MelonLogger.Warning("Failed to set kinematic");
|
||||
SyncLogger.Warning("Failed to set kinematic");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -140,7 +146,7 @@ namespace BoneSync.Sync.Components
|
||||
if (IsPlugged()) { return; }
|
||||
if (objectSyncTransforms.Length != rigidbodies.Length)
|
||||
{
|
||||
MelonLogger.Warning("ObjectSyncTransforms length mismatch: " + objectSyncTransforms.Length + " != " + _transforms.Length);
|
||||
SyncLogger.Warning("ObjectSyncTransforms length mismatch: " + objectSyncTransforms.Length + " != " + _transforms.Length);
|
||||
return;
|
||||
}
|
||||
for (int i = 0; i < objectSyncTransforms.Length; i++)
|
||||
@@ -200,26 +206,29 @@ namespace BoneSync.Sync.Components
|
||||
|
||||
internal void OnSimpleSyncableEvent(SimpleSyncableEvent eventData)
|
||||
{
|
||||
MelonLogger.Msg("OnSimpleSyncableEvent: " + eventData.eventType);
|
||||
SyncLogger.Msg("OnSimpleSyncableEvent: " + eventData.eventType);
|
||||
SimpleEventType eType = eventData.eventType;
|
||||
byte index = eventData.index;
|
||||
byte len = eventData.length;
|
||||
switch (eType) {
|
||||
case SimpleEventType.OnDevicePull:
|
||||
pullDevice?.OnHandlePull?.Invoke();
|
||||
pullDevice?.OnHandlePull?.BypassPatchInvoke();
|
||||
break;
|
||||
case SimpleEventType.OnDeviceRelease:
|
||||
pullDevice?.OnHandleReturn?.Invoke();
|
||||
pullDevice?.OnHandleReturn?.BypassPatchInvoke();
|
||||
break;
|
||||
case SimpleEventType.OnButtonPress:
|
||||
if (len != eventData.length) { SyncLogger.Warning("ButtonPress length mismatch: " + len + " != " + eventData.length); }
|
||||
if (index < buttonToggles.Length)
|
||||
{
|
||||
buttonToggles[index]?.onPress.Invoke();
|
||||
buttonToggles[index]?.onPress.BypassPatchInvoke();
|
||||
}
|
||||
break;
|
||||
case SimpleEventType.OnButtonRelease:
|
||||
if (len != eventData.length) { SyncLogger.Warning("ButtonPress length mismatch: " + len + " != " + eventData.length); }
|
||||
if (index < buttonToggles.Length)
|
||||
{
|
||||
buttonToggles[index]?.onDepress.Invoke();
|
||||
buttonToggles[index]?.onDepress.BypassPatchInvoke();
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@ using UnityEngine;
|
||||
using MelonLoader;
|
||||
using StressLevelZero.Interaction;
|
||||
using BoneSync.Patching;
|
||||
using BoneSync.Data;
|
||||
|
||||
namespace BoneSync.Sync.Components
|
||||
{
|
||||
@@ -18,6 +19,7 @@ namespace BoneSync.Sync.Components
|
||||
if (!socket) return null;
|
||||
if (socket.LockedPlug == plug) return socket;
|
||||
if (plug._isExitTransition) return socket;
|
||||
if (plug._isEnterTransition) return socket;
|
||||
|
||||
return null;
|
||||
}
|
||||
@@ -112,7 +114,7 @@ namespace BoneSync.Sync.Components
|
||||
{
|
||||
if (plugs.Length <= id)
|
||||
{
|
||||
MelonLogger.Error("Plug ID out of range");
|
||||
SyncLogger.Error("Plug ID out of range");
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -123,7 +125,7 @@ namespace BoneSync.Sync.Components
|
||||
{
|
||||
if (sockets.Length <= id)
|
||||
{
|
||||
MelonLogger.Error("Socket ID out of range");
|
||||
SyncLogger.Error("Socket ID out of range");
|
||||
return null;
|
||||
}
|
||||
return sockets[id];
|
||||
|
||||
@@ -48,7 +48,7 @@ namespace BoneSync.Sync
|
||||
|
||||
string spawnableTitle = spawnableRealTitle ?? spawnableAlternateTitle;
|
||||
|
||||
MelonLogger.Msg("Spawnable title: " + spawnableTitle);
|
||||
SyncLogger.Msg("Spawnable title: " + spawnableTitle);
|
||||
info = new RegisterSyncableInfo()
|
||||
{
|
||||
ownerId = ownerId,
|
||||
@@ -65,12 +65,12 @@ namespace BoneSync.Sync
|
||||
|
||||
public static ushort SendRegisterSyncableMessage(Syncable syncable)
|
||||
{
|
||||
MelonLogger.Msg("Sending register syncable message for: " + syncable.transform.name);
|
||||
SyncLogger.Msg("Sending register syncable message for: " + syncable.transform.name);
|
||||
RegisterSyncableInfo? infoNullable = GetRegisterInfo(syncable, syncable.ClientSpawningAllowed());
|
||||
|
||||
if (infoNullable == null)
|
||||
{
|
||||
MelonLogger.Warning("No valid registeration method for syncable");
|
||||
SyncLogger.Warning("No valid registeration method for syncable");
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -89,7 +89,7 @@ namespace BoneSync.Sync
|
||||
new RegisterSyncableMessage(info).SendToHost();
|
||||
}
|
||||
|
||||
MelonLogger.Msg("Sending register syncable message for: " + syncable.transform.name + " with id: " + info.id + " and type : " + info.type);
|
||||
SyncLogger.Msg("Sending register syncable message for: " + syncable.transform.name + " with id: " + info.id + " and type : " + info.type);
|
||||
|
||||
return info.id;
|
||||
}
|
||||
@@ -97,7 +97,7 @@ namespace BoneSync.Sync
|
||||
public static void SendObjectSyncMessage(Syncable syncable)
|
||||
{
|
||||
if (!syncable.Registered) return;
|
||||
//MelonLogger.Msg("Sending object sync message for: " + syncable.transform.name);
|
||||
//SyncLogger.Msg("Sending object sync message for: " + syncable.transform.name);
|
||||
ObjectSyncTransform[] objectSyncTransforms = syncable.GetObjectSyncTransforms();
|
||||
|
||||
ObjectSyncMessageData data = new ObjectSyncMessageData()
|
||||
@@ -112,7 +112,7 @@ namespace BoneSync.Sync
|
||||
private static Syncable _MakeOrGetSyncable(GameObject gameObject, bool deleteSubSyncabled = true)
|
||||
{
|
||||
//Scene scene = gameObject.scene;
|
||||
//MelonLogger.Msg("Making or getting syncable for: " + gameObject.name);
|
||||
//SyncLogger.Msg("Making or getting syncable for: " + gameObject.name);
|
||||
if (gameObject == null)
|
||||
{
|
||||
return null;
|
||||
@@ -133,21 +133,21 @@ namespace BoneSync.Sync
|
||||
bool isRegistered = subSyncable.Registered;
|
||||
bool isPlugged = subSyncable.IsPlugged();
|
||||
|
||||
MelonLogger.Msg("Discarding subSyncable: " + subSyncable.transform.GetPath() + " registered:" + isRegistered + " plugged:" + isPlugged);
|
||||
SyncLogger.Msg("Discarding subSyncable: " + subSyncable.transform.GetPath() + " registered:" + isRegistered + " plugged:" + isPlugged);
|
||||
if (isRegistered || isPlugged) continue;
|
||||
subSyncable.DiscardSyncable();
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
MelonLogger.Warning("Failed to delete sub syncables: " + e.Message);
|
||||
SyncLogger.Warning("Failed to delete sub syncables: " + e.Message);
|
||||
}
|
||||
}
|
||||
|
||||
if (syncable == null)
|
||||
{
|
||||
syncable = gameObject.AddComponent<Syncable>();
|
||||
// MelonLogger.Msg("Created syncable for: " + gameObject.name);
|
||||
// SyncLogger.Msg("Created syncable for: " + gameObject.name);
|
||||
}
|
||||
return syncable;
|
||||
}
|
||||
@@ -203,26 +203,31 @@ namespace BoneSync.Sync
|
||||
|
||||
SpawnableObject spawnableObject = SpawnableManager.GetSpawnable(spawnInfo.spawnableTitle);
|
||||
if (spawnableObject == null) {
|
||||
MelonLogger.Warning("[SpawnPooleeAndMakeSyncable] Failed to find spawnable: " + spawnInfo.spawnableTitle);
|
||||
SyncLogger.Warning("Failed to find spawnable: " + spawnInfo.spawnableTitle);
|
||||
return null;
|
||||
}
|
||||
|
||||
Pool pool = SpawnableManager.GetPool(spawnableObject);
|
||||
/*Pool pool = SpawnableManager.GetPool(spawnableObject);
|
||||
|
||||
if (!pool)
|
||||
{
|
||||
MelonLogger.Warning("[SpawnPooleeAndMakeSyncable] Failed to find pool: " + spawnInfo.spawnableTitle);
|
||||
SyncLogger.Warning("[SpawnPooleeAndMakeSyncable] Failed to find pool: " + spawnInfo.spawnableTitle);
|
||||
return null;
|
||||
}
|
||||
Poolee poolee = CallPatchedMethods.InstantiatePoolee(pool, spawnLocation.position, spawnLocation.rotation, pool.Prefab.transform.localScale);*/
|
||||
Poolee poolee = SpawnableManager.SpawnPoolee(spawnableObject, spawnLocation.position, spawnLocation.rotation);
|
||||
if (poolee == null) {
|
||||
SyncLogger.Warning("Failed to spawn poolee: " + spawnInfo.spawnableTitle);
|
||||
return null;
|
||||
}
|
||||
Poolee poolee = CallPatchedMethods.InstantiatePoolee(pool, spawnLocation.position, spawnLocation.rotation, pool.Prefab.transform.localScale);
|
||||
|
||||
Syncable syncable = MakeOrGetSyncable(poolee);
|
||||
MelonLogger.Msg("Spawned poolee with syncable: " + poolee.transform.GetPath());
|
||||
SyncLogger.Msg("Spawned poolee with syncable: " + poolee.transform.GetPath());
|
||||
return syncable;
|
||||
}
|
||||
public static void OnRegisterSyncMessage(RegisterSyncableMessage registerSyncableMessage)
|
||||
{
|
||||
MelonLogger.Msg("Received register sync message");
|
||||
SyncLogger.Msg("Received register sync message");
|
||||
Syncable syncable = null;
|
||||
RegisterSyncableInfo info = registerSyncableMessage.info;
|
||||
if (BoneSync.lobby.IsHost)
|
||||
@@ -234,26 +239,26 @@ namespace BoneSync.Sync
|
||||
// only host can register syncables, all spawn requests should be sent to host
|
||||
if (registerSyncableMessage.senderId != BoneSync.lobby.GetHostId())
|
||||
{
|
||||
MelonLogger.Warning("Received register sync message from non-host: " + registerSyncableMessage.senderId);
|
||||
SyncLogger.Warning("Received register sync message from non-host: " + registerSyncableMessage.senderId);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (info.id == 0)
|
||||
{
|
||||
MelonLogger.Warning("Received register sync message with id 0");
|
||||
SyncLogger.Warning("Received register sync message with id 0");
|
||||
return;
|
||||
}
|
||||
|
||||
bool hasCallback = info.callbackId != 0;
|
||||
if (hasCallback)
|
||||
{
|
||||
MelonLogger.Msg("Received register sync message with callback id: " + info.callbackId);
|
||||
SyncLogger.Msg("Received register sync message with callback id: " + info.callbackId);
|
||||
}
|
||||
|
||||
if (hasCallback && ObjectSyncCache.CallbackIdToSyncable.ContainsKey(info.callbackId))
|
||||
{
|
||||
MelonLogger.Msg("Found syncable for callback id: " + info.callbackId);
|
||||
SyncLogger.Msg("Found syncable for callback id: " + info.callbackId);
|
||||
syncable = ObjectSyncCache.CallbackIdToSyncable[info.callbackId];
|
||||
ObjectSyncCache.CallbackIdToSyncable.Remove(info.callbackId);
|
||||
} else
|
||||
@@ -261,11 +266,11 @@ namespace BoneSync.Sync
|
||||
switch (info.type)
|
||||
{
|
||||
case RegisterSyncType.RegisterFromPath:
|
||||
MelonLogger.Msg("Registering syncable from path: " + info.transformPath + " with id: " + info.id);
|
||||
SyncLogger.Msg("Registering syncable from path: " + info.transformPath + " with id: " + info.id);
|
||||
syncable = ObjectSyncCache.GetSyncable(info.transformPath);
|
||||
break;
|
||||
case RegisterSyncType.RegisterAndSpawn:
|
||||
MelonLogger.Msg("Registering and spawning syncable from pool: " + info.spawnInfo.Value.spawnableTitle + " with id: " + info.id);
|
||||
SyncLogger.Msg("Registering and spawning syncable from pool: " + info.spawnInfo.Value.spawnableTitle + " with id: " + info.id);
|
||||
syncable = SpawnPooleeAndMakeSyncable(info.spawnInfo.Value);
|
||||
break;
|
||||
}
|
||||
@@ -273,7 +278,7 @@ namespace BoneSync.Sync
|
||||
|
||||
if (!syncable)
|
||||
{
|
||||
MelonLogger.Warning("Failed to create/obtain syncable for register sync message "+ info.id);
|
||||
SyncLogger.Warning("Failed to create/obtain syncable for register sync message "+ info.id);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -295,7 +300,7 @@ namespace BoneSync.Sync
|
||||
Syncable syncable = ObjectSyncCache.GetSyncable(objectId);
|
||||
if (syncable == null)
|
||||
{
|
||||
//MelonLogger.Msg("SyncEvent: Syncable not found for id: " + objectId);
|
||||
//SyncLogger.Msg("SyncEvent: Syncable not found for id: " + objectId);
|
||||
return;
|
||||
}
|
||||
syncable.ApplyObjectSyncTransforms(data.objectSyncTransforms);
|
||||
@@ -309,7 +314,7 @@ namespace BoneSync.Sync
|
||||
Syncable syncable = ObjectSyncCache.GetSyncable(damageInfo.objectId);
|
||||
if (syncable == null)
|
||||
{
|
||||
//MelonLogger.Msg("DamageEvent: Syncable not found for id: " + damageInfo.objectId);
|
||||
//SyncLogger.Msg("DamageEvent: Syncable not found for id: " + damageInfo.objectId);
|
||||
return;
|
||||
}
|
||||
syncable.Damage(damageInfo);
|
||||
@@ -333,7 +338,7 @@ namespace BoneSync.Sync
|
||||
Syncable syncable = ObjectSyncCache.GetSyncable(syncId);
|
||||
if (syncable == null)
|
||||
{
|
||||
MelonLogger.Warning("Ownership transfer request for non-existant syncable: " + syncId);
|
||||
SyncLogger.Warning("Ownership transfer request for non-existant syncable: " + syncId);
|
||||
return;
|
||||
}
|
||||
if (force)
|
||||
|
||||
@@ -15,7 +15,7 @@ namespace BoneSync.Sync
|
||||
{
|
||||
internal class SceneSync
|
||||
{
|
||||
public const float MAP_LOAD_GRACE_PERIOD = 5f;
|
||||
public const float MAP_LOAD_GRACE_PERIOD = 5f; // allow x seconds for the game to load the scene before doing anything that requires the scene to be fully initialized
|
||||
|
||||
private static List<Scene> scenes = new List<Scene>();
|
||||
private static string _currentSceneName;
|
||||
@@ -55,7 +55,7 @@ namespace BoneSync.Sync
|
||||
seenTransformNames[path]++;
|
||||
t.name = t.name + " (BoneSync." + seenTransformNames[path] + ")";
|
||||
total++;
|
||||
//MelonLogger.Msg("Renamed duplicate transform: " + path);
|
||||
//SyncLogger.Msg("Renamed duplicate transform: " + path);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -64,11 +64,7 @@ namespace BoneSync.Sync
|
||||
}
|
||||
}
|
||||
|
||||
MelonLogger.Msg("Renamed " + total + " duplicate transforms in " + scene.name);
|
||||
|
||||
|
||||
|
||||
|
||||
SyncLogger.Msg("Renamed " + total + " duplicate transforms in " + scene.name);
|
||||
}
|
||||
public static void OnSceneInit(int buildIndex)
|
||||
{
|
||||
@@ -77,7 +73,7 @@ namespace BoneSync.Sync
|
||||
_currentSceneIndex = buildIndex;
|
||||
string SceneName = scene.name;
|
||||
_currentSceneName = SceneName;
|
||||
MelonLogger.Msg("Scene initialized: " + SceneName);
|
||||
SyncLogger.Msg("Scene initialized: " + SceneName);
|
||||
RenameDuplicateSceneTransforms(scene);
|
||||
SpawnableManager.AddUnregisteredSpawnables();
|
||||
}
|
||||
@@ -95,7 +91,7 @@ namespace BoneSync.Sync
|
||||
int index = scenes.FindIndex(x => x.name == sceneName);
|
||||
if (index == -1)
|
||||
{
|
||||
MelonLogger.Error("Scene not found: " + sceneName);
|
||||
SyncLogger.Error("Scene not found: " + sceneName);
|
||||
return;
|
||||
}
|
||||
SendSceneSyncMessage(index);
|
||||
@@ -105,7 +101,7 @@ namespace BoneSync.Sync
|
||||
if (!BoneSync.IsConnected) return;
|
||||
if (BoneSync.lobby.IsHost)
|
||||
{
|
||||
MelonLogger.Msg("Host is loading scene, sending message to clients...");
|
||||
SyncLogger.Msg("Host is loading scene, sending message to clients...");
|
||||
SceneChangeInfo info = new SceneChangeInfo()
|
||||
{
|
||||
sceneName = scenes[index].name,
|
||||
|
||||
Reference in New Issue
Block a user