/// <summary>
        /// Updates the state of an agent that is already in transit.
        /// </summary>
        /// <param name='id'></param>
        /// <param name='newState'></param>
        /// <returns></returns>
        /// <exception cref='Exception'>Illegal transitions will throw an Exception</exception>
        internal void SetState(ScenePresenceState newState)
        {
            bool transitionOkay = false;

            lock (this)
            {
                if (newState == m_state)
                    return;
                else if (newState == ScenePresenceState.Running && m_state == ScenePresenceState.PreRemove)
                    transitionOkay = true;
                else if (newState == ScenePresenceState.PreRemove && m_state == ScenePresenceState.Running)
                    transitionOkay = true;
                else if (newState == ScenePresenceState.Removing)
                {   
                    if (m_state == ScenePresenceState.Running || m_state == ScenePresenceState.PreRemove)
                        transitionOkay = true;
                }
                else if (newState == ScenePresenceState.Removed && m_state == ScenePresenceState.Removing)
                    transitionOkay = true;
            }           

            if (!transitionOkay)
            {
                throw new Exception(
                    string.Format(
                        "Scene presence {0} is not allowed to move from state {1} to new state {2} in {3}",
                        m_sp.Name, m_state, newState, m_sp.Scene.Name));
            }
            else
            {
                m_state = newState;
            }
        }
 internal ScenePresenceStateMachine(ScenePresence sp)
 {
     m_sp    = sp;
     m_state = ScenePresenceState.Running;
 }
 internal ScenePresenceStateMachine(ScenePresence sp)
 {
     m_sp = sp;
     m_state = ScenePresenceState.Running;
 }