TigerEmu/Game/Navigator/NavigatorManager.cs

28 lines
916 B
C#

using Microsoft.Extensions.Logging;
using Tiger.Game.Navigator.Nodes;
using Tiger.Storage;
namespace Tiger.Game.Navigator;
public class NavigatorManager : INavigatorManager
{
private readonly IRepository<NavigatorNode> _navigatorNodeRepository;
private readonly ILogger<INavigatorManager> _logger;
public IDictionary<int, NavigatorNode> NavigatorNodes { get; private set; }
public NavigatorManager(IRepository<NavigatorNode> navigatorNodeRepository, ILogger<INavigatorManager> logger)
{
_navigatorNodeRepository = navigatorNodeRepository;
_logger = logger;
NavigatorNodes = new Dictionary<int, NavigatorNode>();
}
public async Task LoadNodesAsync()
{
NavigatorNodes = (await _navigatorNodeRepository.FindByAsync()).ToDictionary(nn => nn.Id);
_logger.LogInformation("Loaded {Count} navigator nodes", NavigatorNodes.Count);
}
}