|
3 | 3 | using System.Collections.Generic; |
4 | 4 | using System.ComponentModel; |
5 | 5 | using UnityEngine; |
| 6 | +using UnityEngine.LowLevel; |
6 | 7 | using System.Linq; |
7 | 8 | using MLAPI.Logging; |
8 | 9 | using UnityEngine.SceneManagement; |
@@ -34,7 +35,7 @@ namespace MLAPI |
34 | 35 | /// The main component of the library |
35 | 36 | /// </summary> |
36 | 37 | [AddComponentMenu("MLAPI/NetworkingManager", -100)] |
37 | | - public class NetworkingManager : MonoBehaviour |
| 38 | + public class NetworkingManager : MonoBehaviour,INetworkUpdateLoopSystem |
38 | 39 | { |
39 | 40 | // RuntimeAccessModifiersILPP will make this `public` |
40 | 41 | internal static readonly Dictionary<uint, Action<NetworkedBehaviour, BitReader, ulong>> __ntable = new Dictionary<uint, Action<NetworkedBehaviour, BitReader, ulong>>(); |
@@ -72,6 +73,10 @@ public class NetworkingManager : MonoBehaviour |
72 | 73 |
|
73 | 74 | public RPCQueueManager RpcQueueManager { get; private set; } |
74 | 75 |
|
| 76 | + |
| 77 | + |
| 78 | + |
| 79 | + |
75 | 80 | /// <summary> |
76 | 81 | /// A synchronized time, represents the time in seconds since the server application started. Is replicated across all clients |
77 | 82 | /// </summary> |
@@ -697,13 +702,50 @@ private void Shutdown() |
697 | 702 | } |
698 | 703 |
|
699 | 704 |
|
| 705 | + public List<INetworkUpdateLoopSystem> NetworkLoopUpdateSystems; |
| 706 | + |
| 707 | + public NetworkUpdateManager.NetworkUpdateLoopCallbackFunction RegisterUpdate(NetworkUpdateManager.NetworkUpdateStages stage ) |
| 708 | + { |
| 709 | + NetworkUpdateManager.NetworkUpdateLoopCallbackFunction networkUpdateLoopCallback = null; |
| 710 | + switch(stage) |
| 711 | + { |
| 712 | + case NetworkUpdateManager.NetworkUpdateStages.PREUPDATE: |
| 713 | + { |
| 714 | + networkUpdateLoopCallback = NetworkPreUpdate; |
| 715 | + break; |
| 716 | + } |
| 717 | + case NetworkUpdateManager.NetworkUpdateStages.FIXEDUPDATE: |
| 718 | + { |
| 719 | + networkUpdateLoopCallback = NetworkFixedUpdate; |
| 720 | + break; |
| 721 | + } |
| 722 | + case NetworkUpdateManager.NetworkUpdateStages.UPDATE: |
| 723 | + { |
| 724 | + networkUpdateLoopCallback = NetworkUpdate; |
| 725 | + break; |
| 726 | + } |
| 727 | + case NetworkUpdateManager.NetworkUpdateStages.LATEUPDATE: |
| 728 | + { |
| 729 | + networkUpdateLoopCallback = NetworkLateUpdate; |
| 730 | + break; |
| 731 | + } |
| 732 | + } |
| 733 | + return networkUpdateLoopCallback; |
| 734 | + } |
| 735 | + |
| 736 | + |
700 | 737 | private void Awake() |
701 | 738 | { |
| 739 | + //We always add the networking manager as the first entry |
| 740 | + NetworkLoopUpdateSystems.Insert(0, this); |
| 741 | + |
702 | 742 | RpcQueueManager = new RPCQueueManager(LoopbackEnabled); |
703 | 743 | //Note: Since frame history is not being used, this is set to 0 |
704 | 744 | //To test frame history, increase the number to (n) where n > 0 |
705 | 745 | RpcQueueManager?.Initialize(0); |
706 | 746 |
|
| 747 | + NetworkUpdateManager.HandleNetworkLoopRegistrations(NetworkLoopUpdateSystems); |
| 748 | + |
707 | 749 | NetworkUpdateManager.RegisterNetworkUpdateAction(NetworkPreUpdate, NetworkUpdateManager.NetworkUpdateStages.PREUPDATE); |
708 | 750 | NetworkUpdateManager.RegisterNetworkUpdateAction(NetworkFixedUpdate, NetworkUpdateManager.NetworkUpdateStages.FIXEDUPDATE); |
709 | 751 | NetworkUpdateManager.RegisterNetworkUpdateAction(NetworkUpdate, NetworkUpdateManager.NetworkUpdateStages.UPDATE); |
|
0 commit comments