TigerEmu/Game/Rooms/RoomManager.cs

26 lines
778 B
C#
Raw Normal View History

2023-10-14 20:32:12 +00:00
using Microsoft.Extensions.Logging;
2023-11-10 13:55:42 +00:00
using Tiger.Game.Rooms.Models;
2023-10-14 20:32:12 +00:00
using Tiger.Storage;
namespace Tiger.Game.Rooms;
public class RoomManager : IRoomManager
{
private readonly IRepository<RoomModel> _roomModelRepository;
2023-10-14 20:32:12 +00:00
private readonly ILogger<IRoomManager> _logger;
2023-11-10 13:55:42 +00:00
public RoomManager(IRepository<RoomModel> roomModelRepository, ILogger<IRoomManager> logger)
2023-10-14 20:32:12 +00:00
{
_roomModelRepository = roomModelRepository;
2023-10-14 20:32:12 +00:00
_logger = logger;
}
2023-11-10 13:55:42 +00:00
public Dictionary<string, RoomModel> Models { get; private set; } = new();
public async Task LoadModelsAsync()
{
2023-11-10 13:55:42 +00:00
Models = (await _roomModelRepository.FindByAsync()).ToDictionary(rm => rm.Name);
2023-11-10 13:55:42 +00:00
_logger.LogInformation("Loaded {Count} room models", Models.Count);
}
2023-10-14 20:32:12 +00:00
}