This commit is contained in:
Garrett
2024-10-29 10:45:54 -05:00
parent 7b4a2aa205
commit af95b422d5

View File

@@ -264,7 +264,12 @@ namespace SeamlessClient.Components
} }
//Following event doesnt clear networked replicables
MyMultiplayer.Static.ReplicationLayer.Dispose(); MyMultiplayer.Static.ReplicationLayer.Dispose();
ClearClientReplicables();
PreventRPC = true; PreventRPC = true;
StartPacketCheck = true; StartPacketCheck = true;
@@ -273,6 +278,24 @@ namespace SeamlessClient.Components
} }
private void ClearClientReplicables()
{
MyReplicationClient replicationClient = (MyReplicationClient)MyMultiplayer.Static.ReplicationLayer;
Dictionary<NetworkId,IMyNetObject> networkedobjs = (Dictionary<NetworkId, IMyNetObject>)typeof(MyReplicationLayer).GetField("m_networkIDToObject", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(replicationClient);
MethodInfo destroyreplicable = typeof(MyReplicationClient).GetMethod("ReplicableDestroy", BindingFlags.Instance | BindingFlags.NonPublic);
int i = 0;
foreach(var obj in networkedobjs)
{
destroyreplicable.Invoke(replicationClient, new object[] { obj.Value, true });
i++;
}
Seamless.TryShow($"Cleared {i} replicables");
}
private void OnUserJoined(JoinResult joinResult) private void OnUserJoined(JoinResult joinResult)
{ {
isSwitchingServer = false; isSwitchingServer = false;