Exemplo n.º 1
0
        /// <summary>Adds the new target.</summary>
        /// <remarks>Precondition: target is null, newTarget is non-null.</remarks>
        /// <param name="newTarget">The new target.</param>
        private void AddTarget(Thing newTarget)
        {
            var self = Parent;

            if (self != null)
            {
                var message     = CreateFollowMessage(self, newTarget);
                var followEvent = new FollowEvent(self, message, self, newTarget);

                self.Eventing.OnMovementRequest(followEvent, EventScope.ParentsDown);

                if (!followEvent.IsCancelled)
                {
                    target = new SimpleWeakReference <Thing>(newTarget);
                    newTarget.Eventing.MovementEvent += ProcessMovementEvent;
                    self.Eventing.OnMovementEvent(followEvent, EventScope.ParentsDown);
                }
            }
        }