private bool AddBeventDispatcher(BEventDispatcherType bEventDispatcherMode) { switch (bEventDispatcherMode) { case BEventDispatcherType.LOCAL: BEventDispatcher = gameObject.AddComponent <LocalBEventDispatcher>(); return(true); case BEventDispatcherType.MIRROR: // Spawn Mirror's NetworkManager NetworkManager mirrorNetworkManager = FindObjectOfType <NetworkManager>(); if (mirrorNetworkManager == null) { LogConsole("Spawning Mirror Network Manager"); GameObject mirroNetworkManagerPrefab = Resources.Load <GameObject>(BConsts.PATH_MirrorNetworkManager); if (IS_NOT_NULL(mirroNetworkManagerPrefab)) { GameObject mirrorNetworkManagerSpawned = Instantiate(mirroNetworkManagerPrefab); mirrorNetworkManagerSpawned.transform.parent = transform; mirrorNetworkManager = mirrorNetworkManagerSpawned.GetComponent <NetworkManager>(); } } // Add Mirror BEvent Dispatcher if (IS_NOT_NULL(mirrorNetworkManager)) { BEventDispatcher = gameObject.AddComponent <MirrorBEventDispatcher>(); return(true); } return(false); case BEventDispatcherType.UBI_INTERACT: BEventDispatcher = gameObject.AddComponent <UbiiBEventDispatcher>(); return(true); case BEventDispatcherType.NONE: LogConsoleWarning("No Event Dispatcher Mode was selected! Default mode will be used : " + BEventDispatcherType.LOCAL); BEventDispatcher = gameObject.AddComponent <LocalBEventDispatcher>(); return(true); } return(false); }
public void SetBEventDispatcher(BEventDispatcherType bEventDispatcherMode) { // Disconnect if (NetworkState != ENetworkState.NOT_CONNECTED) { Disconnect(); } // Remove existing Dispatcher AbstractBEventDispatcher bEventDispatcher = FindObjectOfType <AbstractBEventDispatcher>(); if (bEventDispatcher) { RemoveBEventDispatcher(bEventDispatcher); } // Add new Dispatcher if (AddBeventDispatcher(bEventDispatcherMode)) { BEventsCollection.NETWORK_NewBEventDispatcherSet.Invoke(new BEHandle <AbstractBEventDispatcher>(BEventDispatcher)); } }