public override void OnJoinedRoom() { // trigger events bool isPrivate = false; string gamemode = ""; if (PhotonNetwork.CurrentRoom != null) { var currentRoom = PhotonNetwork.NetworkingClient.CurrentRoom; isPrivate = !currentRoom.IsVisible || currentRoom.CustomProperties.ContainsKey("Description"); // Room Browser rooms if (currentRoom.CustomProperties.TryGetValue("gameMode", out var gamemodeObject)) { gamemode = gamemodeObject as string; } } Events.RoomJoinedArgs args = new Events.RoomJoinedArgs { isPrivate = isPrivate, Gamemode = gamemode }; events.TriggerRoomJoin(args); lastRoom = args; var table = new Hashtable(); var mods = new DataClass(); mods.installedIDs = BepInEx.Bootstrap.Chainloader.PluginInfos.Select(x => x.Value.Metadata.GUID).ToArray(); table.Add("mods", JsonUtility.ToJson(mods)); PhotonNetwork.LocalPlayer.SetCustomProperties(table); RoomUtils.ResetQueue(); }
void OnRoomJoin(object sender, Events.RoomJoinedArgs args) { string gamemode = args.Gamemode; if (PhotonNetwork.IsMasterClient) { foreach (Gamemode g in Gamemodes.Where(x => x.GameManager != null)) { if (gamemode.Contains(g.ID)) { GameObject go = PhotonNetwork.InstantiateRoomObject(BasePrefabPath + g.ID, Vector3.zero, Quaternion.identity); go.SetActive(true); break; } } } foreach (var pluginInfo in pluginInfos) { if (pluginInfo.Gamemodes.Any(x => gamemode.Contains(x.GamemodeString))) { try { pluginInfo.OnGamemodeJoin?.Invoke(gamemode); } catch (Exception e) { Debug.LogError(e); } } } }
public override void OnLeftRoom() { if (lastRoom != null) { events.TriggerRoomLeft(lastRoom); lastRoom = null; } }
void OnRoomLeft(object sender, Events.RoomJoinedArgs args) { string gamemode = args.Gamemode; foreach (var pluginInfo in pluginInfos) { if (pluginInfo.Gamemodes.Any(x => gamemode.Contains(x.GamemodeString))) { try { pluginInfo.OnGamemodeLeave?.Invoke(gamemode); } catch (Exception e) { Debug.LogError(e); } } } }