void Update() { uint size; try { while (SteamNetworking.IsP2PPacketAvailable(out size)) { var buffer = new byte[size]; uint bytesRead; CSteamID remoteId; if (SteamNetworking.ReadP2PPacket(buffer, size, out bytesRead, out remoteId)) { var message = Encoding.UTF8.GetString(buffer).Replace(" ", ""); PlayerPacket info = new PlayerPacket(message); if (info.playerId != SteamAPI.GetUserID() && SteamAPI.getLobbyID().m_SteamID != 0) { UpsertPlayer(info); } } } } catch (Exception e) { Logger.Error(e); } }
private void SceneLoaded(Scene to, LoadSceneMode mode) { Logger.Debug($"Scene loaded: \"{to.name}\""); if (to.name == "MenuCore") { PluginUI.Init(); GameController.Init(to); LeaderboardController.Init(to); Controllers.PlayerController.Init(to); VoiceChatWorker.Init(); } try { if (to.name == "MenuCore" && SteamAPI.getLobbyID().m_SteamID > 0) { Logger.Debug("Creating new lobby"); SteamAPI.CreateLobby(!Config.Instance.IsPublic); Controllers.PlayerController.Instance.DestroyAvatars(); } } catch (Exception e) { Logger.Error(e); } }
private void SceneLoaded(Scene to, LoadSceneMode mode) { try { if (to.name == "Menu" && SteamAPI.getLobbyID().m_SteamID > 0) { Logger.Debug("Creating new lobby"); SteamAPI.CreateLobby(!Config.Instance.IsPublic); Controllers.PlayerController.Instance.DestroyAvatars(); } } catch (Exception e) { Logger.Error(e); } }