using Microsoft.Extensions.Logging; using Tiger.Storage; namespace Tiger.Game.Rooms; public class RoomManager : IRoomManager { private readonly IRepository _roomPrivateCategoryRepository; private readonly IRepository _roomModelRepository; private readonly ILogger _logger; public IDictionary PrivateCategories { get; private set; } public IDictionary RoomModels { get; private set; } public RoomManager(IRepository roomPrivateCategoryRepository, IRepository roomModelRepository, ILogger logger) { _roomPrivateCategoryRepository = roomPrivateCategoryRepository; _roomModelRepository = roomModelRepository; _logger = logger; PrivateCategories = new Dictionary(); RoomModels = new Dictionary(); } 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); } }