Example #1
0
        /// <summary>
        ///		Adds a new subscriber to this Collision Subscription
        /// </summary>
        /// <param name="newSubscriber"></param>
        /// <returns></returns>
        public CollisonSubscriberHolder Register(ICollisionSubscriber newSubscriber)
        {
            CollisonSubscriberHolder newHolder = new CollisonSubscriberHolder(newSubscriber);

            this.listOfSubscribers.PushFront(newHolder);
            return(newHolder);
        }
Example #2
0
        /// <summary>
        ///		Remove every subscriber from this subscription
        /// </summary>
        public void UnregisterAll()
        {
            CollisonSubscriberHolder itr = this.listOfSubscribers.Head as CollisonSubscriberHolder;

            while (itr != null)
            {
                this.listOfSubscribers.PopFront();
                itr = this.listOfSubscribers.Head as CollisonSubscriberHolder;
            }
        }
Example #3
0
        /// <summary>
        ///		Remove a subscriber from this subscription
        /// </summary>
        /// <param name="oldSubscriber"></param>
        /// <returns></returns>
        public bool Unregister(ICollisionSubscriber oldSubscriber)
        {
            CollisonSubscriberHolder oldHolder = this.Search(oldSubscriber);

            Debug.Assert(oldHolder != null);
            oldHolder.Reset();
            this.listOfSubscribers.Pop(oldHolder);
            oldHolder = null;

            return(true);
        }
Example #4
0
        /// <summary>
        ///		Notify every subscriber that a collision occured
        /// </summary>
        public void Notify()
        {
            CollisonSubscriberHolder itr = this.listOfSubscribers.Head as CollisonSubscriberHolder;

            while (itr != null)
            {
                // Notify the individual subscriber
                itr.NotifySubscriber(collisionName);

                // Next subscriber
                itr = itr.next as CollisonSubscriberHolder;
            }
        }
Example #5
0
        //
        // Private Methods
        //

        /// <summary>
        ///		Return a CollisonSubscriberHolder given an ICollisionScriber
        /// </summary>
        /// <param name="queriedSubscriber"></param>
        /// <returns></returns>
        private CollisonSubscriberHolder Search(ICollisionSubscriber queriedSubscriber)
        {
            CollisonSubscriberHolder itr = this.listOfSubscribers.Head as CollisonSubscriberHolder;

            while (itr != null)
            {
                if (ReferenceEquals(itr.Subscriber, queriedSubscriber))
                {
                    break;                      // Found it
                }

                itr = itr.next as CollisonSubscriberHolder;
            }

            return(itr);
        }