Voici un plugin pour EuuBot qui adapte le MapControl de Bouh2, qui affiche la map, les acteurs et les Interactives. C'est vraiment simple mais il est possible de faire beaucoup plus!
Le code pour le form:
Cliquez pour révéler
Cliquez pour masquer
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using EuuBot.Data.Maps;
using EuuBot.Data.Game.Context.Roleplay;
using EuuBot.Packets.Game.Context.Roleplay;
namespace EuuBot.Relay.Plugins.Maps.MapControl
{
public partial class MapControlForm : Form
{
public MapControlForm()
{
InitializeComponent();
}
private void MapControlForm_Load(object sender, EventArgs e)
{
}
public void UpdateMap(Map map, MapComplementaryInformationsDataMessage mapInfo)
{
foreach (var cell in map.CollisionData.CellData)
{
MapCell mCell = mapControl1.GetCell(cell.Id);
mCell.Text = string.Empty;
if (cell.Mov)
{
mCell.State = CellState.Walkable;
}
else
{
mCell.State = CellState.NonWalkable;
}
}
foreach (var actor in mapInfo.Actors)
{
mapControl1.GetCell(actor.Disposition.CellId).Text = "Actor";
}
foreach (var obs in mapInfo.Obstacles)
{
mapControl1.GetCell(obs.ObstacleCellId).Text = "Obstacle";
}
foreach (var stated in mapInfo.StatedElements)
{
mapControl1.GetCell(stated.ElementCellId).Text = "Interactive";
}
mapControl1.Invalidate(mapControl1.Cells);
}
}
}
Le code pour le plugin:
Cliquez pour révéler
Cliquez pour masquer
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.Packets.Game.Context.Roleplay;
namespace EuuBot.Relay.Plugins.Maps.MapControl
{
[PluginInformation("Bouh2 MapControl", "Bouh2 MapControl EuuBot implementation", "Bouh2 (adapted by MikeDotNet)", "1.0.0")]
public class MapControlPlugin : IConnectionPlugin, IFormPlugin, ILoggable
{
private Map _currentMap;
private IPluginHost _host;
#region IConnectionPlugin Membres
public bool ForceAutoLoad
{
get { return false; }
}
public PacketAction ProcessClientPacket(Packets.ClientPacket packet)
{
return PacketAction.Keep;
}
public PacketAction ProcessServerPacket(Packets.ServerPacket packet)
{
if (packet.PacketType == Packets.ServerPacketType.MapComplementaryInformationsDataMessage)
{
MapComplementaryInformationsDataMessage mapInfoMessage = (MapComplementaryInformationsDataMessage)packet;
_currentMap = _host.GetPlugin<MovementPlugin>().GetMap(mapInfoMessage.MapId);
_form.UpdateMap(_currentMap, mapInfoMessage);
}
return PacketAction.Keep;
}
#endregion
#region IPlugin Membres
public void Initiate(IPluginHost host)
{
_host = host;
}
#endregion
#region IDisposable Membres
public void Dispose()
{
}
#endregion
#region IFormPlugin Membres
public System.Windows.Forms.Form GetPluginForm()
{
if (_form == null)
_form = new MapControlForm();
return _form;
}
private MapControlForm _form;
#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)
{
if (Log != null)
Log(this, new LogEventArgs(text, _debugKey));
}
#endregion
}
}