feat(wip): room properties
This commit is contained in:
@@ -55,7 +55,6 @@ namespace Ragon.Client
|
|||||||
public ushort Id { get; private set; }
|
public ushort Id { get; private set; }
|
||||||
public ushort Type { get; private set; }
|
public ushort Type { get; private set; }
|
||||||
|
|
||||||
|
|
||||||
public RagonAuthority Authority { get; private set; }
|
public RagonAuthority Authority { get; private set; }
|
||||||
public RagonPlayer Owner { get; private set; }
|
public RagonPlayer Owner { get; private set; }
|
||||||
public RagonEntityState State { get; private set; }
|
public RagonEntityState State { get; private set; }
|
||||||
|
|||||||
@@ -4,9 +4,17 @@ namespace Ragon.Client
|
|||||||
{
|
{
|
||||||
public class RoomDataHandler: IHandler
|
public class RoomDataHandler: IHandler
|
||||||
{
|
{
|
||||||
|
private readonly RagonClient _client;
|
||||||
|
public RoomDataHandler(RagonClient client)
|
||||||
|
{
|
||||||
|
_client = client;
|
||||||
|
}
|
||||||
|
|
||||||
public void Handle(RagonBuffer reader)
|
public void Handle(RagonBuffer reader)
|
||||||
{
|
{
|
||||||
|
var len = reader.ReadUShort();
|
||||||
|
|
||||||
|
_client.Room?.Data(reader);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+2
-2
@@ -19,12 +19,12 @@ using Ragon.Protocol;
|
|||||||
|
|
||||||
namespace Ragon.Client;
|
namespace Ragon.Client;
|
||||||
|
|
||||||
internal class RawDataHandler: IHandler
|
internal class RoomRawDataHandler: IHandler
|
||||||
{
|
{
|
||||||
private readonly RagonListenerList _listeners;
|
private readonly RagonListenerList _listeners;
|
||||||
private readonly RagonPlayerCache _playerCache;
|
private readonly RagonPlayerCache _playerCache;
|
||||||
|
|
||||||
public RawDataHandler(
|
public RoomRawDataHandler(
|
||||||
RagonPlayerCache playerCache,
|
RagonPlayerCache playerCache,
|
||||||
RagonListenerList listeners)
|
RagonListenerList listeners)
|
||||||
{
|
{
|
||||||
@@ -121,7 +121,7 @@ namespace Ragon.Client
|
|||||||
_handlers[(byte)RagonOperation.REPLICATE_ROOM_EVENT] = new RoomEventHandler(this, _playerCache);
|
_handlers[(byte)RagonOperation.REPLICATE_ROOM_EVENT] = new RoomEventHandler(this, _playerCache);
|
||||||
_handlers[(byte)RagonOperation.SNAPSHOT] = new SnapshotHandler(this, _listeners, _entityCache, _playerCache, _entityListener);
|
_handlers[(byte)RagonOperation.SNAPSHOT] = new SnapshotHandler(this, _listeners, _entityCache, _playerCache, _entityListener);
|
||||||
_handlers[(byte)RagonOperation.TIMESTAMP_SYNCHRONIZATION] = new TimestampHandler(this);
|
_handlers[(byte)RagonOperation.TIMESTAMP_SYNCHRONIZATION] = new TimestampHandler(this);
|
||||||
_handlers[(byte)RagonOperation.REPLICATE_RAW_DATA] = new RawDataHandler(_playerCache, _listeners);
|
_handlers[(byte)RagonOperation.REPLICATE_RAW_DATA] = new RoomRawDataHandler(_playerCache, _listeners);
|
||||||
_handlers[(byte)RagonOperation.ROOM_LIST_UPDATED] = new RoomListHandler(_session, _listeners);
|
_handlers[(byte)RagonOperation.ROOM_LIST_UPDATED] = new RoomListHandler(_session, _listeners);
|
||||||
|
|
||||||
var protocolRaw = RagonVersion.Parse(protocol);
|
var protocolRaw = RagonVersion.Parse(protocol);
|
||||||
|
|||||||
@@ -49,11 +49,12 @@ namespace Ragon.Client
|
|||||||
|
|
||||||
private delegate void OnEventDelegate(RagonPlayer player, RagonBuffer serializer);
|
private delegate void OnEventDelegate(RagonPlayer player, RagonBuffer serializer);
|
||||||
|
|
||||||
private RagonClient _client;
|
private readonly RagonClient _client;
|
||||||
private RagonScene _scene;
|
private readonly RagonScene _scene;
|
||||||
private RagonEntityCache _entityCache;
|
private readonly RagonEntityCache _entityCache;
|
||||||
private RagonPlayerCache _playerCache;
|
private readonly RagonPlayerCache _playerCache;
|
||||||
private RoomParameters _parameters;
|
private readonly RoomParameters _parameters;
|
||||||
|
private readonly Dictionary<string, RagonProperty> _properties = new();
|
||||||
|
|
||||||
public string Id => _parameters.RoomId;
|
public string Id => _parameters.RoomId;
|
||||||
public int MinPlayers => _parameters.Min;
|
public int MinPlayers => _parameters.Min;
|
||||||
@@ -100,6 +101,11 @@ namespace Ragon.Client
|
|||||||
RagonLog.Warn($"Handler event on entity {Id} with eventCode {eventCode} not defined");
|
RagonLog.Warn($"Handler event on entity {Id} with eventCode {eventCode} not defined");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
internal void Data(RagonBuffer buffer)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public IDisposable OnEvent<TEvent>(Action<RagonPlayer, TEvent> callback) where TEvent : IRagonEvent, new()
|
public IDisposable OnEvent<TEvent>(Action<RagonPlayer, TEvent> callback) where TEvent : IRagonEvent, new()
|
||||||
{
|
{
|
||||||
var t = new TEvent();
|
var t = new TEvent();
|
||||||
|
|||||||
@@ -283,6 +283,7 @@ namespace Ragon.Protocol
|
|||||||
_write += numBits;
|
_write += numBits;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public uint Read(int numBits = 16)
|
public uint Read(int numBits = 16)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -14,6 +14,7 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
using Ragon.Server.Data;
|
||||||
using Ragon.Server.Entity;
|
using Ragon.Server.Entity;
|
||||||
using Ragon.Server.IO;
|
using Ragon.Server.IO;
|
||||||
|
|
||||||
@@ -26,6 +27,7 @@ public interface IRagonRoom
|
|||||||
public int PlayerMin { get; }
|
public int PlayerMin { get; }
|
||||||
public int PlayerMax { get; }
|
public int PlayerMax { get; }
|
||||||
public int PlayerCount { get; }
|
public int PlayerCount { get; }
|
||||||
|
public RagonData UserData { get; }
|
||||||
|
|
||||||
RagonRoomPlayer GetPlayerByConnection(INetworkConnection connection);
|
RagonRoomPlayer GetPlayerByConnection(INetworkConnection connection);
|
||||||
RagonRoomPlayer GetPlayerById(string id);
|
RagonRoomPlayer GetPlayerById(string id);
|
||||||
|
|||||||
@@ -110,6 +110,20 @@ public class RagonRoom : IRagonRoom, IRagonAction
|
|||||||
foreach (var roomPlayer in ReadyPlayersList)
|
foreach (var roomPlayer in ReadyPlayersList)
|
||||||
roomPlayer.Connection.Unreliable.Send(sendData);
|
roomPlayer.Connection.Unreliable.Send(sendData);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (UserData.IsDirty)
|
||||||
|
{
|
||||||
|
Writer.Clear();
|
||||||
|
Writer.WriteOperation(RagonOperation.ROOM_DATA_UPDATED);
|
||||||
|
Writer.WriteUShort((ushort)UserData.Data.Length);
|
||||||
|
Writer.WriteBytes(UserData.Data);
|
||||||
|
|
||||||
|
var sendData = Writer.ToArray();
|
||||||
|
foreach (var roomPlayer in ReadyPlayersList)
|
||||||
|
roomPlayer.Connection.Reliable.Send(sendData);
|
||||||
|
|
||||||
|
UserData.IsDirty = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void AttachPlayer(RagonRoomPlayer player)
|
public void AttachPlayer(RagonRoomPlayer player)
|
||||||
|
|||||||
Reference in New Issue
Block a user