/// <summary> /// Initializes a new instance of the <see cref="GenericEvent"/> class. /// </summary> /// <param name="requestorId">The id of the creature requesting this event.</param> /// <param name="conditions">The conditions of the event.</param> /// <param name="onSuccessActions">The actions to run if the event passes conditions.</param> /// <param name="onFailActions">The actions to run if the event fails to pass conditions.</param> /// <param name="evaluationTime">Optional. The time on which the event's conditions should be evaluated. Default is <see cref="EvaluationTime.OnBoth"/>.</param> public GenericEvent(uint requestorId, IEventCondition [] conditions, IEventAction [] onSuccessActions, IEventAction[] onFailActions, EvaluationTime evaluationTime = EvaluationTime.OnBoth) : base(requestorId, evaluationTime) { if (conditions != null) { foreach (var condition in conditions) { Conditions.Add(condition); } } if (onSuccessActions != null) { foreach (var action in onSuccessActions) { ActionsOnPass.Add(action); } } if (onFailActions != null) { foreach (var action in onFailActions) { ActionsOnFail.Add(action); } } }
/// <summary> /// Initializes a new instance of the <see cref="MovementBase"/> class. /// </summary> /// <param name="requestorId">The id of the creature requesting the movement.</param> /// <param name="evaluationTime">The time to evaluate the movement.</param> protected MovementBase(uint requestorId, EvaluationTime evaluationTime) : base(requestorId, evaluationTime) { ActionsOnFail.Add( new GenericEventAction( () => { var player = Requestor as Player; if (player != null) { Game.Instance.NotifySinglePlayer(player, conn => new GenericNotification( conn, new PlayerWalkCancelPacket { Direction = player.ClientSafeDirection }, new TextMessagePacket { Message = ErrorMessage ?? "Sorry, not possible.", Type = MessageType.StatusSmall })); } })); }