using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using EuuBot.Relay.PluginInterfaces;
using EuuBot.Relay.PluginInterfaces.Host;
using EuuBot.Debugging.Logging;
using EuuBot.Data.Maps;
using EuuBot.Data.Maps.MapInformations;
using System.Xml.Linq;
using EuuBot.Packets.Game.Character.Choice;
using EuuBot.Packets.Game.Context.Roleplay;
namespace EuuBot.Relay.Plugins.Maps
{
[PluginInformation("DataBaseMapsManager", "Shared plugin to retrieve maps information", "MikeDotNet", "1.0.1")]
public class MapsManagerPlugin : ISharedPlugin, ILoggable
{
private static MapManager _mapManager;
private IPluginHost _host;
/// <summary>
/// Retrieve the desired map
/// </summary>
/// <param name="mapId">The Id of the map to retrieve</param>
/// <returns>The Map object that correspond to the mapId, if no map correspond, an exception is thrown.</returns>
public Map GetMap(int mapId)
{
return _mapManager.GetMap((uint)mapId);
}
#region IPlugin Membres
public void Initiate(IPluginHost host)
{
//TODO : Shared plugins are not initialized. IPluginHost need to be re-defined for shared plugins. And remove the possibility to send packets
_host = host;
_mapManager = new MapManager(@"C:\Program Files (x86)\Dofus2\app\content\maps");
}
#endregion
#region IDisposable Membres
private bool _disposed = false;
public void Dispose()
{
Dispose(true);
GC.SuppressFinalize(this);
}
protected virtual void Dispose(bool disposing)
{
if (!_disposed)
{
if (disposing)
{
//dispose managed things, for example close running threads.
//Do not dispose the form, it is taken care by the plugin manager
}
//dispose unmanaged code
_disposed = true;
}
}
#endregion
#region ILoggable Membres
public Guid DebugKey
{
get { return _debugKey; }
}
private Guid _debugKey = Guid.NewGuid();
public event EventHandler<LogEventArgs> Log;
protected void onLog(string text)
{
onLog(text, LogType.Info);
}
protected void onLog(string text, LogType logType)
{
if (Log != null)
Log(this, new LogEventArgs(text, this.DebugKey));
}
#endregion
}
}