command - mtanksl/OpenTibia GitHub Wiki
Introduction
Commands
abstract away how and which clients needs to receive this information.
Example
A magic effect displayed to all nearby players.
public class ShowMagicEffectCommand : Command
{
public ShowMagicEffectCommand(Position position, MagicEffectType magicEffectType)
{
Position = position;
MagicEffectType = magicEffectType;
}
public Position Position { get; set; }
public MagicEffectType MagicEffectType { get; set; }
public override Promise Execute()
{
foreach (var observer in Context.Server.Map.GetObserversOfTypePlayer(Position) )
{
if (observer.Tile.Position.CanSee(Position) )
{
Context.AddPacket(observer, new ShowMagicEffectOutgoingPacket(Position, MagicEffectType );
}
}
return Promise.Completed;
}
}