feat(wip): player properties

This commit is contained in:
2024-04-29 09:12:42 +03:00
parent accd442388
commit b4cba20d82
14 changed files with 110 additions and 93 deletions
@@ -86,7 +86,6 @@ public sealed class AuthorizationOperation: BaseOperation
var playerId = context.LobbyPlayer.Id;
var playerName = context.LobbyPlayer.Name;
var playerPayload = context.LobbyPlayer.Payload;
_writer.Clear();
@@ -5,7 +5,6 @@ using Ragon.Server.Lobby;
namespace Ragon.Server.Handler
{
public class PlayerDataOperation : BaseOperation
{
private readonly ILogger _logger = LogManager.GetCurrentClassLogger();
@@ -24,20 +23,8 @@ namespace Ragon.Server.Handler
var playerDataLen = Reader.ReadUShort();
var playerData = Reader.ReadBytes(playerDataLen);
var roomPlayer = context.RoomPlayer;
if (roomPlayer != null)
{
roomPlayer.UserData.Data = playerData;
return;
}
var lobbyPlayer = context.RoomPlayer;
if (lobbyPlayer != null)
{
lobbyPlayer.UserData.Data = playerData;
}
context.UserData.Data = playerData;
}
}
}
@@ -14,7 +14,6 @@
* limitations under the License.
*/
using NLog;
using Ragon.Protocol;
using Ragon.Server.IO;
@@ -28,22 +27,11 @@ public sealed class RoomDataOperation : BaseOperation
public override void Handle(RagonContext context, NetworkChannel channel)
{
var player = context.RoomPlayer;
var playerDataLen = Reader.ReadUShort();
var playerData = Reader.ReadBytes(playerDataLen);
var room = context.Room;
var data = Reader.RawData;
var dataSize = data.Length - 1;
var headerSize = 3;
var size = headerSize + dataSize;
var sendData = new byte[size];
var peerId = player.Connection.Id;
sendData[0] = (byte)RagonOperation.REPLICATE_RAW_DATA;
sendData[1] = (byte)peerId;
sendData[2] = (byte)(peerId >> 8);
Array.Copy(data, 1, sendData, headerSize, dataSize);
room.Broadcast(sendData, channel);
if (room != null)
room.UserData.Data = playerData;
}
}