Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| b8fe2bb13f | |||
| 89d130a193 |
@@ -30,7 +30,7 @@ namespace Ragon.Client
|
|||||||
public int Size => _size;
|
public int Size => _size;
|
||||||
|
|
||||||
private RagonBuffer _propertyBuffer;
|
private RagonBuffer _propertyBuffer;
|
||||||
private RagonEntity _entity;
|
private RagonEntity _entity;
|
||||||
private bool _dirty;
|
private bool _dirty;
|
||||||
private int _size;
|
private int _size;
|
||||||
private int _ticks;
|
private int _ticks;
|
||||||
@@ -46,7 +46,7 @@ namespace Ragon.Client
|
|||||||
_priority = priority;
|
_priority = priority;
|
||||||
_fixed = false;
|
_fixed = false;
|
||||||
_propertyBuffer = new RagonBuffer();
|
_propertyBuffer = new RagonBuffer();
|
||||||
|
|
||||||
InvokeLocal = invokeLocal;
|
InvokeLocal = invokeLocal;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -63,16 +63,17 @@ namespace Ragon.Client
|
|||||||
|
|
||||||
protected void InvokeChanged()
|
protected void InvokeChanged()
|
||||||
{
|
{
|
||||||
if (!InvokeLocal)
|
if (_entity.HasAuthority)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Changed?.Invoke();
|
Changed?.Invoke();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void MarkAsChanged()
|
protected void MarkAsChanged()
|
||||||
{
|
{
|
||||||
InvokeChanged();
|
if (InvokeLocal)
|
||||||
|
Changed?.Invoke();
|
||||||
|
|
||||||
if (_dirty || _entity == null)
|
if (_dirty || _entity == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -101,34 +102,34 @@ namespace Ragon.Client
|
|||||||
internal void Write(RagonBuffer buffer)
|
internal void Write(RagonBuffer buffer)
|
||||||
{
|
{
|
||||||
_propertyBuffer.Clear();
|
_propertyBuffer.Clear();
|
||||||
|
|
||||||
if (_fixed)
|
if (_fixed)
|
||||||
{
|
{
|
||||||
Serialize(_propertyBuffer);
|
Serialize(_propertyBuffer);
|
||||||
|
|
||||||
buffer.CopyFrom(_propertyBuffer, _size);
|
buffer.CopyFrom(_propertyBuffer, _size);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Serialize(_propertyBuffer);
|
Serialize(_propertyBuffer);
|
||||||
|
|
||||||
var propertySize = (ushort) _propertyBuffer.WriteOffset;
|
var propertySize = (ushort)_propertyBuffer.WriteOffset;
|
||||||
buffer.WriteUShort(propertySize);;
|
buffer.WriteUShort(propertySize);
|
||||||
buffer.CopyFrom(_propertyBuffer, propertySize);
|
buffer.CopyFrom(_propertyBuffer, propertySize);
|
||||||
}
|
}
|
||||||
|
|
||||||
internal void Read(RagonBuffer buffer)
|
internal void Read(RagonBuffer buffer)
|
||||||
{
|
{
|
||||||
_propertyBuffer.Clear();
|
_propertyBuffer.Clear();
|
||||||
|
|
||||||
if (_fixed)
|
if (_fixed)
|
||||||
{
|
{
|
||||||
buffer.ToBuffer(_propertyBuffer, _size);
|
buffer.ToBuffer(_propertyBuffer, _size);
|
||||||
|
|
||||||
Deserialize(_propertyBuffer);
|
Deserialize(_propertyBuffer);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var propSize = buffer.ReadUShort();
|
var propSize = buffer.ReadUShort();
|
||||||
buffer.ToBuffer(_propertyBuffer, propSize);
|
buffer.ToBuffer(_propertyBuffer, propSize);
|
||||||
Deserialize(_propertyBuffer);
|
Deserialize(_propertyBuffer);
|
||||||
|
|||||||
@@ -25,12 +25,20 @@ public class LobbyInMemory : IRagonLobby
|
|||||||
private readonly List<RagonRoom> _rooms = new();
|
private readonly List<RagonRoom> _rooms = new();
|
||||||
private readonly Logger _logger = LogManager.GetCurrentClassLogger();
|
private readonly Logger _logger = LogManager.GetCurrentClassLogger();
|
||||||
|
|
||||||
public bool FindRoomById(string RagonRoomId, [MaybeNullWhen(false)] out RagonRoom room)
|
public bool FindRoomById(string roomId, [MaybeNullWhen(false)] out RagonRoom room)
|
||||||
{
|
{
|
||||||
foreach (var existRagonRoom in _rooms)
|
foreach (var existRagonRoom in _rooms)
|
||||||
{
|
{
|
||||||
if (existRagonRoom.Id == RagonRoomId && existRagonRoom.PlayerMin < existRagonRoom.PlayerMax)
|
if (existRagonRoom.Id == roomId)
|
||||||
{
|
{
|
||||||
|
if (existRagonRoom.PlayerCount >= existRagonRoom.PlayerMax)
|
||||||
|
{
|
||||||
|
_logger.Warn($"Room with id {roomId} fulfilled");
|
||||||
|
|
||||||
|
room = default;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
room = existRagonRoom;
|
room = existRagonRoom;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -44,8 +52,16 @@ public class LobbyInMemory : IRagonLobby
|
|||||||
{
|
{
|
||||||
foreach (var existsRoom in _rooms)
|
foreach (var existsRoom in _rooms)
|
||||||
{
|
{
|
||||||
if (existsRoom.Scene == sceneName && existsRoom.PlayerCount < existsRoom.PlayerMax)
|
if (existsRoom.Scene == sceneName)
|
||||||
{
|
{
|
||||||
|
if (existsRoom.PlayerCount >= existsRoom.PlayerMax)
|
||||||
|
{
|
||||||
|
_logger.Warn($"Room with scene {sceneName} fulfilled");
|
||||||
|
|
||||||
|
room = default;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
room = existsRoom;
|
room = existsRoom;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user