feat: add npc info (level and aggro radius)

This commit is contained in:
k0t9i
2023-01-31 00:32:26 +04:00
parent a8734a4ca0
commit 89cec4f40f
11 changed files with 26504 additions and 20 deletions

View File

@@ -39,16 +39,10 @@ namespace Client.Infrastructure.Helpers
private readonly IConfiguration configuration;
private Dictionary<uint, ulong> experienceToLevel = new Dictionary<uint, ulong>();
public class ExpInfo
private class ExpInfo
{
public uint level { get; set; }
public ulong toLevel { get; set; }
/* public ExpInfo(uint level, ulong toLevel)
{
this.level = level;
this.toLevel = toLevel;
}*/
}
}
}

View File

@@ -0,0 +1,62 @@
using Client.Domain.Helpers;
using Microsoft.Extensions.Configuration;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web;
using static Client.Infrastructure.Helpers.ConfigurationExperienceHelper;
namespace Client.Infrastructure.Helpers
{
public class ConfigurationNpcInfoHelper : NpcInfoHelperInterface
{
public uint GetLevel(uint id)
{
return GetNpcInfo(id).level;
}
public uint GetAggroRadius(uint id)
{
return GetNpcInfo(id).aggroRadius;
}
public ConfigurationNpcInfoHelper(IConfiguration configuration)
{
this.configuration = configuration;
}
private NpcInfo GetNpcInfo(uint id)
{
if (!npcInfo.ContainsKey(id))
{
var item = configuration.GetRequiredSection("npcInfo").GetChildren()
.Where(x => x.Key == id.ToString())
.FirstOrDefault();
uint level = 0;
uint aggroRadius = 0;
if (item != null)
{
uint.TryParse(item.GetRequiredSection("level").Value, out level);
uint.TryParse(item.GetRequiredSection("aggroRadius").Value, out aggroRadius);
}
npcInfo[id] = new NpcInfo
{
level = level,
aggroRadius = aggroRadius
};
}
return npcInfo[id];
}
private readonly IConfiguration configuration;
private Dictionary<uint, NpcInfo> npcInfo = new Dictionary<uint, NpcInfo>();
private class NpcInfo
{
public uint level { get; set; }
public uint aggroRadius { get; set; }
}
}
}