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); } }
public void Awake() { if (Instance != this) { Instance = this; DontDestroyOnLoad(gameObject); _playerInfo = new PlayerPacket(SteamAPI.GetUserName(), SteamAPI.GetUserID()); _currentScene = SceneManager.GetActiveScene().name; } }
public void UpdatePlayerPacket() { _playerInfo.avatarHash = ModelSaberAPI.cachedAvatars.FirstOrDefault(x => x.Value == CustomAvatar.Plugin.Instance.PlayerAvatarManager.GetCurrentAvatar()).Key; if (_playerInfo.avatarHash == null) { _playerInfo.avatarHash = "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"; } _playerInfo.playerName = SteamAPI.GetUserName(); _playerInfo.playerId = SteamAPI.GetUserID(); WorldController.CharacterPosition pos = WorldController.GetCharacterInfo(); _playerInfo.headPos = pos.headPos; _playerInfo.headRot = pos.headRot; _playerInfo.leftHandPos = pos.leftHandPos; _playerInfo.leftHandRot = pos.leftHandRot; _playerInfo.rightHandPos = pos.rightHandPos; _playerInfo.rightHandRot = pos.rightHandRot; }