当前位置: 首页>>代码示例>>C#>>正文


C# IScene.GetScenePresences方法代码示例

本文整理汇总了C#中IScene.GetScenePresences方法的典型用法代码示例。如果您正苦于以下问题:C# IScene.GetScenePresences方法的具体用法?C# IScene.GetScenePresences怎么用?C# IScene.GetScenePresences使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IScene的用法示例。


在下文中一共展示了IScene.GetScenePresences方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: KickUserCommand

        /// <summary>
        ///     Kicks users off the region
        /// </summary>
        /// <param name="cmdparams">name of avatar to kick</param>
        void KickUserCommand(IScene scene, string[] cmdparams)
        {
            IList agents = new List<IScenePresence>(scene.GetScenePresences());

            if (cmdparams.Length > 2 && cmdparams[2] == "all")
            {
                string alert = MainConsole.Instance.Prompt("Alert message: ", "");
                foreach (IScenePresence presence in agents)
                {
                    RegionInfo regionInfo = presence.Scene.RegionInfo;

                    MainConsole.Instance.Info(String.Format("Kicking user: {0,-16}{1,-37} in region: {2,-16}",
                                                            presence.Name, presence.UUID, regionInfo.RegionName));

                    //kick client
                    presence.ControllingClient.Kick(alert ?? "\nThe Universe manager kicked you out.\n");

                    //close on our side
                    IEntityTransferModule transferModule =
                        presence.Scene.RequestModuleInterface<IEntityTransferModule>();
                    if (transferModule != null)
                        transferModule.IncomingCloseAgent(presence.Scene, presence.UUID);
                }
                return;
            }
            else
            {
                string username = MainConsole.Instance.Prompt("User to kick: ", "");
                string alert = MainConsole.Instance.Prompt("Alert message: ", "");

                foreach (IScenePresence presence in agents)
                {
                    if (presence.Name.ToLower().Contains(username.ToLower()))
                    {
                        MainConsole.Instance.Info(String.Format("Kicking user: {0} in region: {1}",
                                                                presence.Name, presence.Scene.RegionInfo.RegionName));

                        // kick client
                        presence.ControllingClient.Kick(alert ?? "\nThe Universe manager kicked you out.\n");

                        //close on our side
                        IEntityTransferModule transferModule =
                            presence.Scene.RequestModuleInterface<IEntityTransferModule>();
                        if (transferModule != null)
                            transferModule.IncomingCloseAgent(presence.Scene, presence.UUID);
                    }
                }
            }
        }
开发者ID:emperorstarfinder,项目名称:Virtual-Universe,代码行数:53,代码来源:SceneManager.cs

