提交进入地图和创建房间相关逻辑和协议

This commit is contained in:
2025-08-27 18:05:55 +08:00
parent f6d85a1e0a
commit 94af0e5ddb
31 changed files with 562 additions and 68 deletions

View File

@@ -15,13 +15,48 @@ public class G2Map_EnterRequestHandler : RouteRPC<Scene, G2Map_EnterRoomRequest,
response.ErrorCode = ErrorCode.ErrServer;
return;
}
var mapUnitManage = entity.GetComponent<MapUnitManageComponent>();
if (mapUnitManage == null)
{
response.ErrorCode = ErrorCode.ErrServer;
return;
}
var mapUnit = mapUnitManage.Get(request.AccountId);
if (mapUnit == null)
{
response.ErrorCode = ErrorCode.ErrServer;
return;
}
RoomHelper.ParseCode(request.RoomCode, out var serviceId, out var roomId);
if (serviceId < 1 || roomId < 1)
{
response.ErrorCode = ErrorCode.MapRoomIdError;
return;
}
// roomManageComponent.Enter();
var room = roomManageComponent.Get(roomId);
if (room == null)
{
response.ErrorCode = ErrorCode.MapRoomIdError;
return;
}
if (mapUnit.MapId != room.Map)
{
//切换地图
response.ErrorCode = await mapUnit.EnterMap(mapUnit.MapId);
if (response.ErrorCode != 0)
{
return;
}
}
response.ErrorCode = await room.Enter(request.AccountId);
response.RoomCode = room.Code;
}
}