45 lines
1.6 KiB
C#
45 lines
1.6 KiB
C#
using Microsoft.Extensions.Logging;
|
|
using Tiger.Storage;
|
|
|
|
namespace Tiger.Game.Rooms;
|
|
|
|
public class RoomManager : IRoomManager
|
|
{
|
|
private readonly IRepository<RoomPrivateCategory> _roomPrivateCategoryRepository;
|
|
private readonly IRepository<RoomModel> _roomModelRepository;
|
|
private readonly ILogger<IRoomManager> _logger;
|
|
|
|
public IDictionary<int, RoomPrivateCategory> PrivateCategories { get; private set; }
|
|
public IDictionary<int, RoomModel> RoomModels { get; private set; }
|
|
|
|
public RoomManager(IRepository<RoomPrivateCategory> roomPrivateCategoryRepository,
|
|
IRepository<RoomModel> roomModelRepository, ILogger<IRoomManager> logger)
|
|
{
|
|
_roomPrivateCategoryRepository = roomPrivateCategoryRepository;
|
|
_roomModelRepository = roomModelRepository;
|
|
_logger = logger;
|
|
|
|
PrivateCategories = new Dictionary<int, RoomPrivateCategory>();
|
|
RoomModels = new Dictionary<int, RoomModel>();
|
|
}
|
|
|
|
public async Task LoadPrivateCategoriesAsync()
|
|
{
|
|
PrivateCategories =
|
|
(await _roomPrivateCategoryRepository.FindByAsync()).ToDictionary(rpc => rpc.Id);
|
|
|
|
_logger.LogInformation("Loaded {Count} private room categories", PrivateCategories.Count);
|
|
}
|
|
|
|
public async Task LoadRoomModels()
|
|
{
|
|
RoomModels = (await _roomModelRepository.FindByAsync()).ToDictionary(rpc => rpc.Id);
|
|
|
|
foreach (var model in RoomModels.Values)
|
|
{
|
|
model.Parse();
|
|
}
|
|
|
|
_logger.LogInformation("Loaded and parsed {Count} room models", RoomModels.Count);
|
|
}
|
|
} |