// ------------------------------------------------------------------------------- // Awake // ------------------------------------------------------------------------------- void Awake() { singleton = this; debug = new DebugHelper(); debug.Init(); networkManager = GetComponent <OpenMMO.Network.NetworkManager>(); networkTransport = GetComponent <Mirror.TelepathyTransport>(); if (!active || GetIsMainZone || networkManager == null || networkTransport == null) { return; } int tmpIndex = 0; foreach (NetworkZoneTemplate template in subZones) { tmpIndex++; if (zoneIndex == tmpIndex) { InitAsSubZone(template, tmpIndex); } } }
// ------------------------------------------------------------------------------- // Awake // ------------------------------------------------------------------------------- void Awake() { singleton = this; debug = new DebugHelper(); debug.Init(); networkManager = GetComponent <OpenMMO.Network.NetworkManager>(); networkTransport = GetComponent <Mirror.TelepathyTransport>(); originalPort = networkTransport.port; SceneManager.sceneLoaded += OnSceneLoaded; if (!active || GetIsMainZone || !GetCanSwitchZone) { currentZone = mainZone; debug.LogFormat(this.name, nameof(Awake), "mainZone"); //DEBUG return; } currentZone = subZones[zoneIndex]; foreach (NetworkZoneTemplate template in subZones) { if (template == currentZone) { InitAsSubZone(template); } } }
// ------------------------------------------------------------------------------- // Awake // ------------------------------------------------------------------------------- /// <summary> /// <c>Awake</c> function that sets the singleton and starts the network manager. /// </summary> public override void Awake() { singleton = this; base.Awake(); // required AwakePriority(); // must be first Invoke(nameof(AwakeLate), 0.25f); // delay a bit so other awakes are called first }
/// <summary> /// Removes event listeners from NetworkManager again and clears up NetworkManager reference. /// </summary> void OnDestroy() { if (networkManager == null) { return; } networkManager.eventListeners.OnStartServer.RemoveListener(OnStartServer); networkManager.eventListeners.OnStopServer.RemoveListener(OnStopServer); networkManager.eventListeners.OnStopClient.RemoveListener(OnStopClient); networkManager = null; }
/// <summary> /// Sets reference to NetworkManager and adds event listeners to it. /// </summary> void Awake() { singleton = this; debug = new DebugHelper(); if (!GetIsActive) { return; } networkManager = FindObjectOfType <OpenMMO.Network.NetworkManager>(); networkManager.eventListeners.OnStartServer.AddListener(OnStartServer); networkManager.eventListeners.OnStopServer.AddListener(OnStopServer); networkManager.eventListeners.OnStopClient.AddListener(OnStopClient); }
// ------------------------------------------------------------------------------- // Awake // ------------------------------------------------------------------------------- public override void Awake() { singleton = this; base.Awake(); // required this.InvokeInstanceDevExtMethods("AwakePriority"); // must be first // -- decide how to start #if _SERVER && _CLIENT StartHost(); #elif _SERVER StartServer(); #else StartClient(); #endif this.InvokeInstanceDevExtMethods(nameof(Awake)); // must be last }
// ------------------------------------------------------------------------------- // Awake // ------------------------------------------------------------------------------- /// <summary> /// <c>Awake</c> function that sets the singleton and starts the network manager. /// </summary> public override void Awake() { singleton = this; base.Awake(); // required AwakePriority(); // must be first // -- decide how to start #if _SERVER && _CLIENT StartHost(); #elif _SERVER if (GetComponent <PortalManager>() != null && GetComponent <PortalManager>().GetIsMainZone) { StartServer(); } #else StartClient(); #endif this.InvokeInstanceDevExtMethods(nameof(Awake)); //HOOK // must be last }