/// <summary> /// Schedules an action according to the supplied <see cref="WheelMUD.Core.TimeEvent"/>. /// </summary> /// <param name="timeEventArgs">The <see cref="WheelMUD.Core.TimeEvent"/> instance containing the event data.</param> public void ScheduleEvent(TimeEvent timeEventArgs) { if (timeEventArgs == null) { throw new ArgumentException("Cannot schedule a null event.", "args"); } lock (this.callbackQueue) { this.callbackQueue.Enqueue(timeEventArgs); } }
/// <summary> /// Enqueues the specified element and the associated expiration DateTime. /// </summary> /// <param name="timeEventArgs">The <see cref="WheelMUD.Core.TimeEvent"/> instance containing the event data.</param> public void Enqueue(TimeEvent timeEventArgs) { lock (this.heap) { this.heap.Add(timeEventArgs); this.UpHeap(); } }
/// <summary> /// Called when a parent has just been assigned to this behavior. /// This method first creates and broadcasts an event notifying users that /// the mute effect was applied. Then it creates another event that holds /// the Unmute method, and adds it to the TimeSystem scheduler to call /// after the duration time has passed. /// </summary> public override void OnAddBehavior() { // While this effect is attached to its parent, it denies all verbal communications from it. this.Interceptor = new CancellableGameEventHandler(this.DenyCommunicationRequest); this.Parent.Eventing.CommunicationRequest += this.Interceptor; // Create event and broadcast it to let the affected parties know the effect was applied. var muteEvent = new EffectEvent(this.ActiveThing, this.Parent, this.SensoryMessage); this.ActiveThing.Eventing.OnCommunicationRequest(muteEvent, EventScope.ParentsDown); if (!muteEvent.IsCancelled) { this.ActiveThing.Eventing.OnCommunicationEvent(muteEvent, EventScope.ParentsDown); } // Create an event to be broadcast when the mute effect expires, // and schedule it with the TimeSystem. this.UnmuteEvent = new TimeEvent(this.ActiveThing, this.Unmute, this.EndTime, this.ExpirationMessage); TimeSystem.Instance.ScheduleEvent(this.UnmuteEvent); base.OnAddBehavior(); }