I found a way to do
in your PlayerMobile.cs > PlayerMobile class add the following code:
Code:
#region Delegates/Events
public delegate void OnMoveEventHandler();
public event OnMoveEventHandler OnMoveEvent;
#endregion
(or if want another event instead of OnMove)
now you have the handlers set, with no function
go to your PlayerMobile OnMove(Direction d) method and add the following code
Code:
if (OnMoveEvent != null) //check if we have any event set
OnMoveEvent();
ok, now we want to fire this event when someone equip an item, so:
at your item class, declare a variable that will hold your event
Code:
private static PlayerMobile.OnMoveEventHandler ev = new PlayerMobile.OnMoveEventHandler(pm_OnMove);
override the OnEquip(Mobile from) on your item and do something like that
Code:
public override bool OnEquip(Mobile from)
{
PlayerMobile pm = from as PlayerMobile;
pm.OnMoveEvent += ev;
Console.WriteLine(pm.Name + " Just equiped"); //just debug
return true;
}
them create the method that we specified when declaring the ev variable
Code:
private static void pm_OnMove()
{
Console.WriteLine("Just moved");
}
so now we have an event that will fire only when the player has the item equiped
(the code above didnt remove the event handler from the player, so if you unequip, or delete the item, the event will remain - dont forget to remove the handler in these cases)
the only trouble that i got is, how we will serialize/deserialize the handlers on PlayerMobile
any idea how to improve, please tell me
thanks