Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 0c4bdb83c9 | |||
| 5a79502848 | |||
| b8fe2bb13f | |||
| 89d130a193 |
@@ -12,11 +12,11 @@
|
|||||||
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
|
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
|
||||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||||
<DebugType>none</DebugType>
|
<DebugType>none</DebugType>
|
||||||
<OutputPath>/Users/edmand46/UnityProjects/itd-client/Assets/Ragon/Runtime/Plugins/</OutputPath>
|
<OutputPath></OutputPath>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
|
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
|
||||||
<OutputPath>/Users/edmand46/RagonProjects/ragon-oss-examples/Assets/Ragon/Plugins/</OutputPath>
|
<OutputPath></OutputPath>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|||||||
@@ -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);
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2023 Eduard Kargin <kargin.eduard@gmail.com>
|
* Copyright 2023-2024 Eduard Kargin <kargin.eduard@gmail.com>
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -121,6 +121,21 @@ namespace Ragon.Protocol
|
|||||||
return (RagonOperation)Read(8);
|
return (RagonOperation)Read(8);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
|
public void WriteFloat(float value)
|
||||||
|
{
|
||||||
|
var bytes = BitConverter.GetBytes(value);
|
||||||
|
WriteBytes(bytes);
|
||||||
|
}
|
||||||
|
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
|
public float ReadFloat()
|
||||||
|
{
|
||||||
|
var bytes = ReadBytes(4);
|
||||||
|
var value = BitConverter.ToSingle(bytes, 0);
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public void WriteFloat(float value, float min, float max, float precision)
|
public void WriteFloat(float value, float min, float max, float precision)
|
||||||
{
|
{
|
||||||
@@ -147,6 +162,23 @@ namespace Ragon.Protocol
|
|||||||
return adjusted;
|
return adjusted;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
|
public void WriteInt(int value)
|
||||||
|
{
|
||||||
|
var bytes = BitConverter.GetBytes(value);
|
||||||
|
|
||||||
|
WriteBytes(bytes);
|
||||||
|
}
|
||||||
|
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
|
public int ReadInt()
|
||||||
|
{
|
||||||
|
var bytes = ReadBytes(4);
|
||||||
|
var value = BitConverter.ToInt32(bytes, 0);
|
||||||
|
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public void WriteInt(int value, int min, int max)
|
public void WriteInt(int value, int min, int max)
|
||||||
{
|
{
|
||||||
@@ -281,10 +313,10 @@ namespace Ragon.Protocol
|
|||||||
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
[Obsolete("Do not use this method, will be removed")]
|
[Obsolete("Do not use this method, will be removed")]
|
||||||
public byte[] ReadBytes(int lenght)
|
public byte[] ReadBytes(int len)
|
||||||
{
|
{
|
||||||
var data = new byte[lenght];
|
var data = new byte[len];
|
||||||
for (int i = 0; i < lenght; i++)
|
for (int i = 0; i < len; i++)
|
||||||
data[i] = (byte)Read(8);
|
data[i] = (byte)Read(8);
|
||||||
|
|
||||||
return data;
|
return data;
|
||||||
|
|||||||
@@ -0,0 +1,309 @@
|
|||||||
|
using System;
|
||||||
|
using System.Runtime.CompilerServices;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace Ragon.Protocol
|
||||||
|
{
|
||||||
|
[StructLayout(LayoutKind.Explicit)]
|
||||||
|
internal struct ValueConverter
|
||||||
|
{
|
||||||
|
[FieldOffset(0)] public int Int;
|
||||||
|
[FieldOffset(0)] public float Float;
|
||||||
|
[FieldOffset(0)] public long Long;
|
||||||
|
[FieldOffset(0)] public byte Byte0;
|
||||||
|
[FieldOffset(1)] public byte Byte1;
|
||||||
|
[FieldOffset(2)] public byte Byte2;
|
||||||
|
[FieldOffset(3)] public byte Byte3;
|
||||||
|
[FieldOffset(4)] public byte Byte4;
|
||||||
|
[FieldOffset(5)] public byte Byte5;
|
||||||
|
[FieldOffset(6)] public byte Byte6;
|
||||||
|
[FieldOffset(7)] public byte Byte7;
|
||||||
|
}
|
||||||
|
|
||||||
|
public class RagonStream
|
||||||
|
{
|
||||||
|
private byte[] _data;
|
||||||
|
private int _offset;
|
||||||
|
private int _size;
|
||||||
|
|
||||||
|
public int Lenght => _offset;
|
||||||
|
public int Size => _size - _offset;
|
||||||
|
|
||||||
|
public RagonStream(int capacity = 256)
|
||||||
|
{
|
||||||
|
_data = new byte[capacity];
|
||||||
|
_offset = 0;
|
||||||
|
_size = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
|
public void Reset()
|
||||||
|
{
|
||||||
|
_size = _offset;
|
||||||
|
_offset = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
|
public void AddOffset(int offset)
|
||||||
|
{
|
||||||
|
_offset += offset;
|
||||||
|
}
|
||||||
|
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
|
public int WriteByte(byte value)
|
||||||
|
{
|
||||||
|
ResizeIfNeed(1);
|
||||||
|
_data[_offset] = value;
|
||||||
|
_offset += 1;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
|
public byte ReadByte()
|
||||||
|
{
|
||||||
|
var value = _data[_offset];
|
||||||
|
_offset += 1;
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
|
public int WriteBool(bool value)
|
||||||
|
{
|
||||||
|
ResizeIfNeed(1);
|
||||||
|
_data[_offset] = value ? (byte)1 : (byte)0;
|
||||||
|
_offset += 1;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
|
public bool ReadBool()
|
||||||
|
{
|
||||||
|
var value = _data[_offset];
|
||||||
|
_offset += 1;
|
||||||
|
return value == 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
|
public int WriteInt(int value)
|
||||||
|
{
|
||||||
|
ResizeIfNeed(4);
|
||||||
|
var converter = new ValueConverter() { Int = value };
|
||||||
|
_data[_offset] = converter.Byte0;
|
||||||
|
_data[_offset + 1] = converter.Byte1;
|
||||||
|
_data[_offset + 2] = converter.Byte2;
|
||||||
|
_data[_offset + 3] = converter.Byte3;
|
||||||
|
_offset += 4;
|
||||||
|
return 4;
|
||||||
|
}
|
||||||
|
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
|
public int WriteInt(int value, int offset)
|
||||||
|
{
|
||||||
|
ResizeIfNeed(4);
|
||||||
|
var converter = new ValueConverter() { Int = value };
|
||||||
|
_data[offset] = converter.Byte0;
|
||||||
|
_data[offset + 1] = converter.Byte1;
|
||||||
|
_data[offset + 2] = converter.Byte2;
|
||||||
|
_data[offset + 3] = converter.Byte3;
|
||||||
|
return 4;
|
||||||
|
}
|
||||||
|
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
|
public int ReadInt()
|
||||||
|
{
|
||||||
|
var converter = new ValueConverter
|
||||||
|
{ Byte0 = _data[_offset], Byte1 = _data[_offset + 1], Byte2 = _data[_offset + 2], Byte3 = _data[_offset + 3] };
|
||||||
|
_offset += 4;
|
||||||
|
return converter.Int;
|
||||||
|
}
|
||||||
|
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
|
public void WriteLong(long value)
|
||||||
|
{
|
||||||
|
ResizeIfNeed(8);
|
||||||
|
WriteLong(value, _offset);
|
||||||
|
_offset += 8;
|
||||||
|
}
|
||||||
|
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
|
public int WriteLong(long value, int offset)
|
||||||
|
{
|
||||||
|
var converter = new ValueConverter() { Long = value };
|
||||||
|
_data[offset] = converter.Byte0;
|
||||||
|
_data[offset + 1] = converter.Byte1;
|
||||||
|
_data[offset + 2] = converter.Byte2;
|
||||||
|
_data[offset + 3] = converter.Byte3;
|
||||||
|
_data[offset + 4] = converter.Byte4;
|
||||||
|
_data[offset + 5] = converter.Byte5;
|
||||||
|
_data[offset + 6] = converter.Byte6;
|
||||||
|
_data[offset + 7] = converter.Byte7;
|
||||||
|
return 8;
|
||||||
|
}
|
||||||
|
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
|
public long ReadLong()
|
||||||
|
{
|
||||||
|
var converter = new ValueConverter
|
||||||
|
{
|
||||||
|
Byte0 = _data[_offset],
|
||||||
|
Byte1 = _data[_offset + 1],
|
||||||
|
Byte2 = _data[_offset + 2],
|
||||||
|
Byte3 = _data[_offset + 3],
|
||||||
|
Byte4 = _data[_offset + 4],
|
||||||
|
Byte5 = _data[_offset + 5],
|
||||||
|
Byte6 = _data[_offset + 6],
|
||||||
|
Byte7 = _data[_offset + 7],
|
||||||
|
};
|
||||||
|
_offset += 8;
|
||||||
|
return converter.Long;
|
||||||
|
}
|
||||||
|
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
|
public int WriteFloat(float value)
|
||||||
|
{
|
||||||
|
var converter = new ValueConverter() { Float = value };
|
||||||
|
WriteInt(converter.Int);
|
||||||
|
return 4;
|
||||||
|
}
|
||||||
|
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
|
public float ReadFloat()
|
||||||
|
{
|
||||||
|
var rawValue = ReadInt();
|
||||||
|
var converter = new ValueConverter() { Int = rawValue };
|
||||||
|
var value = converter.Float;
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
|
public int WriteString(string value)
|
||||||
|
{
|
||||||
|
var rawData = Encoding.UTF8.GetBytes(value);
|
||||||
|
var len = rawData.Length;
|
||||||
|
ResizeIfNeed(2 + len);
|
||||||
|
WriteUShort((ushort)len);
|
||||||
|
|
||||||
|
Buffer.BlockCopy(rawData, 0, _data, _offset, len);
|
||||||
|
|
||||||
|
_offset += len;
|
||||||
|
|
||||||
|
return len + 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
|
public string ReadString()
|
||||||
|
{
|
||||||
|
var len = ReadUShort();
|
||||||
|
var rawData = new byte[len];
|
||||||
|
|
||||||
|
Buffer.BlockCopy(_data, _offset, rawData, 0, len);
|
||||||
|
|
||||||
|
var str = Encoding.UTF8.GetString(rawData);
|
||||||
|
_offset += len;
|
||||||
|
return str;
|
||||||
|
}
|
||||||
|
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
|
public byte[] ReadBinary(int len)
|
||||||
|
{
|
||||||
|
if (len >= _data.Length)
|
||||||
|
return Array.Empty<byte>();
|
||||||
|
|
||||||
|
var payload = new byte[len];
|
||||||
|
Buffer.BlockCopy(_data, _offset, payload, 0, len);
|
||||||
|
|
||||||
|
_offset += len;
|
||||||
|
|
||||||
|
return payload;
|
||||||
|
}
|
||||||
|
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
|
public void WriteBinary(byte[] payload)
|
||||||
|
{
|
||||||
|
ResizeIfNeed(payload.Length);
|
||||||
|
|
||||||
|
Array.Copy(payload, 0, _data, _offset, payload.Length);
|
||||||
|
|
||||||
|
_offset += payload.Length;
|
||||||
|
}
|
||||||
|
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
|
public void WriteOperation(RagonOperation operation)
|
||||||
|
{
|
||||||
|
ResizeIfNeed(1);
|
||||||
|
|
||||||
|
_data[_offset] = (byte)operation;
|
||||||
|
_offset += 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
|
public RagonOperation ReadOperation()
|
||||||
|
{
|
||||||
|
var op = (RagonOperation)_data[_offset];
|
||||||
|
_offset += 1;
|
||||||
|
return op;
|
||||||
|
}
|
||||||
|
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
|
public void WriteUShort(ushort value)
|
||||||
|
{
|
||||||
|
ResizeIfNeed(2);
|
||||||
|
|
||||||
|
_data[_offset] = (byte)(value & 0x00FF);
|
||||||
|
_data[_offset + 1] = (byte)((value & 0xFF00) >> 8);
|
||||||
|
_offset += 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
|
public void WriteUShort(ushort value, int offset)
|
||||||
|
{
|
||||||
|
ResizeIfNeed(2);
|
||||||
|
_data[offset] = (byte)(value & 0x00FF);
|
||||||
|
_data[offset + 1] = (byte)((value & 0xFF00) >> 8);
|
||||||
|
}
|
||||||
|
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
|
public ushort ReadUShort()
|
||||||
|
{
|
||||||
|
var value = (ushort)(_data[_offset] + (_data[_offset + 1] << 8));
|
||||||
|
_offset += 2;
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Clear()
|
||||||
|
{
|
||||||
|
_offset = 0;
|
||||||
|
_size = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void FromArray(byte[] data)
|
||||||
|
{
|
||||||
|
Clear();
|
||||||
|
ResizeIfNeed(data.Length);
|
||||||
|
Buffer.BlockCopy(data, 0, _data, 0, data.Length);
|
||||||
|
_size = data.Length;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public byte[] ToArray()
|
||||||
|
{
|
||||||
|
var bytes = new byte[_offset];
|
||||||
|
Buffer.BlockCopy(_data, 0, bytes, 0, _offset);
|
||||||
|
return bytes;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ResizeIfNeed(int lenght)
|
||||||
|
{
|
||||||
|
if (_offset + lenght < _data.Length)
|
||||||
|
return;
|
||||||
|
|
||||||
|
var newData = new byte[_data.Length * 4 + lenght];
|
||||||
|
Buffer.BlockCopy(_data, 0, newData, 0, _data.Length);
|
||||||
|
_data = newData;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -3,7 +3,7 @@
|
|||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<OutputType>Exe</OutputType>
|
<OutputType>Exe</OutputType>
|
||||||
<RootNamespace>Ragon.Relay</RootNamespace>
|
<RootNamespace>Ragon.Relay</RootNamespace>
|
||||||
<TargetFramework>net7.0</TargetFramework>
|
<TargetFrameworks>net7.0;net8.0</TargetFrameworks>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
|
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
|
||||||
|
|||||||
@@ -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