2015-05-08 10:20:13 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.IO;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Xml.Serialization;
|
|
|
|
|
using TransportGame.Model;
|
|
|
|
|
using TransportGame.Utils;
|
|
|
|
|
|
|
|
|
|
namespace TransportGame.Business
|
|
|
|
|
{
|
|
|
|
|
public static class BiomeManager
|
|
|
|
|
{
|
|
|
|
|
private static List<Biome> biomes = new List<Biome>();
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets all the loaded biomes
|
|
|
|
|
/// </summary>
|
|
|
|
|
public static IEnumerable<Biome> Biomes
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return biomes;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Loads the biomes from the Biome directory.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public static void LoadBiomes()
|
|
|
|
|
{
|
2015-06-03 20:54:22 +00:00
|
|
|
|
foreach (var file in Directory.GetFiles(ConfigManager.BiomeDirectory, "*.xml", SearchOption.AllDirectories))
|
2015-05-08 10:20:13 +00:00
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
// Try to deserialize biome
|
2015-05-22 08:26:29 +00:00
|
|
|
|
var biome = SerializationHelper.DeserializeXml<Biome>(file);
|
2015-05-09 15:06:30 +00:00
|
|
|
|
biome.FileName = file;
|
2015-05-08 10:20:13 +00:00
|
|
|
|
|
|
|
|
|
// Add it to biome list
|
|
|
|
|
biomes.Add(biome);
|
|
|
|
|
Logger.Info("Loaded biome '{0}' from file '{1}'.", biome.Name, file);
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
Logger.Exception(ex);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|