private void MakeRoomContainer(NeutronRoom room) { if (Neutron.Server.MatchmakingMode == MatchmakingMode.Room || Neutron.Server.MatchmakingMode == MatchmakingMode.All) { if (room.Scene == null) { string containerName = $"Room({room.Id}) - [Container] - {SceneHelper.GetSideTag(IsServer)}"; //* Cria um container(scene) para a nova sala, somente se não existir um. room.Scene = SceneHelper.CreateContainer(containerName, Neutron.Server.LocalPhysicsMode); GameObject matchManager = SceneHelper.MakeMatchmakingManager(room.Owner, IsServer, Server); SceneHelper.MoveToContainer(matchManager, containerName); //* Registra os objetos de cena. NeutronSceneObject.OnSceneObjectRegister(room.Owner, IsServer, room.Scene, MatchmakingMode.Room, room, Server); } } }
private void MakeContainerOnChannels() { foreach (var channel in Neutron.Server.ChannelsById.Values) { MakeProperties(channel); MakeVirtualOwner(channel, channel, null); if (Neutron.Server.MatchmakingMode == MatchmakingMode.Channel || Neutron.Server.MatchmakingMode == MatchmakingMode.All) { string containerName = $"Channel({channel.Id}) - [Container] - {SceneHelper.GetSideTag(IsServer)}"; //* Cria um container(scene) para a nova sala, somente se não existir um. channel.Scene = SceneHelper.CreateContainer(containerName, Neutron.Server.LocalPhysicsMode); GameObject matchManager = SceneHelper.MakeMatchmakingManager(channel.Owner, true, Neutron.Server.Instance); SceneHelper.MoveToContainer(matchManager, containerName); //* Registra os objetos de cena. NeutronSceneObject.OnSceneObjectRegister(channel.Owner, IsServer, channel.Scene, MatchmakingMode.Channel, channel, Server); } MakeContainerOnRooms(channel); } }
//* Inicializa o cliente e registra os eventos de Neutron. protected void Initialize(ClientMode clientMode) { This = (Neutron)this; ClientMode = clientMode; Internal_OnNeutronConnected += OnNeutronConnected; Internal_OnNeutronAuthenticated += OnNeutronAuthenticated; Internal_OnPlayerConnected += OnPlayerConnected; Internal_OnPlayerDisconnected += OnPlayerDisconnected; Internal_OnMessageReceived += OnMessageReceived; Internal_OnChannelsReceived += OnChannelsReceived; Internal_OnRoomsReceived += OnRoomsReceived; Internal_OnRoomPropertiesChanged += OnRoomPropertiesChanged; Internal_OnPlayerPropertiesChanged += OnPlayerPropertiesChanged; Internal_OnPlayerNicknameChanged += OnPlayerNicknameChanged; Internal_OnPlayerCustomPacketReceived += OnPlayerCustomPacketReceived; Internal_OnPlayerCreatedRoom += OnPlayerCreatedRoom; Internal_OnPlayerJoinedChannel += OnPlayerJoinedChannel; Internal_OnPlayerJoinedRoom += OnPlayerJoinedRoom; Internal_OnPlayerLeftChannel += OnPlayerLeftChannel; Internal_OnPlayerLeftRoom += OnPlayerLeftRoom; Internal_OnError += OnError; //* Define nome da cena principal do cliente. _sceneName = $"Client(Container) - {SceneHelper.GetSideTag(IsServer)} - [{clientMode}] - ({UnityEngine.Random.Range(1, int.MaxValue)})"; }