Ejemplo n.º 1
0
        /// <summary>
        /// Add player to the required group for the game
        /// </summary>
        /// <param name="ua"></param>
        /// <returns>true if add was successful, false if not</returns>
        public bool AddPlayerToRequiredGroup(UserAccount ua)
        {
            if (!WaterWarsConstants.ENABLE_GROUPS)
            {
                return(true);
            }

            m_log.InfoFormat(
                "[WATER WARS]: Adding player {0} to group {1} {2}",
                ua.Name, WaterWarsGroup.GroupName, WaterWarsGroup.GroupID);

            ScenePresence scenePresence = null;

            // Look for the presence in every scene.  If this kind of thing becomes common we will need to refactor the
            // code
            foreach (Scene scene in m_controller.Scenes)
            {
                ScenePresence sp = scene.GetScenePresence(ua.PrincipalID);
                if (sp != null)
                {
                    scenePresence = sp;
                    break;
                }
            }

            if (scenePresence != null)
            {
                m_groupsModule.JoinGroupRequest(scenePresence.ControllingClient, WaterWarsGroup.GroupID);
                return(true);
            }

            return(false);
        }