2018-11-24 03:07:41 -05:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using OpenDiablo2.Common;
|
2018-12-04 23:20:31 -05:00
|
|
|
|
using OpenDiablo2.Common.Enums;
|
2018-11-24 03:07:41 -05:00
|
|
|
|
using OpenDiablo2.Common.Interfaces;
|
2018-12-04 23:20:31 -05:00
|
|
|
|
using OpenDiablo2.Common.Interfaces.Mobs;
|
2018-11-24 03:07:41 -05:00
|
|
|
|
using OpenDiablo2.Common.Models;
|
2018-12-04 23:20:31 -05:00
|
|
|
|
using OpenDiablo2.Common.Models.Mobs;
|
2018-11-24 03:07:41 -05:00
|
|
|
|
|
|
|
|
|
namespace OpenDiablo2.Core
|
|
|
|
|
{
|
|
|
|
|
public sealed class EngineDataManager : IEngineDataManager
|
|
|
|
|
{
|
2018-12-05 22:29:45 -05:00
|
|
|
|
static readonly log4net.ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
|
|
|
|
|
|
2018-11-24 03:07:41 -05:00
|
|
|
|
private readonly IMPQProvider mpqProvider;
|
|
|
|
|
|
|
|
|
|
public List<LevelPreset> LevelPresets { get; internal set; }
|
|
|
|
|
public List<LevelType> LevelTypes { get; internal set; }
|
2018-11-25 01:51:21 -05:00
|
|
|
|
public List<LevelDetail> LevelDetails { get; internal set; }
|
2018-12-02 16:34:00 -05:00
|
|
|
|
public List<Item> Items { get; internal set; } = new List<Item>();
|
2018-12-04 23:20:31 -05:00
|
|
|
|
public Dictionary<eHero, ILevelExperienceConfig> ExperienceConfigs { get; internal set; } = new Dictionary<eHero, ILevelExperienceConfig>();
|
2018-12-05 22:28:09 -05:00
|
|
|
|
public Dictionary<eHero, IHeroTypeConfig> HeroTypeConfigs { get; internal set; } = new Dictionary<eHero, IHeroTypeConfig>();
|
2018-11-24 03:07:41 -05:00
|
|
|
|
|
|
|
|
|
public EngineDataManager(IMPQProvider mpqProvider)
|
|
|
|
|
{
|
|
|
|
|
this.mpqProvider = mpqProvider;
|
|
|
|
|
|
|
|
|
|
LoadLevelPresets();
|
|
|
|
|
LoadLevelTypes();
|
2018-11-25 01:51:21 -05:00
|
|
|
|
LoadLevelDetails();
|
2018-12-02 16:34:00 -05:00
|
|
|
|
|
|
|
|
|
LoadItemData();
|
2018-12-04 23:20:31 -05:00
|
|
|
|
|
|
|
|
|
LoadCharacterData();
|
2018-11-24 03:07:41 -05:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void LoadLevelTypes()
|
|
|
|
|
{
|
2018-12-05 22:29:45 -05:00
|
|
|
|
log.Info("Loading level types");
|
2018-11-24 03:07:41 -05:00
|
|
|
|
var data = mpqProvider
|
|
|
|
|
.GetTextFile(ResourcePaths.LevelType)
|
|
|
|
|
.Skip(1)
|
|
|
|
|
.Where(x => !String.IsNullOrWhiteSpace(x))
|
|
|
|
|
.Select(x => x.Split('\t'))
|
2018-11-24 17:54:15 -05:00
|
|
|
|
.Where(x => x.Count() == 36 && x[0] != "Expansion")
|
2018-11-24 03:07:41 -05:00
|
|
|
|
.ToArray()
|
|
|
|
|
.Select(x => x.ToLevelType());
|
|
|
|
|
|
|
|
|
|
LevelTypes = new List<LevelType>(data);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void LoadLevelPresets()
|
|
|
|
|
{
|
2018-12-05 22:29:45 -05:00
|
|
|
|
log.Info("Loading level presets");
|
2018-11-24 03:07:41 -05:00
|
|
|
|
var data = mpqProvider
|
|
|
|
|
.GetTextFile(ResourcePaths.LevelPreset)
|
|
|
|
|
.Skip(1)
|
|
|
|
|
.Where(x => !String.IsNullOrWhiteSpace(x))
|
|
|
|
|
.Select(x => x.Split('\t'))
|
2018-11-24 17:54:15 -05:00
|
|
|
|
.Where(x => x.Count() == 24 && x[0] != "Expansion")
|
2018-11-24 03:07:41 -05:00
|
|
|
|
.ToArray()
|
|
|
|
|
.Select(x => x.ToLevelPreset());
|
|
|
|
|
|
|
|
|
|
LevelPresets = new List<LevelPreset>(data);
|
|
|
|
|
}
|
2018-11-25 01:51:21 -05:00
|
|
|
|
|
|
|
|
|
private void LoadLevelDetails()
|
|
|
|
|
{
|
2018-12-05 22:29:45 -05:00
|
|
|
|
log.Info("Loading level details");
|
2018-11-25 01:51:21 -05:00
|
|
|
|
var data = mpqProvider
|
|
|
|
|
.GetTextFile(ResourcePaths.LevelDetails)
|
|
|
|
|
.Skip(1)
|
|
|
|
|
.Where(x => !String.IsNullOrWhiteSpace(x))
|
|
|
|
|
.Select(x => x.Split('\t'))
|
|
|
|
|
.Where(x => x.Count() > 80 && x[0] != "Expansion")
|
|
|
|
|
.ToArray()
|
|
|
|
|
.Select(x => x.ToLevelDetail());
|
|
|
|
|
|
|
|
|
|
LevelDetails = new List<LevelDetail>(data);
|
|
|
|
|
}
|
2018-12-02 16:34:00 -05:00
|
|
|
|
|
|
|
|
|
private void LoadItemData()
|
|
|
|
|
{
|
|
|
|
|
var weaponData = LoadWeaponData();
|
|
|
|
|
var armorData = LoadArmorData();
|
|
|
|
|
var miscData = LoadMiscData();
|
|
|
|
|
|
|
|
|
|
Items.AddRange(weaponData);
|
|
|
|
|
Items.AddRange(armorData);
|
|
|
|
|
Items.AddRange(miscData);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private IEnumerable<Weapon> LoadWeaponData()
|
|
|
|
|
{
|
|
|
|
|
var data = mpqProvider
|
|
|
|
|
.GetTextFile(ResourcePaths.Weapons)
|
|
|
|
|
.Skip(1)
|
|
|
|
|
.Where(x => !String.IsNullOrWhiteSpace(x))
|
|
|
|
|
.Select(x => x.Split('\t'))
|
|
|
|
|
//.Where(x => !String.IsNullOrWhiteSpace(x[27]))
|
|
|
|
|
.ToArray()
|
|
|
|
|
.Select(x => x.ToWeapon());
|
|
|
|
|
|
|
|
|
|
return data;
|
|
|
|
|
;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private IEnumerable<Armor> LoadArmorData()
|
|
|
|
|
{
|
|
|
|
|
var data = mpqProvider
|
|
|
|
|
.GetTextFile(ResourcePaths.Armor)
|
|
|
|
|
.Skip(1)
|
|
|
|
|
.Where(x => !String.IsNullOrWhiteSpace(x))
|
|
|
|
|
.Select(x => x.Split('\t'))
|
|
|
|
|
//.Where(x => !String.IsNullOrWhiteSpace(x[27]))
|
|
|
|
|
.ToArray()
|
|
|
|
|
.Select(x => x.ToArmor());
|
|
|
|
|
|
|
|
|
|
return data;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private IEnumerable<Misc> LoadMiscData()
|
|
|
|
|
{
|
|
|
|
|
var data = mpqProvider
|
|
|
|
|
.GetTextFile(ResourcePaths.Misc)
|
|
|
|
|
.Skip(1)
|
|
|
|
|
.Where(x => !String.IsNullOrWhiteSpace(x))
|
|
|
|
|
.Select(x => x.Split('\t'))
|
|
|
|
|
//.Where(x => !String.IsNullOrWhiteSpace(x[27]))
|
|
|
|
|
.ToArray()
|
|
|
|
|
.Select(x => x.ToMisc());
|
|
|
|
|
|
|
|
|
|
return data;
|
|
|
|
|
}
|
2018-12-04 23:20:31 -05:00
|
|
|
|
|
|
|
|
|
private void LoadCharacterData()
|
|
|
|
|
{
|
|
|
|
|
LoadExperienceConfig();
|
2018-12-05 22:28:09 -05:00
|
|
|
|
LoadHeroTypeConfig();
|
2018-12-04 23:20:31 -05:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void LoadExperienceConfig()
|
|
|
|
|
{
|
|
|
|
|
var data = mpqProvider
|
|
|
|
|
.GetTextFile(ResourcePaths.Experience)
|
|
|
|
|
.Where(x => !String.IsNullOrWhiteSpace(x))
|
|
|
|
|
.Select(x => x.Split('\t'))
|
|
|
|
|
.ToArray()
|
|
|
|
|
.ToLevelExperienceConfigs();
|
|
|
|
|
|
|
|
|
|
ExperienceConfigs = data;
|
|
|
|
|
}
|
2018-12-05 22:28:09 -05:00
|
|
|
|
|
|
|
|
|
private void LoadHeroTypeConfig()
|
|
|
|
|
{
|
|
|
|
|
var data = mpqProvider
|
|
|
|
|
.GetTextFile(ResourcePaths.CharStats)
|
|
|
|
|
.Skip(1)
|
|
|
|
|
.Where(x => !String.IsNullOrWhiteSpace(x))
|
|
|
|
|
.Select(x => x.Split('\t'))
|
|
|
|
|
.Where(x => x[0] != "Expansion")
|
|
|
|
|
.ToArray()
|
|
|
|
|
.ToDictionary(x => (eHero)Enum.Parse(typeof(eHero),x[0]), x => x.ToHeroTypeConfig());
|
|
|
|
|
|
|
|
|
|
HeroTypeConfigs = data;
|
|
|
|
|
}
|
2018-11-24 03:07:41 -05:00
|
|
|
|
}
|
|
|
|
|
}
|