示例2: CreateAvatar

        /// <summary>
        ///   Creates a new bot inworld
        /// </summary>
        /// <param name = "FirstName"></param>
        /// <param name = "LastName"></param>
        /// <param name = "cloneAppearanceFrom">UUID of the avatar whos appearance will be copied to give this bot an appearance</param>
        /// <returns>ID of the bot</returns>
        public UUID CreateAvatar(string FirstName, string LastName, IScene scene, UUID cloneAppearanceFrom,
                                 UUID creatorID, Vector3 startPos)
        {
            AgentCircuitData m_aCircuitData = new AgentCircuitData
                                                  {
                                                      child = false,
                                                      circuitcode = (uint) Util.RandomClass.Next(),
                                                      Appearance = GetAppearance(cloneAppearanceFrom, scene)
                                                  };

            //Add the circuit data so they can login

            //Sets up appearance
            if (m_aCircuitData.Appearance == null)
            {
                m_aCircuitData.Appearance = new AvatarAppearance {Wearables = AvatarWearable.DefaultWearables};
            }
            //Create the new bot data
            BotClientAPI m_character = new BotClientAPI(scene, m_aCircuitData) { FirstName = FirstName, LastName = LastName };

            m_aCircuitData.AgentID = m_character.AgentId;
            m_aCircuitData.Appearance.Owner = m_character.AgentId;
            List<AvatarAttachment> attachments = m_aCircuitData.Appearance.GetAttachments();

            m_aCircuitData.Appearance.ClearAttachments();
            foreach (AvatarAttachment t in attachments)
            {
                InventoryItemBase item = scene.InventoryService.GetItem(new InventoryItemBase(t.ItemID));
                if (item != null)
                {
                    item.ID = UUID.Random();
                    item.Owner = m_character.AgentId;
                    item.Folder = UUID.Zero;
                    scene.InventoryService.AddItemAsync(item, null);
                    //Now fix the ItemID
                    m_aCircuitData.Appearance.SetAttachment(t.AttachPoint, item.ID, t.AssetID);
                }
            }

            scene.AuthenticateHandler.AgentCircuits.Add(m_character.CircuitCode, m_aCircuitData);
            //This adds them to the scene and sets them inworld
            AddAndWaitUntilAgentIsAdded(scene, m_character);

            IScenePresence SP = scene.GetScenePresence(m_character.AgentId);
            if (SP == null)
                return UUID.Zero; //Failed!
            Bot bot = new Bot();
            bot.Initialize(SP, creatorID);
            SP.MakeRootAgent(startPos, false, true);
            //Move them
            SP.Teleport(startPos);

            foreach(var presence in scene.GetScenePresences())
                presence.SceneViewer.QueuePresenceForUpdate(SP, PrimUpdateFlags.ForcedFullUpdate);
            IAttachmentsModule attModule = SP.Scene.RequestModuleInterface<IAttachmentsModule>();
            if (attModule != null)
                foreach (AvatarAttachment att in attachments)
                    attModule.RezSingleAttachmentFromInventory(SP.ControllingClient, att.ItemID, att.AssetID, 0, true);

            IAvatarAppearanceModule appearance = SP.RequestModuleInterface<IAvatarAppearanceModule>();
            appearance.InitialHasWearablesBeenSent = true;

            //Save them in the bots list
            m_bots.Add(m_character.AgentId, bot);
            AddTagToBot(m_character.AgentId, "AllBots", bot.AvatarCreatorID);

            MainConsole.Instance.Info("[RexBotManager]: Added bot " + m_character.Name + " to scene.");
            //Return their UUID
            return m_character.AgentId;
        }
开发者ID:nathanmarck,项目名称:Aurora-Sim,代码行数:77,代码来源:BotManager.cs

示例3: HandleShowUsers

        /// <summary>
        /// Handles the show users command.
        /// </summary>
        /// <param name="scene">Scene.</param>
        /// <param name="cmd">Cmd.</param>
        void HandleShowUsers(IScene scene, string[] cmd)
        {
            List<string> args = new List<string>(cmd);
            args.RemoveAt(0);
            string[] showParams = args.ToArray();

            List<IScenePresence> agents = new List<IScenePresence>();
            agents.AddRange(scene.GetScenePresences());
            if (showParams.Length == 1 || showParams[1] != "full")
                agents.RemoveAll(sp => sp.IsChildAgent);

            MainConsole.Instance.Info(String.Format("\n" + scene.RegionInfo.RegionName +": "+
                (agents.Count == 0 ? "No": agents.Count.ToString()) + " Agents connected\n"));
            if (agents.Count == 0)
                return;

            // we have some details to show...
            MainConsole.Instance.CleanInfo(String.Format("{0,-16}{1,-37}{2,-14}{3,-20}{4,-30}",
                "Username", "Agent ID", "Root/Child", "Region", "Position"));

            foreach (IScenePresence presence in agents)
            {
                RegionInfo regionInfo = presence.Scene.RegionInfo;

                string regionName = regionInfo == null ? "Unresolvable" : regionInfo.RegionName;

                    MainConsole.Instance.CleanInfo(String.Format("{0,-16}{1,-37}{2,-14}{3,-20}{4,-30}", presence.Name,
                                                        presence.UUID, presence.IsChildAgent ? "Child" : "Root",
                                                        regionName, presence.AbsolutePosition.ToString()));
            }

            MainConsole.Instance.CleanInfo(String.Empty);
            MainConsole.Instance.CleanInfo(String.Empty);
        }
