wip
This commit is contained in:
@@ -68,7 +68,7 @@ public sealed class RoomCreateOperation: IRagonOperation
|
||||
|
||||
var information = new RoomInformation()
|
||||
{
|
||||
Map = _roomParameters.Map,
|
||||
Scene = _roomParameters.Scene,
|
||||
Max = _roomParameters.Max,
|
||||
Min = _roomParameters.Min,
|
||||
};
|
||||
@@ -87,7 +87,7 @@ public sealed class RoomCreateOperation: IRagonOperation
|
||||
|
||||
_ragonWebHookPlugin.RoomCreated(context, room, roomPlayer);
|
||||
|
||||
_logger.Trace($"Player {context.Connection.Id}|{context.LobbyPlayer.Name} create room {room.Id} with map {information.Map}");
|
||||
_logger.Trace($"Player {context.Connection.Id}|{context.LobbyPlayer.Name} create room {room.Id} with scene {information.Scene}");
|
||||
|
||||
JoinSuccess(roomPlayer, room, writer);
|
||||
|
||||
@@ -103,7 +103,7 @@ public sealed class RoomCreateOperation: IRagonOperation
|
||||
writer.WriteString(room.Owner.Id);
|
||||
writer.WriteUShort((ushort) room.PlayerMin);
|
||||
writer.WriteUShort((ushort) room.PlayerMax);
|
||||
writer.WriteString(room.Map);
|
||||
writer.WriteString(room.Scene);
|
||||
|
||||
var sendData = writer.ToArray();
|
||||
player.Connection.Reliable.Send(sendData);
|
||||
|
||||
@@ -68,7 +68,7 @@ public sealed class RoomJoinOperation : IRagonOperation
|
||||
writer.WriteString(room.Owner.Id);
|
||||
writer.WriteUShort((ushort) room.PlayerMin);
|
||||
writer.WriteUShort((ushort) room.PlayerMax);
|
||||
writer.WriteString(room.Map);
|
||||
writer.WriteString(room.Scene);
|
||||
|
||||
var sendData = writer.ToArray();
|
||||
context.Connection.Reliable.Send(sendData);
|
||||
|
||||
@@ -49,7 +49,7 @@ public sealed class RoomJoinOrCreateOperation : IRagonOperation
|
||||
|
||||
_roomParameters.Deserialize(reader);
|
||||
|
||||
if (context.Lobby.FindRoomByMap(_roomParameters.Map, out var existsRoom))
|
||||
if (context.Lobby.FindRoomByScene(_roomParameters.Scene, out var existsRoom))
|
||||
{
|
||||
var player = new RagonRoomPlayer(context.Connection, lobbyPlayer.Id, lobbyPlayer.Name);
|
||||
context.SetRoom(existsRoom, player);
|
||||
@@ -62,7 +62,7 @@ public sealed class RoomJoinOrCreateOperation : IRagonOperation
|
||||
{
|
||||
var information = new RoomInformation()
|
||||
{
|
||||
Map = _roomParameters.Map,
|
||||
Scene = _roomParameters.Scene,
|
||||
Max = _roomParameters.Max,
|
||||
Min = _roomParameters.Min,
|
||||
};
|
||||
@@ -77,7 +77,7 @@ public sealed class RoomJoinOrCreateOperation : IRagonOperation
|
||||
context.Scheduler.Run(room);
|
||||
context.SetRoom(room, roomPlayer);
|
||||
|
||||
_logger.Trace($"Player {context.Connection.Id}|{context.LobbyPlayer.Name} create room {room.Id} with map {information.Map}");
|
||||
_logger.Trace($"Player {context.Connection.Id}|{context.LobbyPlayer.Name} create room {room.Id} with scene {information.Scene}");
|
||||
|
||||
JoinSuccess(roomPlayer, room, writer);
|
||||
}
|
||||
@@ -92,7 +92,7 @@ public sealed class RoomJoinOrCreateOperation : IRagonOperation
|
||||
writer.WriteString(room.Owner.Id);
|
||||
writer.WriteUShort((ushort) room.PlayerMin);
|
||||
writer.WriteUShort((ushort) room.PlayerMax);
|
||||
writer.WriteString(room.Map);
|
||||
writer.WriteString(room.Scene);
|
||||
|
||||
var sendData = writer.ToArray();
|
||||
player.Connection.Reliable.Send(sendData);
|
||||
|
||||
@@ -33,7 +33,7 @@ public class SceneLoadOperation: IRagonOperation
|
||||
|
||||
if (roomOwner.Connection.Id != currentPlayer.Connection.Id)
|
||||
{
|
||||
_logger.Warn("Only owner can change map!");
|
||||
_logger.Warn("Only owner can change scene!");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ namespace Ragon.Server.Lobby;
|
||||
public interface IRagonLobby
|
||||
{
|
||||
public bool FindRoomById(string roomId, [MaybeNullWhen(false)] out RagonRoom room);
|
||||
public bool FindRoomByMap(string map, [MaybeNullWhen(false)] out RagonRoom room);
|
||||
public bool FindRoomByScene(string sceneName, [MaybeNullWhen(false)] out RagonRoom room);
|
||||
public void Persist(RagonRoom room);
|
||||
public bool RemoveIfEmpty(RagonRoom room);
|
||||
}
|
||||
@@ -40,11 +40,11 @@ public class LobbyInMemory : IRagonLobby
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool FindRoomByMap(string map, [MaybeNullWhen(false)] out RagonRoom room)
|
||||
public bool FindRoomByScene(string sceneName, [MaybeNullWhen(false)] out RagonRoom room)
|
||||
{
|
||||
foreach (var existsRoom in _rooms)
|
||||
{
|
||||
if (existsRoom.Map == map && existsRoom.PlayerCount < existsRoom.PlayerMax)
|
||||
if (existsRoom.Scene == sceneName && existsRoom.PlayerCount < existsRoom.PlayerMax)
|
||||
{
|
||||
room = existsRoom;
|
||||
return true;
|
||||
@@ -61,7 +61,7 @@ public class LobbyInMemory : IRagonLobby
|
||||
_logger.Trace($"New room: {room.Id}");
|
||||
|
||||
foreach (var r in _rooms)
|
||||
_logger.Trace($"Room: {r.Id} Map: {r.Map} Players: {r.Players.Count} Entities: {r.Entities.Count}");
|
||||
_logger.Trace($"Room: {r.Id} Scene: {r.Scene} Players: {r.Players.Count} Entities: {r.Entities.Count}");
|
||||
}
|
||||
|
||||
public bool RemoveIfEmpty(RagonRoom room)
|
||||
@@ -76,7 +76,7 @@ public class LobbyInMemory : IRagonLobby
|
||||
}
|
||||
|
||||
foreach (var r in _rooms)
|
||||
_logger.Trace($"Room: {r.Id} Map: {r.Map} Players: {r.Players.Count} Entities: {r.Entities.Count}");
|
||||
_logger.Trace($"Room: {r.Id} Scene: {r.Scene} Players: {r.Players.Count} Entities: {r.Entities.Count}");
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -25,15 +25,15 @@ namespace Ragon.Server.Room;
|
||||
public class RagonRoom : IRagonRoom, IRagonAction
|
||||
{
|
||||
public string Id { get; private set; }
|
||||
public string Map { get; private set; }
|
||||
public string Scene { get; private set; }
|
||||
public int PlayerMax { get; private set; }
|
||||
public int PlayerMin { get; private set; }
|
||||
public int PlayerCount => WaitPlayersList.Count;
|
||||
|
||||
|
||||
public RagonRoomPlayer Owner { get; private set; }
|
||||
public RagonBuffer Writer { get; }
|
||||
public IRoomPlugin Plugin { get; private set; }
|
||||
|
||||
|
||||
public Dictionary<ushort, RagonRoomPlayer> Players { get; private set; }
|
||||
public List<RagonRoomPlayer> WaitPlayersList { get; private set; }
|
||||
public List<RagonRoomPlayer> ReadyPlayersList { get; private set; }
|
||||
@@ -45,11 +45,11 @@ public class RagonRoom : IRagonRoom, IRagonAction
|
||||
public List<RagonEntity> EntityList { get; private set; }
|
||||
|
||||
private readonly HashSet<RagonEntity> _entitiesDirtySet;
|
||||
|
||||
|
||||
public RagonRoom(string roomId, RoomInformation info, IRoomPlugin roomPlugin)
|
||||
{
|
||||
Id = roomId;
|
||||
Map = info.Map;
|
||||
Scene = info.Scene;
|
||||
PlayerMax = info.Max;
|
||||
PlayerMin = info.Min;
|
||||
Plugin = roomPlugin;
|
||||
@@ -182,7 +182,7 @@ public class RagonRoom : IRagonRoom, IRagonAction
|
||||
|
||||
public void UpdateMap(string sceneName)
|
||||
{
|
||||
Map = sceneName;
|
||||
Scene = sceneName;
|
||||
|
||||
DynamicEntitiesList.Clear();
|
||||
StaticEntitiesList.Clear();
|
||||
@@ -218,9 +218,7 @@ public class RagonRoom : IRagonRoom, IRagonAction
|
||||
|
||||
public IRagonEntity? GetEntityById(ushort id)
|
||||
{
|
||||
return Entities.TryGetValue(id, out var entity) ?
|
||||
entity :
|
||||
null;
|
||||
return Entities.TryGetValue(id, out var entity) ? entity : null;
|
||||
}
|
||||
|
||||
public IRagonEntity[] GetEntitiesOfPlayer(RagonRoomPlayer player)
|
||||
|
||||
@@ -18,7 +18,7 @@ namespace Ragon.Server;
|
||||
|
||||
public ref struct RoomInformation
|
||||
{
|
||||
public string Map;
|
||||
public string Scene;
|
||||
public int Min;
|
||||
public int Max;
|
||||
}
|
||||
Reference in New Issue
Block a user