public NetworkMessage BuildMessage(uint id, IDataReader reader)
{
if (!m_messages.ContainsKey(id))
{
return new UnknownMessage(id, reader);
//throw new MessageNotFoundException(string.Format("NetworkMessage <id:{0}> doesn't exist", id));
}
NetworkMessage message = m_constructors[id]();
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using BiM.Core.IO;
namespace BiM.Core.Network
{
public class UnknownMessage : NetworkMessage
{
uint _messageId = 0xFFFFFFFF;
public override uint MessageId { get { return _messageId; } }
public UnknownMessage()
{
_messageId = 0xFFFFFFFF;
}
public UnknownMessage(uint messageId, IDataReader reader)
{
_messageId = messageId;
Unpack(reader);
}
public byte[] Content { get; set; }
public override void Serialize(IDataWriter writer)
{
writer.WriteBytes(Content);
}
public override void Deserialize(IDataReader reader)
{
Content = reader.ReadBytes((int)reader.BytesAvailable);
}
public override string ToString()
{
return string.Format("UnknownMessage#Id{0}#{1}bytes", _messageId, Content == null ? 0 : Content.Length);
}
}
}
try
{
if (to.Id == cell.Id)
continue;
if (!cell.LineOfSight || !throughEntities && Array.IndexOf(occupiedCells, cell.Id) != -1)
return false;
}
catch { }
finally { }
bool TryCast(string explain)
{
lastActionFailed = false;
_explain = explain;
if (spellTarget == null || spellTarget.Spell == null || spellTarget.FromCell == null || spellTarget.TargetCell == null || spellTarget.Efficiency <= 0 || spellTarget.cast == true)
return false;
if (spellTarget.Spell.Template.id == 26) // benedition animale
{
if (Fighter.CanSummon()) // pas besoin , il peu encore invoquer
{
return false;
}
spellTarget = new SpellTarget(spellTarget.Efficiency, Fighter.Cell, Fighter.Cell, spellTarget.Spell); // forcer la cible sur lui meme
}
ComeAtSpellRangeThenCast();
return !lastActionFailed;
}