开发者ID:emperorstarfinder,项目名称:Virtual-Universe,代码行数:39,代码来源:SceneManager.cs

示例4: HandleShowUsers

        private void HandleShowUsers(IScene scene, string[] cmd)
        {
            List<string> args = new List<string>(cmd);
            args.RemoveAt(0);
            string[] showParams = args.ToArray();

            List<IScenePresence> agents = new List<IScenePresence>();
            agents.AddRange(scene.GetScenePresences());
            if (showParams.Length == 1 || showParams[1] != "full")
                agents.RemoveAll(sp => sp.IsChildAgent);

            MainConsole.Instance.Info(String.Format("\nAgents connected: {0}\n", agents.Count));

            MainConsole.Instance.Info(String.Format("{0,-16}{1,-16}{2,-37}{3,-11}{4,-16}{5,-30}", "Firstname",
                                                    "Lastname", "Agent ID", "Root/Child", "Region", "Position"));

            foreach (IScenePresence presence in agents)
            {
                RegionInfo regionInfo = presence.Scene.RegionInfo;

                string regionName = regionInfo == null ? "Unresolvable" : regionInfo.RegionName;

                MainConsole.Instance.Info(String.Format("{0,-16}{1,-37}{2,-11}{3,-16}{4,-30}", presence.Name,
                                                        presence.UUID, presence.IsChildAgent ? "Child" : "Root",
                                                        regionName, presence.AbsolutePosition.ToString()));
            }

            MainConsole.Instance.Info(String.Empty);
            MainConsole.Instance.Info(String.Empty);
        }
开发者ID:BogusCurry,项目名称:WhiteCore-Dev,代码行数:30,代码来源:SceneManager.cs

示例5: SerializeUsers

        private void SerializeUsers(IScene scene)
        {
            OSDMap userMap = new OSDMap();
            foreach (IScenePresence presence in scene.GetScenePresences())
            {
                OSDMap user = new OSDMap();
                OSDMap remoteIP = new OSDMap();
                remoteIP["Address"] = presence.ControllingClient.RemoteEndPoint.Address.ToString();
                remoteIP["Port"] = presence.ControllingClient.RemoteEndPoint.Port;
                user["RemoteEndPoint"] = remoteIP;
                user["ClientInfo"] = presence.ControllingClient.RequestClientInfo().ToOSD();
                user["Position"] = presence.AbsolutePosition;
                user["IsFlying"] = presence.PhysicsActor.Flying;

                userMap[presence.UUID.ToString()] = user;
            }

            File.WriteAllText(BuildSaveFileName(), OSDParser.SerializeJsonString(userMap));
        }
开发者ID:QueenStarfinder,项目名称:WhiteCore-Dev,代码行数:19,代码来源:InworldRestartSerializer.cs

示例6: SerializeUsers

        void SerializeUsers(IScene scene)
        {
            List<IScenePresence> sceneAgents = scene.GetScenePresences ();
            if (sceneAgents.Count == 0)
                return;

            var regionUsers = 0;
            OSDMap userMap = new OSDMap ();
            foreach (IScenePresence presence in sceneAgents)
            {
                OSDMap user = new OSDMap ();
                OSDMap remoteIP = new OSDMap ();

                remoteIP ["Address"] = presence.ControllingClient.RemoteEndPoint.Address.ToString ();
                remoteIP ["Port"] = presence.ControllingClient.RemoteEndPoint.Port;

                user ["RemoteEndPoint"] = remoteIP;
                user ["ClientInfo"] = presence.ControllingClient.RequestClientInfo ().ToOSD ();
                user ["Position"] = presence.AbsolutePosition;
                user ["IsFlying"] = presence.PhysicsActor.Flying;

                userMap [presence.UUID.ToString ()] = user;

                regionUsers++;
            }

            var regionName = scene.RegionInfo.RegionName;
            var sceneFile = BuildSaveFileName (regionName);

            File.WriteAllText (sceneFile, OSDParser.SerializeJsonString (userMap));
            MainConsole.Instance.InfoFormat ("[Restart]: {0} users saved for {1}", regionUsers, regionName);
        }
