TigerEmu/Game/Rooms/RoomManager.cs

45 lines
1.6 KiB
C#
Raw Permalink Normal View History

2023-10-14 20:32:12 +00:00
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;
2023-10-14 20:32:12 +00:00
private readonly ILogger<IRoomManager> _logger;
public IDictionary<int, RoomPrivateCategory> PrivateCategories { get; private set; }
public IDictionary<int, RoomModel> RoomModels { get; private set; }
2023-10-14 20:32:12 +00:00
public RoomManager(IRepository<RoomPrivateCategory> roomPrivateCategoryRepository,
IRepository<RoomModel> roomModelRepository, ILogger<IRoomManager> logger)
2023-10-14 20:32:12 +00:00
{
_roomPrivateCategoryRepository = roomPrivateCategoryRepository;
_roomModelRepository = roomModelRepository;
2023-10-14 20:32:12 +00:00
_logger = logger;
PrivateCategories = new Dictionary<int, RoomPrivateCategory>();
RoomModels = new Dictionary<int, RoomModel>();
2023-10-14 20:32:12 +00:00
}
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);
}
2023-10-14 20:32:12 +00:00
}