feat: player/room user data now available on joined event
This commit is contained in:
@@ -71,15 +71,15 @@ namespace Ragon.Client
|
|||||||
internal bool PropertiesChanged => _propertiesChanged;
|
internal bool PropertiesChanged => _propertiesChanged;
|
||||||
internal ushort SceneId => _sceneId;
|
internal ushort SceneId => _sceneId;
|
||||||
|
|
||||||
private ushort _sceneId;
|
private readonly ushort _sceneId;
|
||||||
private bool _propertiesChanged;
|
private bool _propertiesChanged;
|
||||||
|
|
||||||
private RagonPayload _spawnPayload;
|
private RagonPayload _spawnPayload;
|
||||||
private RagonPayload _destroyPayload;
|
private RagonPayload _destroyPayload;
|
||||||
|
|
||||||
private readonly Dictionary<int, OnEventDelegate> _events = new Dictionary<int, OnEventDelegate>();
|
private readonly Dictionary<int, OnEventDelegate> _events = new();
|
||||||
private readonly Dictionary<int, List<Action<RagonPlayer, IRagonEvent>>> _localListeners = new Dictionary<int, List<Action<RagonPlayer, IRagonEvent>>>();
|
private readonly Dictionary<int, List<Action<RagonPlayer, IRagonEvent>>> _localListeners = new();
|
||||||
private readonly Dictionary<int, List<Action<RagonPlayer, IRagonEvent>>> _listeners = new Dictionary<int, List<Action<RagonPlayer, IRagonEvent>>>();
|
private readonly Dictionary<int, List<Action<RagonPlayer, IRagonEvent>>> _listeners = new();
|
||||||
|
|
||||||
public RagonEntity(ushort type = 0, ushort sceneId = 0, bool replicated = true)
|
public RagonEntity(ushort type = 0, ushort sceneId = 0, bool replicated = true)
|
||||||
{
|
{
|
||||||
@@ -125,7 +125,14 @@ namespace Ragon.Client
|
|||||||
return payload;
|
return payload;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Prepare(RagonClient client, ushort entityId, ushort entityType, bool hasAuthority, RagonPlayer player, RagonPayload payload)
|
public void Prepare(
|
||||||
|
RagonClient client,
|
||||||
|
ushort entityId,
|
||||||
|
ushort entityType,
|
||||||
|
bool hasAuthority,
|
||||||
|
RagonPlayer player,
|
||||||
|
RagonPayload payload
|
||||||
|
)
|
||||||
{
|
{
|
||||||
Type = entityType;
|
Type = entityType;
|
||||||
Id = entityId;
|
Id = entityId;
|
||||||
|
|||||||
@@ -39,8 +39,6 @@ public struct RoomParameters
|
|||||||
|
|
||||||
internal class JoinSuccessHandler : IHandler
|
internal class JoinSuccessHandler : IHandler
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
private readonly RagonListenerList _listenerList;
|
private readonly RagonListenerList _listenerList;
|
||||||
private readonly RagonPlayerCache _playerCache;
|
private readonly RagonPlayerCache _playerCache;
|
||||||
private readonly RagonEntityCache _entityCache;
|
private readonly RagonEntityCache _entityCache;
|
||||||
@@ -62,19 +60,39 @@ internal class JoinSuccessHandler : IHandler
|
|||||||
public void Handle(RagonBuffer reader)
|
public void Handle(RagonBuffer reader)
|
||||||
{
|
{
|
||||||
var roomId = reader.ReadString();
|
var roomId = reader.ReadString();
|
||||||
var localId = reader.ReadString();
|
|
||||||
var ownerId = reader.ReadString();
|
|
||||||
var min = reader.ReadUShort();
|
var min = reader.ReadUShort();
|
||||||
var max = reader.ReadUShort();
|
var max = reader.ReadUShort();
|
||||||
var sceneName = reader.ReadString();
|
var sceneName = reader.ReadString();
|
||||||
|
var localId = reader.ReadString();
|
||||||
|
var ownerId = reader.ReadString();
|
||||||
|
|
||||||
|
_playerCache.SetOwnerAndLocal(ownerId, localId);
|
||||||
|
|
||||||
var scene = new RagonScene(_client, _playerCache, _entityCache, sceneName);
|
var scene = new RagonScene(_client, _playerCache, _entityCache, sceneName);
|
||||||
var roomInfo = new RoomParameters(roomId, localId, ownerId, min, max);
|
var roomInfo = new RoomParameters(roomId, localId, ownerId, min, max);
|
||||||
var room = new RagonRoom(_client, _entityCache, _playerCache, roomInfo, scene);
|
var room = new RagonRoom(_client, _entityCache, _playerCache, roomInfo, scene);
|
||||||
|
|
||||||
_playerCache.SetOwnerAndLocal(ownerId, localId);
|
room.UserData.Read(reader);
|
||||||
_client.AssignRoom(room);
|
|
||||||
|
|
||||||
|
var playersCount = reader.ReadUShort();
|
||||||
|
RagonLog.Trace("Players: " + playersCount);
|
||||||
|
for (var i = 0; i < playersCount; i++)
|
||||||
|
{
|
||||||
|
var playerPeerId = reader.ReadUShort();
|
||||||
|
var playerId = reader.ReadString();
|
||||||
|
var playerName = reader.ReadString();
|
||||||
|
|
||||||
|
var player = _playerCache.AddPlayer(playerPeerId, playerId, playerName);
|
||||||
|
|
||||||
|
player.UserData.Read(reader);
|
||||||
|
|
||||||
|
RagonLog.Trace($"Player {playerPeerId} - {playerId} - {playerName}");
|
||||||
|
}
|
||||||
|
|
||||||
|
_client.AssignRoom(room);
|
||||||
|
_client.SetStatus(RagonStatus.ROOM);
|
||||||
|
|
||||||
|
_listenerList.OnJoined();
|
||||||
_listenerList.OnSceneRequest(sceneName);
|
_listenerList.OnSceneRequest(sceneName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -46,19 +46,6 @@ internal class SnapshotHandler : IHandler
|
|||||||
public void Handle(RagonBuffer buffer)
|
public void Handle(RagonBuffer buffer)
|
||||||
{
|
{
|
||||||
var entities = new List<RagonEntity>();
|
var entities = new List<RagonEntity>();
|
||||||
var playersCount = buffer.ReadUShort();
|
|
||||||
RagonLog.Trace("Players: " + playersCount);
|
|
||||||
for (var i = 0; i < playersCount; i++)
|
|
||||||
{
|
|
||||||
var playerPeerId = buffer.ReadUShort();
|
|
||||||
var playerId = buffer.ReadString();
|
|
||||||
var playerName = buffer.ReadString();
|
|
||||||
|
|
||||||
_playerCache.AddPlayer(playerPeerId, playerId, playerName);
|
|
||||||
|
|
||||||
RagonLog.Trace($"Player {playerPeerId} - {playerId} - {playerName}");
|
|
||||||
}
|
|
||||||
|
|
||||||
var dynamicEntities = buffer.ReadUShort();
|
var dynamicEntities = buffer.ReadUShort();
|
||||||
RagonLog.Trace("Dynamic Entities: " + dynamicEntities);
|
RagonLog.Trace("Dynamic Entities: " + dynamicEntities);
|
||||||
for (var i = 0; i < dynamicEntities; i++)
|
for (var i = 0; i < dynamicEntities; i++)
|
||||||
@@ -123,12 +110,6 @@ internal class SnapshotHandler : IHandler
|
|||||||
entities.Add(entity);
|
entities.Add(entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_client.Status == RagonStatus.LOBBY)
|
|
||||||
{
|
|
||||||
_client.SetStatus(RagonStatus.ROOM);
|
|
||||||
_listenerList.OnJoined();
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach (var entity in entities)
|
foreach (var entity in entities)
|
||||||
entity.Attach();
|
entity.Attach();
|
||||||
|
|
||||||
|
|||||||
@@ -18,5 +18,5 @@ namespace Ragon.Client;
|
|||||||
|
|
||||||
public interface IRagonDataListener
|
public interface IRagonDataListener
|
||||||
{
|
{
|
||||||
public void OnData(RagonPlayer player, byte[] data);
|
public void OnData(RagonClient client, RagonPlayer player, byte[] data);
|
||||||
}
|
}
|
||||||
@@ -2,5 +2,5 @@ namespace Ragon.Client;
|
|||||||
|
|
||||||
public interface IRagonRoomListListener
|
public interface IRagonRoomListListener
|
||||||
{
|
{
|
||||||
public void OnRoomListUpdate(IReadOnlyList<RagonRoomInformation> roomsInfos);
|
public void OnRoomListUpdate(RagonClient client, IReadOnlyList<RagonRoomInformation> roomsInfos);
|
||||||
}
|
}
|
||||||
@@ -298,13 +298,13 @@ namespace Ragon.Client
|
|||||||
public void OnData(RagonPlayer player, byte[] data)
|
public void OnData(RagonPlayer player, byte[] data)
|
||||||
{
|
{
|
||||||
foreach (var listener in _dataListeners)
|
foreach (var listener in _dataListeners)
|
||||||
listener.OnData(player, data);
|
listener.OnData(_client, player, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OnRoomList(RagonRoomInformation[] roomInfos)
|
public void OnRoomList(RagonRoomInformation[] roomInfos)
|
||||||
{
|
{
|
||||||
foreach (var listListener in _roomListListeners)
|
foreach (var listListener in _roomListListeners)
|
||||||
listListener.OnRoomListUpdate(roomInfos);
|
listListener.OnRoomListUpdate(_client, roomInfos);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OnRoomUserData(IReadOnlyList<string> changes)
|
public void OnRoomUserData(IReadOnlyList<string> changes)
|
||||||
|
|||||||
@@ -52,10 +52,10 @@ public sealed class RagonPlayerCache
|
|||||||
_localId = localId;
|
_localId = localId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void AddPlayer(ushort peerId, string playerId, string playerName)
|
public RagonPlayer AddPlayer(ushort peerId, string playerId, string playerName)
|
||||||
{
|
{
|
||||||
if (_playersById.ContainsKey(playerId))
|
if (_playersById.ContainsKey(playerId))
|
||||||
return;
|
return null;
|
||||||
|
|
||||||
var isOwner = playerId == _ownerId;
|
var isOwner = playerId == _ownerId;
|
||||||
var isLocal = playerId == _localId;
|
var isLocal = playerId == _localId;
|
||||||
@@ -73,6 +73,8 @@ public sealed class RagonPlayerCache
|
|||||||
_players.Add(player);
|
_players.Add(player);
|
||||||
_playersById.Add(player.Id, player);
|
_playersById.Add(player.Id, player);
|
||||||
_playersByConnection.Add(player.PeerId, player);
|
_playersByConnection.Add(player.PeerId, player);
|
||||||
|
|
||||||
|
return player;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void RemovePlayer(string playerId)
|
public void RemovePlayer(string playerId)
|
||||||
|
|||||||
@@ -104,7 +104,7 @@ namespace Ragon.Client
|
|||||||
if (_events.TryGetValue(eventCode, out var evnt))
|
if (_events.TryGetValue(eventCode, out var evnt))
|
||||||
evnt?.Invoke(caller, buffer);
|
evnt?.Invoke(caller, buffer);
|
||||||
else
|
else
|
||||||
RagonLog.Warn($"Handler event on entity {Id} with eventCode {eventCode} not defined");
|
RagonLog.Warn($"Handler event {Id} with eventCode {eventCode} not defined");
|
||||||
}
|
}
|
||||||
|
|
||||||
internal void HandleUserData(RagonBuffer buffer)
|
internal void HandleUserData(RagonBuffer buffer)
|
||||||
|
|||||||
@@ -80,6 +80,8 @@ public class RagonScene
|
|||||||
buffer.WriteByte((byte)replicationMode);
|
buffer.WriteByte((byte)replicationMode);
|
||||||
buffer.WriteByte((byte)target);
|
buffer.WriteByte((byte)target);
|
||||||
|
|
||||||
|
evnt.Serialize(buffer);
|
||||||
|
|
||||||
var sendData = buffer.ToArray();
|
var sendData = buffer.ToArray();
|
||||||
_client.Reliable.Send(sendData);
|
_client.Reliable.Send(sendData);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ using Ragon.Protocol;
|
|||||||
|
|
||||||
namespace Ragon.Client
|
namespace Ragon.Client
|
||||||
{
|
{
|
||||||
public class RagonUserData: IUserData
|
public class RagonUserData : IUserData
|
||||||
{
|
{
|
||||||
public byte[] this[string key]
|
public byte[] this[string key]
|
||||||
{
|
{
|
||||||
@@ -49,13 +49,12 @@ namespace Ragon.Client
|
|||||||
|
|
||||||
public bool Dirty => _localChanges.Count > 0;
|
public bool Dirty => _localChanges.Count > 0;
|
||||||
|
|
||||||
private readonly List<string> _localChanges = new ();
|
private readonly List<string> _localChanges = new();
|
||||||
private readonly Dictionary<string, bool> _changesCache = new();
|
private readonly Dictionary<string, bool> _changesCache = new();
|
||||||
private readonly Dictionary<string, byte[]> _properties = new();
|
private readonly Dictionary<string, byte[]> _properties = new();
|
||||||
|
|
||||||
public RagonUserData()
|
public RagonUserData()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public IReadOnlyList<string> Read(RagonBuffer buffer)
|
public IReadOnlyList<string> Read(RagonBuffer buffer)
|
||||||
@@ -70,7 +69,6 @@ namespace Ragon.Client
|
|||||||
{
|
{
|
||||||
var value = buffer.ReadBytes(valueSize);
|
var value = buffer.ReadBytes(valueSize);
|
||||||
_properties[key] = value;
|
_properties[key] = value;
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -91,7 +89,7 @@ namespace Ragon.Client
|
|||||||
buffer.WriteString(propertyChanged);
|
buffer.WriteString(propertyChanged);
|
||||||
if (_properties.TryGetValue(propertyChanged, out var property))
|
if (_properties.TryGetValue(propertyChanged, out var property))
|
||||||
{
|
{
|
||||||
buffer.WriteUShort((ushort) property.Length);
|
buffer.WriteUShort((ushort)property.Length);
|
||||||
buffer.WriteBytes(property);
|
buffer.WriteBytes(property);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
using System;
|
using System;
|
||||||
using Ragon.Server;
|
|
||||||
using Ragon.Server.Entity;
|
using Ragon.Server.Entity;
|
||||||
using Ragon.Server.Plugin;
|
using Ragon.Server.Plugin;
|
||||||
using Ragon.Server.Room;
|
using Ragon.Server.Room;
|
||||||
@@ -34,4 +33,10 @@ public class RelayRoomPlugin: BaseRoomPlugin
|
|||||||
Console.WriteLine($"Entity destroyed: {entity.Id}");
|
Console.WriteLine($"Entity destroyed: {entity.Id}");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override bool OnData(RagonRoomPlayer player, byte[] data)
|
||||||
|
{
|
||||||
|
Console.WriteLine("Data received");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -21,6 +21,7 @@ namespace Ragon.Server.ENetServer;
|
|||||||
|
|
||||||
public sealed class ENetConnection: INetworkConnection
|
public sealed class ENetConnection: INetworkConnection
|
||||||
{
|
{
|
||||||
|
private static ushort _iterator = 0;
|
||||||
public ushort Id { get; }
|
public ushort Id { get; }
|
||||||
public INetworkChannel Reliable { get; private set; }
|
public INetworkChannel Reliable { get; private set; }
|
||||||
public INetworkChannel Unreliable { get; private set; }
|
public INetworkChannel Unreliable { get; private set; }
|
||||||
@@ -30,7 +31,8 @@ public sealed class ENetConnection: INetworkConnection
|
|||||||
{
|
{
|
||||||
_peer = peer;
|
_peer = peer;
|
||||||
|
|
||||||
Id = (ushort) peer.ID;
|
// Id = (ushort) peer.ID;
|
||||||
|
Id = _iterator++;
|
||||||
Reliable = new ENetReliableChannel(peer, NetworkChannel.RELIABLE);
|
Reliable = new ENetReliableChannel(peer, NetworkChannel.RELIABLE);
|
||||||
Unreliable = new ENetUnreliableChannel(peer, NetworkChannel.UNRELIABLE);
|
Unreliable = new ENetUnreliableChannel(peer, NetworkChannel.UNRELIABLE);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,20 +4,63 @@ namespace Ragon.Server.Data;
|
|||||||
|
|
||||||
public class RagonData
|
public class RagonData
|
||||||
{
|
{
|
||||||
private byte[] _data;
|
private readonly Dictionary<string, byte[]> _data = new Dictionary<string, byte[]>();
|
||||||
public bool IsDirty { get; set; }
|
|
||||||
public byte[] Data
|
public bool IsDirty { get; private set; }
|
||||||
|
|
||||||
|
public RagonData()
|
||||||
{
|
{
|
||||||
get => _data;
|
}
|
||||||
set
|
|
||||||
|
public void Read(RagonBuffer buffer)
|
||||||
|
{
|
||||||
|
var len = buffer.ReadUShort();
|
||||||
|
for (int i = 0; i < len; i++)
|
||||||
{
|
{
|
||||||
_data = value;
|
var key = buffer.ReadString();
|
||||||
IsDirty = true;
|
var valueSize = buffer.ReadUShort();
|
||||||
|
if (valueSize > 0)
|
||||||
|
{
|
||||||
|
var value = buffer.ReadBytes(valueSize);
|
||||||
|
_data[key] = value;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_data[key] = Array.Empty<byte>();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public RagonData(byte[] data)
|
public void Write(RagonBuffer buffer)
|
||||||
{
|
{
|
||||||
_data = data;
|
buffer.WriteUShort((ushort)_data.Count);
|
||||||
|
foreach (var prop in _data)
|
||||||
|
{
|
||||||
|
buffer.WriteString(prop.Key);
|
||||||
|
buffer.WriteUShort((ushort)prop.Value.Length);
|
||||||
|
buffer.WriteBytes(prop.Value);
|
||||||
|
}
|
||||||
|
|
||||||
|
var toDelete = _data
|
||||||
|
.Where(p => p.Value.Length == 0)
|
||||||
|
.Select(p => p.Key);
|
||||||
|
|
||||||
|
foreach (var prop in toDelete)
|
||||||
|
_data.Remove(prop);
|
||||||
|
|
||||||
|
IsDirty = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Snapshot(RagonBuffer buffer)
|
||||||
|
{
|
||||||
|
buffer.WriteUShort((ushort)_data.Count);
|
||||||
|
foreach (var prop in _data)
|
||||||
|
{
|
||||||
|
buffer.WriteString(prop.Key);
|
||||||
|
buffer.WriteUShort((ushort)prop.Value.Length);
|
||||||
|
buffer.WriteBytes(prop.Value);
|
||||||
|
|
||||||
|
Console.WriteLine($"Key: {prop.Key} Value: {prop.Value.Length}");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -27,14 +27,7 @@ namespace Ragon.Server.Handler
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var playerUserData = Reader.ReadBytes(Reader.Capacity);
|
context.UserData.Read(Reader);
|
||||||
if (playerUserData.Length > _userDataLimit)
|
|
||||||
{
|
|
||||||
_logger.Warn($"Player {context.Connection.Id} exceeded user data limit");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
context.UserData.Data = playerUserData;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -75,7 +75,7 @@ public sealed class RoomCreateOperation : BaseOperation
|
|||||||
};
|
};
|
||||||
|
|
||||||
var lobbyPlayer = context.LobbyPlayer;
|
var lobbyPlayer = context.LobbyPlayer;
|
||||||
var roomPlayer = new RagonRoomPlayer(context.Connection, lobbyPlayer.Id, lobbyPlayer.Name);
|
var roomPlayer = new RagonRoomPlayer(context, lobbyPlayer.Id, lobbyPlayer.Name);
|
||||||
|
|
||||||
var roomPlugin = _serverPlugin.CreateRoomPlugin(information);
|
var roomPlugin = _serverPlugin.CreateRoomPlugin(information);
|
||||||
var room = new RagonRoom(roomId, information, roomPlugin);
|
var room = new RagonRoom(roomId, information, roomPlugin);
|
||||||
@@ -103,11 +103,23 @@ public sealed class RoomCreateOperation : BaseOperation
|
|||||||
writer.Clear();
|
writer.Clear();
|
||||||
writer.WriteOperation(RagonOperation.JOIN_SUCCESS);
|
writer.WriteOperation(RagonOperation.JOIN_SUCCESS);
|
||||||
writer.WriteString(room.Id);
|
writer.WriteString(room.Id);
|
||||||
writer.WriteString(player.Id);
|
|
||||||
writer.WriteString(room.Owner.Id);
|
|
||||||
writer.WriteUShort((ushort)room.PlayerMin);
|
writer.WriteUShort((ushort)room.PlayerMin);
|
||||||
writer.WriteUShort((ushort)room.PlayerMax);
|
writer.WriteUShort((ushort)room.PlayerMax);
|
||||||
writer.WriteString(room.Scene);
|
writer.WriteString(room.Scene);
|
||||||
|
writer.WriteString(player.Id);
|
||||||
|
writer.WriteString(room.Owner.Id);
|
||||||
|
|
||||||
|
room.UserData.Snapshot(writer);
|
||||||
|
|
||||||
|
writer.WriteUShort((ushort)room.PlayerList.Count);
|
||||||
|
foreach (var roomPlayer in room.PlayerList)
|
||||||
|
{
|
||||||
|
writer.WriteUShort(roomPlayer.Connection.Id);
|
||||||
|
writer.WriteString(roomPlayer.Id);
|
||||||
|
writer.WriteString(roomPlayer.Name);
|
||||||
|
|
||||||
|
roomPlayer.Context.UserData.Snapshot(writer);
|
||||||
|
}
|
||||||
|
|
||||||
var sendData = writer.ToArray();
|
var sendData = writer.ToArray();
|
||||||
player.Connection.Reliable.Send(sendData);
|
player.Connection.Reliable.Send(sendData);
|
||||||
|
|||||||
@@ -1,22 +1,31 @@
|
|||||||
|
using NLog;
|
||||||
using Ragon.Protocol;
|
using Ragon.Protocol;
|
||||||
using Ragon.Server.Event;
|
using Ragon.Server.Event;
|
||||||
using Ragon.Server.IO;
|
using Ragon.Server.IO;
|
||||||
|
using Ragon.Server.Lobby;
|
||||||
|
|
||||||
namespace Ragon.Server.Handler;
|
namespace Ragon.Server.Handler;
|
||||||
|
|
||||||
public class RoomEventOperation : BaseOperation
|
public class RoomEventOperation : BaseOperation
|
||||||
{
|
{
|
||||||
|
private readonly Logger _logger = LogManager.GetCurrentClassLogger();
|
||||||
public RoomEventOperation(RagonBuffer reader, RagonBuffer writer) : base(reader, writer)
|
public RoomEventOperation(RagonBuffer reader, RagonBuffer writer) : base(reader, writer)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Handle(RagonContext context, NetworkChannel channel)
|
public override void Handle(RagonContext context, NetworkChannel channel)
|
||||||
{
|
{
|
||||||
|
if (context.ConnectionStatus == ConnectionStatus.Unauthorized)
|
||||||
|
{
|
||||||
|
_logger.Warn($"Player {context.Connection.Id} not authorized for this request");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
var room = context.Room;
|
var room = context.Room;
|
||||||
var player = context.RoomPlayer;
|
var player = context.RoomPlayer;
|
||||||
|
|
||||||
var eventId = Reader.ReadUShort();
|
var eventId = Reader.ReadUShort();
|
||||||
var replicationMode = (RagonReplicationMode)Reader.ReadByte();
|
var eventMode = (RagonReplicationMode)Reader.ReadByte();
|
||||||
var targetMode = (RagonTarget)Reader.ReadByte();
|
var targetMode = (RagonTarget)Reader.ReadByte();
|
||||||
var targetPlayerPeerId = (ushort)0;
|
var targetPlayerPeerId = (ushort)0;
|
||||||
|
|
||||||
@@ -26,20 +35,12 @@ public class RoomEventOperation : BaseOperation
|
|||||||
var @event = new RagonEvent(player, eventId);
|
var @event = new RagonEvent(player, eventId);
|
||||||
@event.Read(Reader);
|
@event.Read(Reader);
|
||||||
|
|
||||||
Writer.Clear();
|
|
||||||
Writer.WriteUShort(eventId);
|
|
||||||
Writer.WriteUShort(player.Connection.Id);
|
|
||||||
Writer.WriteUShort((ushort) replicationMode);
|
|
||||||
|
|
||||||
var sendData = Writer.ToArray();
|
|
||||||
|
|
||||||
if (targetMode == RagonTarget.Player && room.Players.TryGetValue(targetPlayerPeerId, out var targetPlayer))
|
if (targetMode == RagonTarget.Player && room.Players.TryGetValue(targetPlayerPeerId, out var targetPlayer))
|
||||||
{
|
{
|
||||||
targetPlayer.Connection.Reliable.Send(sendData);
|
room.ReplicateEvent(player, @event, eventMode, targetPlayer);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (var roomPlayer in room.ReadyPlayersList)
|
room.ReplicateEvent(player, @event, eventMode, targetMode);
|
||||||
roomPlayer.Connection.Reliable.Send(sendData);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -46,7 +46,7 @@ public sealed class RoomJoinOperation : BaseOperation
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var player = new RagonRoomPlayer(context.Connection, lobbyPlayer.Id, lobbyPlayer.Name);
|
var player = new RagonRoomPlayer(context, lobbyPlayer.Id, lobbyPlayer.Name);
|
||||||
context.SetRoom(existsRoom, player);
|
context.SetRoom(existsRoom, player);
|
||||||
|
|
||||||
if (!existsRoom.Plugin.OnPlayerJoined(player))
|
if (!existsRoom.Plugin.OnPlayerJoined(player))
|
||||||
@@ -56,6 +56,8 @@ public sealed class RoomJoinOperation : BaseOperation
|
|||||||
|
|
||||||
JoinSuccess(context, existsRoom, Writer);
|
JoinSuccess(context, existsRoom, Writer);
|
||||||
|
|
||||||
|
existsRoom.RestoreBufferedEvents(player);
|
||||||
|
|
||||||
_logger.Trace($"Player {context.Connection.Id}|{context.LobbyPlayer.Name} joined to {existsRoom.Id}");
|
_logger.Trace($"Player {context.Connection.Id}|{context.LobbyPlayer.Name} joined to {existsRoom.Id}");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -64,11 +66,23 @@ public sealed class RoomJoinOperation : BaseOperation
|
|||||||
writer.Clear();
|
writer.Clear();
|
||||||
writer.WriteOperation(RagonOperation.JOIN_SUCCESS);
|
writer.WriteOperation(RagonOperation.JOIN_SUCCESS);
|
||||||
writer.WriteString(room.Id);
|
writer.WriteString(room.Id);
|
||||||
writer.WriteString(context.RoomPlayer.Id);
|
|
||||||
writer.WriteString(room.Owner.Id);
|
|
||||||
writer.WriteUShort((ushort)room.PlayerMin);
|
writer.WriteUShort((ushort)room.PlayerMin);
|
||||||
writer.WriteUShort((ushort)room.PlayerMax);
|
writer.WriteUShort((ushort)room.PlayerMax);
|
||||||
writer.WriteString(room.Scene);
|
writer.WriteString(room.Scene);
|
||||||
|
writer.WriteString(context.RoomPlayer.Id);
|
||||||
|
writer.WriteString(room.Owner.Id);
|
||||||
|
|
||||||
|
room.UserData.Snapshot(writer);
|
||||||
|
|
||||||
|
writer.WriteUShort((ushort)room.PlayerList.Count);
|
||||||
|
foreach (var roomPlayer in room.PlayerList)
|
||||||
|
{
|
||||||
|
writer.WriteUShort(roomPlayer.Connection.Id);
|
||||||
|
writer.WriteString(roomPlayer.Id);
|
||||||
|
writer.WriteString(roomPlayer.Name);
|
||||||
|
|
||||||
|
roomPlayer.Context.UserData.Snapshot(writer);
|
||||||
|
}
|
||||||
|
|
||||||
var sendData = writer.ToArray();
|
var sendData = writer.ToArray();
|
||||||
context.Connection.Reliable.Send(sendData);
|
context.Connection.Reliable.Send(sendData);
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ public sealed class RoomJoinOrCreateOperation : BaseOperation
|
|||||||
|
|
||||||
if (context.Lobby.FindRoomByScene(_roomPayload.Scene, out var existsRoom))
|
if (context.Lobby.FindRoomByScene(_roomPayload.Scene, out var existsRoom))
|
||||||
{
|
{
|
||||||
var player = new RagonRoomPlayer(context.Connection, lobbyPlayer.Id, lobbyPlayer.Name);
|
var player = new RagonRoomPlayer(context, lobbyPlayer.Id, lobbyPlayer.Name);
|
||||||
|
|
||||||
if (!existsRoom.Plugin.OnPlayerJoined(player))
|
if (!existsRoom.Plugin.OnPlayerJoined(player))
|
||||||
return;
|
return;
|
||||||
@@ -62,6 +62,8 @@ public sealed class RoomJoinOrCreateOperation : BaseOperation
|
|||||||
_ragonWebHookPlugin.RoomJoined(context, existsRoom, player);
|
_ragonWebHookPlugin.RoomJoined(context, existsRoom, player);
|
||||||
|
|
||||||
JoinSuccess(player, existsRoom, Writer);
|
JoinSuccess(player, existsRoom, Writer);
|
||||||
|
|
||||||
|
existsRoom.RestoreBufferedEvents(player);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -72,7 +74,7 @@ public sealed class RoomJoinOrCreateOperation : BaseOperation
|
|||||||
Min = _roomPayload.Min,
|
Min = _roomPayload.Min,
|
||||||
};
|
};
|
||||||
|
|
||||||
var roomPlayer = new RagonRoomPlayer(context.Connection, lobbyPlayer.Id, lobbyPlayer.Name);
|
var roomPlayer = new RagonRoomPlayer(context, lobbyPlayer.Id, lobbyPlayer.Name);
|
||||||
var roomPlugin = _serverPlugin.CreateRoomPlugin(information);
|
var roomPlugin = _serverPlugin.CreateRoomPlugin(information);
|
||||||
var room = new RagonRoom(roomId, information, roomPlugin);
|
var room = new RagonRoom(roomId, information, roomPlugin);
|
||||||
|
|
||||||
@@ -96,11 +98,23 @@ public sealed class RoomJoinOrCreateOperation : BaseOperation
|
|||||||
writer.Clear();
|
writer.Clear();
|
||||||
writer.WriteOperation(RagonOperation.JOIN_SUCCESS);
|
writer.WriteOperation(RagonOperation.JOIN_SUCCESS);
|
||||||
writer.WriteString(room.Id);
|
writer.WriteString(room.Id);
|
||||||
|
writer.WriteUShort((ushort)room.PlayerMin);
|
||||||
|
writer.WriteUShort((ushort)room.PlayerMax);
|
||||||
|
writer.WriteString(room.Scene);
|
||||||
writer.WriteString(player.Id);
|
writer.WriteString(player.Id);
|
||||||
writer.WriteString(room.Owner.Id);
|
writer.WriteString(room.Owner.Id);
|
||||||
writer.WriteUShort((ushort) room.PlayerMin);
|
|
||||||
writer.WriteUShort((ushort) room.PlayerMax);
|
room.UserData.Snapshot(writer);
|
||||||
writer.WriteString(room.Scene);
|
|
||||||
|
writer.WriteUShort((ushort)room.PlayerList.Count);
|
||||||
|
foreach (var roomPlayer in room.PlayerList)
|
||||||
|
{
|
||||||
|
writer.WriteUShort(roomPlayer.Connection.Id);
|
||||||
|
writer.WriteString(roomPlayer.Id);
|
||||||
|
writer.WriteString(roomPlayer.Name);
|
||||||
|
|
||||||
|
roomPlayer.Context.UserData.Snapshot(writer);
|
||||||
|
}
|
||||||
|
|
||||||
var sendData = writer.ToArray();
|
var sendData = writer.ToArray();
|
||||||
player.Connection.Reliable.Send(sendData);
|
player.Connection.Reliable.Send(sendData);
|
||||||
|
|||||||
@@ -43,15 +43,8 @@ public sealed class RoomUserDataOperation : BaseOperation
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var roomUserData = Reader.ReadBytes(Reader.Capacity);
|
|
||||||
if (roomUserData.Length > _userDataLimit)
|
|
||||||
{
|
|
||||||
_logger.Warn("Room user data is too big");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
var room = context.Room;
|
var room = context.Room;
|
||||||
if (room != null)
|
if (room != null)
|
||||||
room.UserData.Data = roomUserData;
|
room.UserData.Read(Reader);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -143,13 +143,6 @@ public sealed class SceneLoadedOperation : BaseOperation
|
|||||||
{
|
{
|
||||||
writer.Clear();
|
writer.Clear();
|
||||||
writer.WriteOperation(RagonOperation.SNAPSHOT);
|
writer.WriteOperation(RagonOperation.SNAPSHOT);
|
||||||
writer.WriteUShort((ushort)room.ReadyPlayersList.Count);
|
|
||||||
foreach (var roomPlayer in room.ReadyPlayersList)
|
|
||||||
{
|
|
||||||
writer.WriteUShort(roomPlayer.Connection.Id);
|
|
||||||
writer.WriteString(roomPlayer.Id);
|
|
||||||
writer.WriteString(roomPlayer.Name);
|
|
||||||
}
|
|
||||||
|
|
||||||
var dynamicEntities = room.DynamicEntitiesList;
|
var dynamicEntities = room.DynamicEntitiesList;
|
||||||
var dynamicEntitiesCount = (ushort)dynamicEntities.Count;
|
var dynamicEntitiesCount = (ushort)dynamicEntities.Count;
|
||||||
|
|||||||
@@ -63,5 +63,11 @@ public class BaseRoomPlugin: IRoomPlugin
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public virtual bool OnData(RagonRoomPlayer player, byte[] data)
|
||||||
|
{
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
@@ -30,7 +30,7 @@ public class RagonContext
|
|||||||
public int LimitBufferedEvents { get; private set; }
|
public int LimitBufferedEvents { get; private set; }
|
||||||
public IRagonLobby Lobby { get; private set; }
|
public IRagonLobby Lobby { get; private set; }
|
||||||
public RagonLobbyPlayer? LobbyPlayer { get; private set; }
|
public RagonLobbyPlayer? LobbyPlayer { get; private set; }
|
||||||
public RagonRoom? Room { get; private set; }
|
public RagonRoom Room { get; private set; }
|
||||||
public RagonRoomPlayer? RoomPlayer { get; private set; }
|
public RagonRoomPlayer? RoomPlayer { get; private set; }
|
||||||
public RagonData UserData { get; private set; }
|
public RagonData UserData { get; private set; }
|
||||||
public RagonScheduler Scheduler { get; private set; }
|
public RagonScheduler Scheduler { get; private set; }
|
||||||
@@ -48,7 +48,7 @@ public class RagonContext
|
|||||||
Executor = executor;
|
Executor = executor;
|
||||||
Lobby = lobby;
|
Lobby = lobby;
|
||||||
Scheduler = scheduler;
|
Scheduler = scheduler;
|
||||||
UserData = new RagonData(Array.Empty<byte>());
|
UserData = new RagonData();
|
||||||
}
|
}
|
||||||
|
|
||||||
internal void SetPlayer(RagonLobbyPlayer player)
|
internal void SetPlayer(RagonLobbyPlayer player)
|
||||||
|
|||||||
@@ -73,9 +73,9 @@ public class RagonServer : IRagonServer, INetworkListener
|
|||||||
|
|
||||||
var contextObserver = new RagonContextObserver(_contextsByPlayerId);
|
var contextObserver = new RagonContextObserver(_contextsByPlayerId);
|
||||||
|
|
||||||
_scheduler.Run(new RagonActionTimer(SendRoomList, 1.0f));
|
_scheduler.Run(new RagonActionTimer(SendRoomList, 2.0f));
|
||||||
_scheduler.Run(new RagonActionTimer(SendPlayerUserData, 0.2f));
|
_scheduler.Run(new RagonActionTimer(SendPlayerUserData, 0.1f));
|
||||||
_scheduler.Run(new RagonActionTimer(SendRoomUserData, 0.2f));
|
_scheduler.Run(new RagonActionTimer(SendRoomUserData, 0.1f));
|
||||||
|
|
||||||
_serverPlugin.OnAttached(this);
|
_serverPlugin.OnAttached(this);
|
||||||
|
|
||||||
@@ -257,12 +257,11 @@ public class RagonServer : IRagonServer, INetworkListener
|
|||||||
_writer.Clear();
|
_writer.Clear();
|
||||||
_writer.WriteOperation(RagonOperation.PLAYER_DATA_UPDATED);
|
_writer.WriteOperation(RagonOperation.PLAYER_DATA_UPDATED);
|
||||||
_writer.WriteUShort(value.Connection.Id);
|
_writer.WriteUShort(value.Connection.Id);
|
||||||
_writer.WriteBytes(value.UserData.Data);
|
|
||||||
|
value.UserData.Write(_writer);
|
||||||
|
|
||||||
var sendData = _writer.ToArray();
|
var sendData = _writer.ToArray();
|
||||||
_server.Broadcast(sendData, NetworkChannel.RELIABLE);
|
_server.Broadcast(sendData, NetworkChannel.RELIABLE);
|
||||||
|
|
||||||
value.UserData.IsDirty = false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -275,12 +274,11 @@ public class RagonServer : IRagonServer, INetworkListener
|
|||||||
{
|
{
|
||||||
_writer.Clear();
|
_writer.Clear();
|
||||||
_writer.WriteOperation(RagonOperation.ROOM_DATA_UPDATED);
|
_writer.WriteOperation(RagonOperation.ROOM_DATA_UPDATED);
|
||||||
_writer.WriteBytes(room.UserData.Data);
|
|
||||||
|
room.UserData.Write(_writer);
|
||||||
|
|
||||||
var sendData = _writer.ToArray();
|
var sendData = _writer.ToArray();
|
||||||
_server.Broadcast(sendData, NetworkChannel.RELIABLE);
|
_server.Broadcast(sendData, NetworkChannel.RELIABLE);
|
||||||
|
|
||||||
room.UserData.IsDirty = false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,6 +17,7 @@
|
|||||||
using Ragon.Protocol;
|
using Ragon.Protocol;
|
||||||
using Ragon.Server.Data;
|
using Ragon.Server.Data;
|
||||||
using Ragon.Server.Entity;
|
using Ragon.Server.Entity;
|
||||||
|
using Ragon.Server.Event;
|
||||||
using Ragon.Server.IO;
|
using Ragon.Server.IO;
|
||||||
using Ragon.Server.Plugin;
|
using Ragon.Server.Plugin;
|
||||||
using Ragon.Server.Time;
|
using Ragon.Server.Time;
|
||||||
@@ -47,6 +48,8 @@ public class RagonRoom : IRagonRoom, IRagonAction
|
|||||||
public List<RagonEntity> EntityList { get; private set; }
|
public List<RagonEntity> EntityList { get; private set; }
|
||||||
|
|
||||||
private readonly HashSet<RagonEntity> _entitiesDirtySet;
|
private readonly HashSet<RagonEntity> _entitiesDirtySet;
|
||||||
|
private readonly List<RagonEvent> _bufferedEvents;
|
||||||
|
private readonly int _limitBufferedEvents;
|
||||||
|
|
||||||
public RagonRoom(string roomId, RoomInformation info, IRoomPlugin roomPlugin)
|
public RagonRoom(string roomId, RoomInformation info, IRoomPlugin roomPlugin)
|
||||||
{
|
{
|
||||||
@@ -67,8 +70,10 @@ public class RagonRoom : IRagonRoom, IRagonAction
|
|||||||
EntityList = new List<RagonEntity>();
|
EntityList = new List<RagonEntity>();
|
||||||
|
|
||||||
_entitiesDirtySet = new HashSet<RagonEntity>();
|
_entitiesDirtySet = new HashSet<RagonEntity>();
|
||||||
|
_bufferedEvents = new List<RagonEvent>();
|
||||||
|
_limitBufferedEvents = 1000;
|
||||||
|
|
||||||
UserData = new RagonData(Array.Empty<byte>());
|
UserData = new RagonData();
|
||||||
Writer = new RagonBuffer();
|
Writer = new RagonBuffer();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -93,6 +98,101 @@ public class RagonRoom : IRagonRoom, IRagonAction
|
|||||||
_entitiesDirtySet.Remove(entity);
|
_entitiesDirtySet.Remove(entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void RestoreBufferedEvents(RagonRoomPlayer roomPlayer)
|
||||||
|
{
|
||||||
|
foreach (var evnt in _bufferedEvents)
|
||||||
|
{
|
||||||
|
Writer.Clear();
|
||||||
|
Writer.WriteOperation(RagonOperation.REPLICATE_ROOM_EVENT);
|
||||||
|
Writer.WriteUShort(evnt.EventCode);
|
||||||
|
Writer.WriteUShort(evnt.Invoker.Connection.Id);
|
||||||
|
Writer.WriteByte((byte)RagonReplicationMode.Server);
|
||||||
|
|
||||||
|
evnt.Write(Writer);
|
||||||
|
|
||||||
|
var sendData = Writer.ToArray();
|
||||||
|
roomPlayer.Connection.Reliable.Send(sendData);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void ReplicateEvent(
|
||||||
|
RagonRoomPlayer invoker,
|
||||||
|
RagonEvent evnt,
|
||||||
|
RagonReplicationMode eventMode,
|
||||||
|
RagonRoomPlayer targetPlayer
|
||||||
|
)
|
||||||
|
{
|
||||||
|
var room = Owner.Room;
|
||||||
|
var buffer = room.Writer;
|
||||||
|
|
||||||
|
buffer.Clear();
|
||||||
|
buffer.WriteOperation(RagonOperation.REPLICATE_ROOM_EVENT);
|
||||||
|
buffer.WriteUShort(evnt.EventCode);
|
||||||
|
buffer.WriteUShort(invoker.Connection.Id);
|
||||||
|
buffer.WriteByte((byte)eventMode);
|
||||||
|
|
||||||
|
evnt.Write(buffer);
|
||||||
|
|
||||||
|
var sendData = buffer.ToArray();
|
||||||
|
targetPlayer.Connection.Reliable.Send(sendData);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void ReplicateEvent(
|
||||||
|
RagonRoomPlayer invoker,
|
||||||
|
RagonEvent evnt,
|
||||||
|
RagonReplicationMode eventMode,
|
||||||
|
RagonTarget targetMode
|
||||||
|
)
|
||||||
|
{
|
||||||
|
if (eventMode == RagonReplicationMode.Buffered && targetMode != RagonTarget.Owner && _bufferedEvents.Count < _limitBufferedEvents)
|
||||||
|
{
|
||||||
|
_bufferedEvents.Add(evnt);
|
||||||
|
}
|
||||||
|
|
||||||
|
Writer.Clear();
|
||||||
|
Writer.WriteOperation(RagonOperation.REPLICATE_ROOM_EVENT);
|
||||||
|
Writer.WriteUShort(evnt.EventCode);
|
||||||
|
Writer.WriteUShort(invoker.Connection.Id);
|
||||||
|
Writer.WriteByte((byte)eventMode);
|
||||||
|
|
||||||
|
evnt.Write(Writer);
|
||||||
|
|
||||||
|
var sendData = Writer.ToArray();
|
||||||
|
switch (targetMode)
|
||||||
|
{
|
||||||
|
case RagonTarget.Owner:
|
||||||
|
{
|
||||||
|
Owner.Connection.Reliable.Send(sendData);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case RagonTarget.ExceptOwner:
|
||||||
|
{
|
||||||
|
foreach (var roomPlayer in ReadyPlayersList)
|
||||||
|
{
|
||||||
|
if (roomPlayer.Connection.Id != Owner.Connection.Id)
|
||||||
|
roomPlayer.Connection.Reliable.Send(sendData);
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case RagonTarget.ExceptInvoker:
|
||||||
|
{
|
||||||
|
foreach (var roomPlayer in ReadyPlayersList)
|
||||||
|
{
|
||||||
|
if (roomPlayer.Connection.Id != invoker.Connection.Id)
|
||||||
|
roomPlayer.Connection.Reliable.Send(sendData);
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case RagonTarget.All:
|
||||||
|
{
|
||||||
|
Broadcast(sendData);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void Tick(float dt)
|
public void Tick(float dt)
|
||||||
{
|
{
|
||||||
var entities = (ushort)_entitiesDirtySet.Count;
|
var entities = (ushort)_entitiesDirtySet.Count;
|
||||||
|
|||||||
@@ -21,4 +21,5 @@ public ref struct RoomInformation
|
|||||||
public string Scene;
|
public string Scene;
|
||||||
public int Min;
|
public int Min;
|
||||||
public int Max;
|
public int Max;
|
||||||
|
public int BufferedEventsLimit;
|
||||||
}
|
}
|
||||||
@@ -23,6 +23,7 @@ namespace Ragon.Server.Room;
|
|||||||
public class RagonRoomPlayer
|
public class RagonRoomPlayer
|
||||||
{
|
{
|
||||||
public INetworkConnection Connection { get; }
|
public INetworkConnection Connection { get; }
|
||||||
|
public RagonContext Context { get; }
|
||||||
public string Id { get; }
|
public string Id { get; }
|
||||||
public string Name { get; }
|
public string Name { get; }
|
||||||
public bool IsLoaded { get; private set; }
|
public bool IsLoaded { get; private set; }
|
||||||
@@ -30,11 +31,12 @@ public class RagonRoomPlayer
|
|||||||
public RagonRoom Room { get; private set; }
|
public RagonRoom Room { get; private set; }
|
||||||
public RagonEntityCache Entities { get; private set; }
|
public RagonEntityCache Entities { get; private set; }
|
||||||
|
|
||||||
public RagonRoomPlayer(INetworkConnection connection, string id, string name)
|
public RagonRoomPlayer(RagonContext context, string id, string name)
|
||||||
{
|
{
|
||||||
Id = id;
|
Id = id;
|
||||||
Name = name;
|
Name = name;
|
||||||
Connection = connection;
|
Context = context;
|
||||||
|
Connection = context.Connection;
|
||||||
Entities = new RagonEntityCache();
|
Entities = new RagonEntityCache();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user