1
1
mirror of https://github.com/OpenDiablo2/OpenDiablo2 synced 2024-11-18 18:36:12 -05:00
OpenDiablo2/OpenDiablo2.Core/EngineDataManager.cs

72 lines
2.2 KiB
C#
Raw Normal View History

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;
using OpenDiablo2.Common.Interfaces;
using OpenDiablo2.Common.Models;
namespace OpenDiablo2.Core
{
public sealed class EngineDataManager : IEngineDataManager
{
private readonly IMPQProvider mpqProvider;
public List<LevelPreset> LevelPresets { get; internal set; }
public List<LevelType> LevelTypes { get; internal set; }
public List<LevelDetail> LevelDetails { get; internal set; }
2018-11-24 03:07:41 -05:00
public EngineDataManager(IMPQProvider mpqProvider)
{
this.mpqProvider = mpqProvider;
LoadLevelPresets();
LoadLevelTypes();
LoadLevelDetails();
2018-11-24 03:07:41 -05:00
}
private void LoadLevelTypes()
{
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()
{
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);
}
private void LoadLevelDetails()
{
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-11-24 03:07:41 -05:00
}
}