开发者ID:CaseyraeStarfinder,项目名称:WhiteCore-Dev,代码行数:32,代码来源:RestartModule.cs

示例7: CreateAvatar

        public UUID CreateAvatar(string firstName, string lastName, IScene scene, AvatarAppearance avatarApp,
            UUID creatorID, Vector3 startPos)
        {
            //Add the circuit data so they can login
            AgentCircuitData m_aCircuitData = new AgentCircuitData
            {
                IsChildAgent = false,
                CircuitCode = (uint) Util.RandomClass.Next()
            };

            //Create the new bot data
            BotClientAPI m_character = new BotClientAPI(scene, m_aCircuitData);
            m_character.Name = firstName + " " + lastName;
            m_aCircuitData.AgentID = m_character.AgentId;

            //Set up appearance
            var origOwner = avatarApp.Owner;
            avatarApp.Owner = m_character.AgentId;
            List<AvatarAttachment> attachments = avatarApp.GetAttachments();

            avatarApp.ClearAttachments();
            // get original attachments
            foreach (AvatarAttachment t in attachments)
            {
                InventoryItemBase item = scene.InventoryService.GetItem(origOwner, t.ItemID);
                if (item != null)
                {
                    item.ID = UUID.Random();
                    item.Owner = m_character.AgentId;
                    item.Folder = UUID.Zero;
                    scene.InventoryService.AddCacheItemAsync(item);
                    //Now fix the ItemID
                    avatarApp.SetAttachment(t.AttachPoint, item.ID, t.AssetID);
                }
            }

            scene.AuthenticateHandler.AgentCircuits.Add(m_character.CircuitCode, m_aCircuitData);
            //This adds them to the scene and sets them in world
            AddAndWaitUntilAgentIsAdded(scene, m_character);

            IScenePresence SP = scene.GetScenePresence(m_character.AgentId);
            if (SP == null)
                return UUID.Zero; //Failed!

            IAvatarAppearanceModule appearance = SP.RequestModuleInterface<IAvatarAppearanceModule>();
            appearance.Appearance = avatarApp;
            appearance.InitialHasWearablesBeenSent = true;
            Bot bot = new Bot();
            bot.Initialize(SP, creatorID);
            SP.MakeRootAgent(startPos, false, true);
            //Move them
            SP.Teleport(startPos);

            foreach (var presence in scene.GetScenePresences())
                presence.SceneViewer.QueuePresenceForUpdate(SP, PrimUpdateFlags.ForcedFullUpdate);
            IAttachmentsModule attModule = SP.Scene.RequestModuleInterface<IAttachmentsModule>();
            if (attModule != null)
                foreach (AvatarAttachment att in attachments)
                    attModule.RezSingleAttachmentFromInventory(SP.ControllingClient, att.ItemID, att.AssetID, 0, true);

            //Save them in the bots list
            m_bots.Add(m_character.AgentId, bot);
            AddTagToBot(m_character.AgentId, "AllBots", bot.AvatarCreatorID);

            MainConsole.Instance.InfoFormat("[BotManager]: Added bot {0} to region {1}",
                m_character.Name, scene.RegionInfo.RegionName);

            //Return their UUID
            return m_character.AgentId;
        }
开发者ID:CaseyraeStarfinder,项目名称:WhiteCore-Dev,代码行数:70,代码来源:BotManager.cs


注:本文中的IScene.GetScenePresences方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。