@@ -21,8 +21,8 @@ class PlayerController : MonoBehaviour
21
21
{
22
22
public static PlayerController Instance ;
23
23
24
- public PlayerInfo _playerInfo ;
25
- private Dictionary < ulong , PlayerInfo > _connectedPlayers = new Dictionary < ulong , PlayerInfo > ( ) ;
24
+ public PlayerPacket _playerInfo ;
25
+ private Dictionary < ulong , PlayerPacket > _connectedPlayers = new Dictionary < ulong , PlayerPacket > ( ) ;
26
26
private Dictionary < ulong , AvatarController > _connectedPlayerAvatars = new Dictionary < ulong , AvatarController > ( ) ;
27
27
private string _currentScene ;
28
28
@@ -42,7 +42,7 @@ public void Awake()
42
42
Instance = this ;
43
43
DontDestroyOnLoad ( gameObject ) ;
44
44
45
- _playerInfo = new PlayerInfo ( SteamAPI . GetUserName ( ) , SteamAPI . GetUserID ( ) ) ;
45
+ _playerInfo = new PlayerPacket ( SteamAPI . GetUserName ( ) , SteamAPI . GetUserID ( ) ) ;
46
46
_currentScene = SceneManager . GetActiveScene ( ) . name ;
47
47
}
48
48
}
@@ -51,13 +51,13 @@ public void StartBroadcasting()
51
51
{
52
52
if ( isBroadcasting ) { return ; }
53
53
isBroadcasting = true ;
54
- InvokeRepeating ( "BroadcastPlayerInfo " , 0f , GameController . TPS ) ;
54
+ InvokeRepeating ( "BroadcastPlayerPacket " , 0f , GameController . TPS ) ;
55
55
}
56
56
public void StopBroadcasting ( )
57
57
{
58
58
if ( ! isBroadcasting ) { return ; }
59
59
isBroadcasting = false ;
60
- CancelInvoke ( "BroadcastPlayerInfo " ) ;
60
+ CancelInvoke ( "BroadcastPlayerPacket " ) ;
61
61
}
62
62
63
63
public void RestartBroadcasting ( )
@@ -95,15 +95,15 @@ public void UpdatePlayerScoring(string fieldName, uint value)
95
95
}
96
96
}
97
97
98
- public List < PlayerInfo > GetConnectedPlayerInfos ( )
98
+ public List < PlayerPacket > GetConnectedPlayerPackets ( )
99
99
{
100
- List < PlayerInfo > scores = new List < PlayerInfo > ( ) ;
101
- scores . AddRange ( _connectedPlayers . Values . ToList < PlayerInfo > ( ) ) ;
100
+ List < PlayerPacket > scores = new List < PlayerPacket > ( ) ;
101
+ scores . AddRange ( _connectedPlayers . Values . ToList < PlayerPacket > ( ) ) ;
102
102
scores . Add ( _playerInfo ) ;
103
103
return scores ;
104
104
}
105
105
106
- public void UpdatePlayerInfo ( )
106
+ public void UpdatePlayerPacket ( )
107
107
{
108
108
_playerInfo . avatarHash = ModelSaberAPI . cachedAvatars . FirstOrDefault ( x => x . Value == CustomAvatar . Plugin . Instance . PlayerAvatarManager . GetCurrentAvatar ( ) ) . Key ;
109
109
if ( _playerInfo . avatarHash == null ) _playerInfo . avatarHash = "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" ;
@@ -146,12 +146,12 @@ public Dictionary<string, float> GetConnectedPlayerDownloadStatus()
146
146
connectedPlayerStatus . Add ( _playerInfo . playerName , _playerInfo . Ready ? 1f : _playerInfo . playerProgress ) ;
147
147
for ( int i = 0 ; i < _connectedPlayers . Count ; i ++ )
148
148
{
149
- PlayerInfo info = _connectedPlayers . Values . ToArray ( ) [ i ] ;
149
+ PlayerPacket info = _connectedPlayers . Values . ToArray ( ) [ i ] ;
150
150
connectedPlayerStatus . Add ( info . playerName , info . Ready ? 1f : info . playerProgress ) ;
151
151
}
152
152
return connectedPlayerStatus ;
153
153
}
154
- public void UpsertPlayer ( PlayerInfo info )
154
+ public void UpsertPlayer ( PlayerPacket info )
155
155
{
156
156
if ( info . playerId == _playerInfo . playerId ) { return ; }
157
157
try
@@ -162,7 +162,7 @@ public void UpsertPlayer(PlayerInfo info)
162
162
if ( ( Config . Instance . AvatarsInLobby && Plugin . instance . CurrentScene == "Menu" ) || ( Config . Instance . AvatarsInGame && Plugin . instance . CurrentScene == "GameCore" ) )
163
163
{
164
164
AvatarController avatar = new GameObject ( "AvatarController" ) . AddComponent < AvatarController > ( ) ;
165
- avatar . SetPlayerInfo ( info , new Vector3 ( 0 , 0 , 0 ) , info . playerId == _playerInfo . playerId ) ;
165
+ avatar . SetPlayerPacket ( info , new Vector3 ( 0 , 0 , 0 ) , info . playerId == _playerInfo . playerId ) ;
166
166
_connectedPlayerAvatars . Add ( info . playerId , avatar ) ;
167
167
}
168
168
MultiplayerLobby . RefreshScores ( ) ;
@@ -189,7 +189,7 @@ public void UpsertPlayer(PlayerInfo info)
189
189
offset = new Vector3 ( ( Array . IndexOf ( playerInfosByID , info . playerId ) - Array . IndexOf ( playerInfosByID , _playerInfo . playerId ) ) * 2f , 0 , Math . Abs ( ( Array . IndexOf ( playerInfosByID , info . playerId ) - Array . IndexOf ( playerInfosByID , _playerInfo . playerId ) ) * 2.5f ) ) ;
190
190
}
191
191
192
- _connectedPlayerAvatars [ info . playerId ] . SetPlayerInfo ( info , offset , info . playerId == _playerInfo . playerId ) ;
192
+ _connectedPlayerAvatars [ info . playerId ] . SetPlayerPacket ( info , offset , info . playerId == _playerInfo . playerId ) ;
193
193
}
194
194
bool changedReady = ( _connectedPlayers [ info . playerId ] . Ready != info . Ready || _connectedPlayers [ info . playerId ] . playerProgress != info . playerProgress ) ;
195
195
_connectedPlayers [ info . playerId ] = info ;
@@ -228,12 +228,12 @@ public List<ulong> GetConnectedPlayers()
228
228
{
229
229
return _connectedPlayers . Keys . ToList ( ) ;
230
230
}
231
- void BroadcastPlayerInfo ( )
231
+ void BroadcastPlayerPacket ( )
232
232
{
233
233
try
234
234
{
235
- UpdatePlayerInfo ( ) ;
236
- SteamAPI . SendPlayerInfo ( _playerInfo ) ;
235
+ UpdatePlayerPacket ( ) ;
236
+ SteamAPI . SendPlayerPacket ( _playerInfo ) ;
237
237
} catch ( Exception e )
238
238
{
239
239
Data . Logger . Error ( e ) ;
@@ -262,7 +262,7 @@ void Update()
262
262
if ( SteamNetworking . ReadP2PPacket ( buffer , size , out bytesRead , out remoteId ) )
263
263
{
264
264
var message = Encoding . UTF8 . GetString ( buffer ) . Replace ( " " , "" ) ;
265
- PlayerInfo info = new PlayerInfo ( message ) ;
265
+ PlayerPacket info = new PlayerPacket ( message ) ;
266
266
if ( info . playerId != SteamAPI . GetUserID ( ) && SteamAPI . getLobbyID ( ) . m_SteamID != 0 )
267
267
{
268
268
UpsertPlayer ( info ) ;
0 commit comments