/* On Clients */ private void On_NETWORK_PlayerJoined(BEHandle <EPlayerID, EControllerID> handle) { if (ARE_NOT_EQUAL(localNetworkID, handle.InvokingNetworkID) && ARE_NOT_EQUAL(localNetworkID, ENetworkID.HOST) && InputManager.Instance.IsControllerConnected(handle.Arg2) == false) { // Connect Controller InputManager.Instance.ConnectController(handle.Arg2); // Update Party Map if (IS_KEY_NOT_CONTAINED(partyMap, handle.Arg2)) { partyMap.Add(handle.Arg2, handle.Arg1); } // Join Player IS_TRUE(PlayerManager.Instance.JoinPlayer(handle.Arg1, handle.Arg2)); // Spawn Player ENetworkID networkID = BUtils.GetNetworkIDFrom(handle.Arg2); AbstractNetPlayer newPlayer = (AbstractNetPlayer)PlayerManager.Instance.SpawnPlayer(handle.Arg1); if (IS_NOT_NULL(newPlayer) && IS_NOT_NONE(networkID)) { newPlayer.SetOwner(networkID); } } }
private IEnumerator JoinConnectedPlayerCoroutine(BEHandle <ENetworkID> handle, EControllerID newControllerID) { // Wait a delay yield return(new WaitForSeconds(1.0f)); // Connect Controller InputManager.Instance.ConnectController(newControllerID); // Join Player EPlayerID newPlayerID = PlayerManager.Instance.JoinPlayer(newControllerID); // TODO : Move to OnButtonPressed if (IS_NOT_NONE(newPlayerID)) { // Spawn Player AbstractNetPlayer newPlayer = (AbstractNetPlayer)PlayerManager.Instance.SpawnPlayer(newPlayerID); if (IS_NOT_NULL(newPlayer)) { newPlayer.SetOwner(handle.Arg1); } // Update map partyMap.Add(newControllerID, newPlayerID); // Replicate all connected net controllers to all other clients (Refresh) foreach (ENetworkID networkIDitr in BEventManager.Instance.GetConnectedNetworkIDs()) { if (networkIDitr != localNetworkID) // != Host { foreach (KeyValuePair <EControllerID, EPlayerID> pair in partyMap) { BEventsCollection.NETWORK_PlayerJoined.Invoke(new BEHandle <EPlayerID, EControllerID>(pair.Value, pair.Key), BEventReplicationType.TO_TARGET, true, networkIDitr); } } } } }