コード例 #1
0
        public object SendAttachments(string funct, object param)
        {
            object[]       parameters = (object[])param;
            IScenePresence sp         = (IScenePresence)parameters[1];

            Interfaces.GridRegion dest = (Interfaces.GridRegion)parameters[0];
            // this is never used..
            IAttachmentsModule att = sp.Scene.RequestModuleInterface <IAttachmentsModule> ();

            if (m_userAttachments.ContainsKey(sp.UUID))
            {
                Util.FireAndForget(delegate
                {
                    foreach (ISceneEntity attachment in m_userAttachments[sp.UUID])
                    {
                        Connectors.Simulation.SimulationServiceConnector ssc = new Connectors.Simulation.SimulationServiceConnector();
                        attachment.IsDeleted = false;//Fix this, we 'did' get removed from the sim already
                        //Now send it to them
                        ssc.CreateObject(dest, (ISceneObject)attachment);
                        attachment.IsDeleted = true;
                    }
                });
            }
            return(null);
        }
コード例 #2
0
        /// <summary>
        ///     The movement animation is reserved for "main" animations
        ///     that are mutually exclusive, e.g. flying and sitting.
        /// </summary>
        public void TrySetMovementAnimation(string anim, bool sendTerseUpdateIfNotSending)
        {
            //MainConsole.Instance.DebugFormat("Updating movement animation to {0}", anim);

            if (!m_useSplatAnimation && anim == "STANDUP")
            {
                anim = "LAND";
            }

            if (!m_scenePresence.IsChildAgent)
            {
                if (m_animations.TrySetDefaultAnimation(
                        anim, m_scenePresence.ControllingClient.NextAnimationSequenceNumber, m_scenePresence.UUID))
                {
                    // 16384 is CHANGED_ANIMATION
                    IAttachmentsModule attMod = m_scenePresence.Scene.RequestModuleInterface <IAttachmentsModule>();
                    if (attMod != null)
                    {
                        attMod.SendScriptEventToAttachments(m_scenePresence.UUID, "changed",
                                                            new Object[] { (int)Changed.ANIMATION });
                    }
                    SendAnimPack();
                }
                else if (sendTerseUpdateIfNotSending)
                {
                    m_scenePresence.SendTerseUpdateToAllClients(); //Send the terse update alone then
                }
            }
        }
コード例 #3
0
        void OnSetAgentLeaving(IScenePresence presence, Interfaces.GridRegion destination)
        {
            IAttachmentsModule attModule = presence.Scene.RequestModuleInterface <IAttachmentsModule>();

            if (attModule != null)
            {
                m_userAttachments[presence.UUID] = attModule.GetAttachmentsForAvatar(presence.UUID);
            }
        }
コード例 #4
0
        private void AddPresenceToCurrentlyInView(IScenePresence presence)
        {
            lastPresencesDInView.Add(presence.UUID, presence);
            //We need to send all attachments of this avatar as well
            IAttachmentsModule attmodule =
                presence.Scene.RequestModuleInterface <IAttachmentsModule>();

            if (attmodule != null)
            {
                attmodule.SendAttachmentsToPresence(presence, m_presence);
            }
        }
コード例 #5
0
        void KillAttachments(IScenePresence agent)
        {
            IAttachmentsModule attModule = agent.Scene.RequestModuleInterface <IAttachmentsModule> ();

            if (attModule != null)
            {
                ISceneEntity [] attachments = attModule.GetAttachmentsForAvatar(agent.UUID);
                foreach (ISceneEntity grp in attachments)
                {
                    // Kill in all clients as it will be re-added in the other region
                    KillEntities(agent, grp.ChildrenEntities().ToArray());
                    // Now remove it from the Scene so that it will not come back
                    agent.Scene.SceneGraph.DeleteEntity(grp);
                }
            }
        }
コード例 #6
0
        protected void SendFullUpdateForPresence(IScenePresence presence)
        {
            Util.FireAndForget(delegate
            {
                m_presence.ControllingClient.SendAvatarDataImmediate(presence);
                //Send the animations too
                presence.Animator.SendAnimPackToClient(m_presence.ControllingClient);
                //Send the presence of this agent to us
                IAvatarAppearanceModule module =
                    presence.RequestModuleInterface <IAvatarAppearanceModule>();
                if (module != null)
                {
                    module.SendAppearanceToAgent(m_presence);
                }
                //We need to send all attachments of this avatar as well
                IAttachmentsModule attmodule =
                    m_presence.Scene.RequestModuleInterface <IAttachmentsModule>();
                if (attmodule != null)
                {
                    ISceneEntity[] entities = attmodule.GetAttachmentsForAvatar(m_presence.UUID);
                    foreach (ISceneEntity entity in entities)
                    {
                        QueuePartForUpdate(entity.RootChild, PrimUpdateFlags.ForcedFullUpdate);
#if (!ISWIN)
                        foreach (ISceneChildEntity child in entity.ChildrenEntities())
                        {
                            if (!child.IsRoot)
                            {
                                QueuePartForUpdate(child, PrimUpdateFlags.ForcedFullUpdate);
                            }
                        }
#else
                        foreach (ISceneChildEntity child in entity.ChildrenEntities().Where(child => !child.IsRoot))
                        {
                            QueuePartForUpdate(child, PrimUpdateFlags.ForcedFullUpdate);
                        }
#endif
                    }
                }
            });
        }
コード例 #7
0
        /// <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);
        }
コード例 #8
0
        private int llAttachToAvatarTemp(UUID host, UUID script, int attachmentPoint)
        {
            SceneObjectPart hostPart = m_scene.GetSceneObjectPart(host);

            if (hostPart == null)
            {
                return(0);
            }

            if (hostPart.ParentGroup.IsAttachment)
            {
                return(0);
            }

            IAttachmentsModule attachmentsModule = m_scene.RequestModuleInterface <IAttachmentsModule>();

            if (attachmentsModule == null)
            {
                return(0);
            }

            TaskInventoryItem item = hostPart.Inventory.GetInventoryItem(script);

            if (item == null)
            {
                return(0);
            }

            if ((item.PermsMask & 32) == 0) // PERMISSION_ATTACH
            {
                return(0);
            }

            ScenePresence target;

            if (!m_scene.TryGetScenePresence(item.PermsGranter, out target))
            {
                return(0);
            }

            if (target.UUID != hostPart.ParentGroup.OwnerID)
            {
                uint effectivePerms = hostPart.ParentGroup.GetEffectivePermissions();

                if ((effectivePerms & (uint)PermissionMask.Transfer) == 0)
                {
                    return(0);
                }

                hostPart.ParentGroup.SetOwnerId(target.UUID);
                hostPart.ParentGroup.SetRootPartOwner(hostPart.ParentGroup.RootPart, target.UUID, target.ControllingClient.ActiveGroupId);

                if (m_scene.Permissions.PropagatePermissions())
                {
                    foreach (SceneObjectPart child in hostPart.ParentGroup.Parts)
                    {
                        child.Inventory.ChangeInventoryOwner(target.UUID);
                        child.TriggerScriptChangedEvent(Changed.OWNER);
                        child.ApplyNextOwnerPermissions();
                    }
                }

                hostPart.ParentGroup.RootPart.ObjectSaleType = 0;
                hostPart.ParentGroup.RootPart.SalePrice      = 10;

                hostPart.ParentGroup.HasGroupChanged = true;
                hostPart.ParentGroup.RootPart.SendPropertiesToClient(target.ControllingClient);
                hostPart.ParentGroup.RootPart.ScheduleFullUpdate();
            }

            return(attachmentsModule.AttachObject(target, hostPart.ParentGroup, (uint)attachmentPoint, false, false, true) ? 1 : 0);
        }
コード例 #9
0
        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!
            }
            // set this as a NPC character
            SP.IsNpcAgent = true;

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

            appearance.Appearance = avatarApp;
            appearance.InitialHasWearablesBeenSent = true;
            Bot bot = new Bot();

            bot.Initialize(SP, creatorID);
            try {
                SP.MakeRootAgent(startPos, false, true);
            } catch {
                MainConsole.Instance.ErrorFormat("[BotManager]: Error creating bot {0} as root agent!", m_character.AgentId);
            }
            //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);
        }
コード例 #10
0
        public virtual void DeliverChatToAvatars(ChatSourceType sourceType, OSChatMessage c)
        {
            string  fromName = c.From;
            UUID    fromID   = UUID.Zero;
            string  message  = c.Message;
            IScene  scene    = c.Scene;
            Vector3 fromPos  = c.Position;

            if (c.Channel == DEBUG_CHANNEL)
            {
                c.Type = ChatTypeEnum.DebugChannel;
            }

            IScenePresence avatar = (scene != null && c.Sender != null)
                                        ? scene.GetScenePresence(c.Sender.AgentId)
                                        : null;

            switch (sourceType)
            {
            case ChatSourceType.Agent:
                if (scene != null)
                {
                    if (avatar != null && message == "")
                    {
                        fromPos  = avatar.AbsolutePosition;
                        fromName = avatar.Name;
                        fromID   = c.Sender.AgentId;
                        //Always send this so it fires on typing start and end
                        IAttachmentsModule attMod = scene.RequestModuleInterface <IAttachmentsModule>();
                        if (attMod != null)
                        {
                            attMod.SendScriptEventToAttachments(avatar.UUID, "changed", new object[] { Changed.STATE });
                        }
                    }
                    else
                    {
                        fromID = c.SenderUUID;
                    }
                }
                else
                {
                    fromID = c.SenderUUID;
                }
                break;

            case ChatSourceType.Object:
                fromID = c.SenderUUID;

                break;
            }

            if (message.Length >= 1000) // libomv limit
            {
                message = message.Substring(0, 1000);
            }

            foreach (IScenePresence presence in from presence in m_Scene.GetScenePresences()
                     where !presence.IsChildAgent
                     let fromRegionPos = fromPos
                                         let toRegionPos = presence.AbsolutePosition
                                                           let dis = (int)Util.GetDistanceTo(toRegionPos, fromRegionPos)
                                                                     where
                                                                     (c.Type != ChatTypeEnum.Whisper || dis <= m_whisperdistance) &&
                                                                     (c.Type != ChatTypeEnum.Say || dis <= m_saydistance) &&
                                                                     (c.Type != ChatTypeEnum.Shout || dis <= m_shoutdistance) &&
                                                                     (c.Type != ChatTypeEnum.Custom || dis <= c.Range)
                                                                     where
                                                                     sourceType != ChatSourceType.Agent || avatar == null ||
                                                                     avatar.CurrentParcel == null ||
                                                                     (avatar.CurrentParcelUUID == presence.CurrentParcelUUID ||
                                                                      (!avatar.CurrentParcel.LandData.Private &&
                                                                       !presence.CurrentParcel.LandData.Private))
                                                                     select presence)
            {
                //If one of them is in a private parcel, and the other isn't in the same parcel, don't send the chat message
                TrySendChatMessage(presence, fromPos, fromID, fromName, c.Type, message, sourceType,
                                   c.Range);
            }
        }
コード例 #11
0
        public virtual void DeliverChatToAvatars(ChatSourceType sourceType, OSChatMessage c)
        {
            string  fromName  = c.From;
            UUID    fromID    = UUID.Zero;
            string  message   = c.Message;
            IScene  scene     = c.Scene;
            Vector3 fromPos   = c.Position;
            Vector3 regionPos = scene != null ? new Vector3(scene.RegionInfo.RegionLocX,
                                                            scene.RegionInfo.RegionLocY, 0) : Vector3.Zero;

            if (c.Channel == DEBUG_CHANNEL)
            {
                c.Type = ChatTypeEnum.DebugChannel;
            }

            switch (sourceType)
            {
            case ChatSourceType.Agent:
                if (scene != null)
                {
                    if (!(scene is Scene))
                    {
                        m_log.WarnFormat("[CHAT]: scene {0} is not a Scene object, cannot obtain scene presence for {1}",
                                         scene.RegionInfo.RegionName, c.Sender.AgentId);
                        return;
                    }
                    IScenePresence avatar = (scene as Scene).GetScenePresence(c.Sender.AgentId);
                    if (avatar != null && message == "")
                    {
                        fromPos  = avatar.AbsolutePosition;
                        fromName = avatar.Name;
                        fromID   = c.Sender.AgentId;
                        //Always send this so it fires on typing start and end
                        IAttachmentsModule attMod = scene.RequestModuleInterface <IAttachmentsModule>();
                        if (attMod != null)
                        {
                            attMod.SendScriptEventToAttachments(avatar.UUID, "changed", new object[] { Changed.STATE });
                        }
                    }
                    else
                    {
                        fromID = c.SenderUUID;
                    }
                }
                else
                {
                    fromID = c.SenderUUID;
                }
                break;

            case ChatSourceType.Object:
                fromID = c.SenderUUID;

                break;
            }

            if (message.Length >= 1000) // libomv limit
            {
                message = message.Substring(0, 1000);
            }

            // m_log.DebugFormat("[CHAT]: DCTA: fromID {0} fromName {1}, cType {2}, sType {3}", fromID, fromName, c.Type, sourceType);

            foreach (Scene s in m_scenes)
            {
                List <IScenePresence> ScenePresences = s.GetScenePresences();
                foreach (IScenePresence presence in ScenePresences)
                {
                    // don't send stuff to child agents
                    if (!presence.IsChildAgent)
                    {
                        //Block this out early so we don't look through the mutes if the message shouldn't even be sent
                        Vector3 fromRegionPos = fromPos + regionPos;
                        Vector3 toRegionPos   = presence.AbsolutePosition +
                                                new Vector3(presence.Scene.RegionInfo.RegionLocX,
                                                            presence.Scene.RegionInfo.RegionLocY, 0);

                        int dis = (int)Util.GetDistanceTo(toRegionPos, fromRegionPos);

                        //Check for max range
                        if (c.Type == ChatTypeEnum.Whisper && dis > m_whisperdistance ||
                            c.Type == ChatTypeEnum.Say && dis > m_saydistance ||
                            c.Type == ChatTypeEnum.Shout && dis > m_shoutdistance ||
                            c.Type == ChatTypeEnum.Custom && dis > c.Range)
                        {
                            continue;
                        }
                        TrySendChatMessage(presence, fromPos, regionPos, fromID, fromName, c.Type, message, sourceType, c.Range);
                    }
                }
            }
        }
コード例 #12
0
        public virtual void DeliverChatToAvatars(ChatSourceType sourceType, OSChatMessage c)
        {
            string  fromName = c.From;
            UUID    fromID   = UUID.Zero;
            string  message  = c.Message;
            IScene  scene    = c.Scene;
            Vector3 fromPos  = c.Position;

            if (c.Channel == DEBUG_CHANNEL)
            {
                c.Type = ChatTypeEnum.DebugChannel;
            }

            IScenePresence avatar = (scene != null && c.Sender != null)
                                        ? scene.GetScenePresence(c.Sender.AgentId)
                                        : null;

            switch (sourceType)
            {
            case ChatSourceType.Agent:
                if (scene != null)
                {
                    if (avatar != null && message == "")
                    {
                        fromPos  = avatar.AbsolutePosition;
                        fromName = avatar.Name;
                        fromID   = c.Sender.AgentId;
                        //Always send this so it fires on typing start and end
                        IAttachmentsModule attMod = scene.RequestModuleInterface <IAttachmentsModule> ();
                        if (attMod != null)
                        {
                            attMod.SendScriptEventToAttachments(avatar.UUID, "changed", new object [] { Changed.STATE });
                        }
                    }
                    else
                    {
                        fromID = c.SenderUUID;
                    }
                }
                else
                {
                    fromID = c.SenderUUID;
                }
                break;

            case ChatSourceType.Object:
                fromID = c.SenderUUID;

                break;
            }

            if (message.Length >= 1000) // libomv limit
            {
                message = message.Substring(0, 1000);
            }

            // determine who should receive the message
            var presences     = m_Scene.GetScenePresences();
            var fromRegionPos = fromPos;

            foreach (IScenePresence presence in presences)
            {
                if (presence.IsChildAgent)
                {
                    continue;
                }

                // check presence distances
                var toRegionPos = presence.AbsolutePosition;
                var dis         = (int)Util.GetDistanceTo(toRegionPos, fromRegionPos);

                if (c.Type == ChatTypeEnum.Custom && dis > c.Range)                 // further than the defined custom range
                {
                    continue;
                }

                if (c.Type == ChatTypeEnum.Shout && dis > m_shoutdistance)          // too far for shouting
                {
                    continue;
                }

                if (c.Type == ChatTypeEnum.Say && dis > m_saydistance)              // too far for normal chat
                {
                    continue;
                }

                if (c.Type == ChatTypeEnum.Whisper && dis > m_whisperdistance)      // too far out for whisper
                {
                    continue;
                }

                if (sourceType == ChatSourceType.Agent)
                {
                    if (avatar != null)
                    {
                        if (avatar.CurrentParcel != null)
                        {
                            if (avatar.CurrentParcelUUID != presence.CurrentParcelUUID)     // not in the same parcel
                            {
                                continue;
                            }

                            // If both are not in the same private parcel, don't send the chat message
                            //                if (!(avatar.CurrentParcel.LandData.Private && presence.CurrentParcel.LandData.Private))
                            if (avatar.CurrentParcel.LandData.Private && !presence.CurrentParcel.LandData.Private)
                            {
                                continue;
                            }
                        }
                    }
                }

                // this one is good to go....
                TrySendChatMessage(presence, fromPos, fromID, fromName, c.Type, message, sourceType,
                                   c.Range);
            }

            /* previous for reference - remove when verified - greythane -
             * foreach (IScenePresence presence in from presence in m_Scene.GetScenePresences()
             *                                  where !presence.IsChildAgent
             *                                  let fromRegionPos = fromPos
             *                                  let toRegionPos = presence.AbsolutePosition
             *                                  let dis = (int) Util.GetDistanceTo(toRegionPos, fromRegionPos)
             *                                  where
             *                                      (c.Type != ChatTypeEnum.Whisper || dis <= m_whisperdistance) &&
             *                                      (c.Type != ChatTypeEnum.Say || dis <= m_saydistance) &&
             *                                      (c.Type != ChatTypeEnum.Shout || dis <= m_shoutdistance) &&
             *                                      (c.Type != ChatTypeEnum.Custom || dis <= c.Range)
             *                                  where
             *                                      sourceType != ChatSourceType.Agent || avatar == null ||
             *                                      avatar.CurrentParcel == null ||
             *                                      (avatar.CurrentParcelUUID == presence.CurrentParcelUUID ||
             *                                       (!avatar.CurrentParcel.LandData.Private &&
             *                                        !presence.CurrentParcel.LandData.Private))
             *                                  select presence)
             * {
             *  //If one of them is in a private parcel, and the other isn't in the same parcel, don't send the chat message
             *  TrySendChatMessage (presence, fromPos, fromID, fromName, c.Type, message, sourceType,
             *      c.Range);
             * }
             */
        }
コード例 #13
0
ファイル: Scene.cs プロジェクト: shangcheng/Aurora
        /// <summary>
        /// Sets up references to modules required by the scene
        /// </summary>
        public void SetModuleInterfaces()
        {
            m_xmlrpcModule = RequestModuleInterface<IXMLRPC>();
            m_worldCommModule = RequestModuleInterface<IWorldComm>();
            XferManager = RequestModuleInterface<IXfer>();
            m_AvatarFactory = RequestModuleInterface<IAvatarFactory>();
            AttachmentsModule = RequestModuleInterface<IAttachmentsModule>();
            m_serialiser = RequestModuleInterface<IRegionSerialiserModule>();
            m_dialogModule = RequestModuleInterface<IDialogModule>();
            m_capsModule = RequestModuleInterface<ICapabilitiesModule>();
            m_teleportModule = RequestModuleInterface<IEntityTransferModule>();

            // Shoving this in here for now, because we have the needed
            // interfaces at this point
            //
            // TODO: Find a better place for this
            //
            while (m_regInfo.EstateSettings.EstateOwner == UUID.Zero && MainConsole.Instance != null)
            {
                MainConsole.Instance.Output("The current estate " + m_regInfo.EstateSettings.EstateName + " has no owner set.");
                List<char> excluded = new List<char>(new char[1] { ' ' });
                string first = MainConsole.Instance.CmdPrompt("Estate owner first name", "Test", excluded);
                string last = MainConsole.Instance.CmdPrompt("Estate owner last name", "User", excluded);

                UserAccount account = UserAccountService.GetUserAccount(m_regInfo.ScopeID, first, last);

                if (account == null)
                {
                    // Create a new account
                    account = new UserAccount(m_regInfo.ScopeID, first, last, String.Empty);
                    if (account.ServiceURLs == null || (account.ServiceURLs != null && account.ServiceURLs.Count == 0))
                    {
                        account.ServiceURLs = new Dictionary<string, object>();
                        account.ServiceURLs["HomeURI"] = string.Empty;
                        account.ServiceURLs["GatekeeperURI"] = string.Empty;
                        account.ServiceURLs["InventoryServerURI"] = string.Empty;
                        account.ServiceURLs["AssetServerURI"] = string.Empty;
                    }

                    if (UserAccountService.StoreUserAccount(account))
                    {
                        string password = MainConsole.Instance.PasswdPrompt("Password");
                        string email = MainConsole.Instance.CmdPrompt("Email", "");

                        account.Email = email;
                        UserAccountService.StoreUserAccount(account);

                        bool success = false;
                        success = AuthenticationService.SetPassword(account.PrincipalID, password);
                        if (!success)
                            m_log.WarnFormat("[USER ACCOUNT SERVICE]: Unable to set password for account {0} {1}.",
                               first, last);

                        GridRegion home = null;
                        if (GridService != null)
                        {
                            List<GridRegion> defaultRegions = GridService.GetDefaultRegions(UUID.Zero);
                            if (defaultRegions != null && defaultRegions.Count >= 1)
                                home = defaultRegions[0];

                            if (GridUserService != null && home != null)
                                GridUserService.SetHome(account.PrincipalID.ToString(), home.RegionID, new Vector3(128, 128, 0), new Vector3(0, 1, 0));
                            else
                                m_log.WarnFormat("[USER ACCOUNT SERVICE]: Unable to set home for account {0} {1}.",
                                   first, last);

                        }
                        else
                            m_log.WarnFormat("[USER ACCOUNT SERVICE]: Unable to retrieve home region for account {0} {1}.",
                               first, last);

                        if (InventoryService != null)
                            success = InventoryService.CreateUserInventory(account.PrincipalID);
                        if (!success)
                            m_log.WarnFormat("[USER ACCOUNT SERVICE]: Unable to create inventory for account {0} {1}.",
                               first, last);


                        m_log.InfoFormat("[USER ACCOUNT SERVICE]: Account {0} {1} created successfully", first, last);

                        m_regInfo.EstateSettings.EstateOwner = account.PrincipalID;
                        m_regInfo.EstateSettings.Save();
                    }
                    else
                        m_log.ErrorFormat("[SCENE]: Unable to store account. If this simulator is connected to a grid, you must create the estate owner account first.");
                }
                else
                {
                    m_regInfo.EstateSettings.EstateOwner = account.PrincipalID;
                    m_regInfo.EstateSettings.Save();
                }
            }
        }
コード例 #14
0
        protected void OnInstantMessage(IClientAPI client, GridInstantMessage im)
        {
            m_log.InfoFormat("[WATER WARS]: GameManagerTopLevelInteraction.OnInstantMessage received");

            if (im.dialog == (byte)InstantMessageDialog.InventoryAccepted &&
                client.AgentId == m_playerId)
            {
                m_log.InfoFormat("[WATER WARS]: Now we get to do something cool!  IMSessionId [{0}]", im.imSessionID);

                UUID  itemId = new UUID(im.imSessionID);
                Scene scene  = client.Scene as Scene;

                // This really need to be a 'has inventory item' method in Scene.Inventory.cs
                InventoryItemBase item = new InventoryItemBase(itemId, m_playerId);
                item = scene.InventoryService.GetItem(item);

                if (item == null)
                {
                    m_log.Error("[WATER WARS]: Failed to find item " + itemId);
                    return;
                }
                else if (item.Name != HUD_ITEM_NAME)
                {
                    m_log.InfoFormat(
                        "[WATER WARS]: Ignoring hud item {0} since it's not a {1}", item.Name, HUD_ITEM_NAME);
                    return;
                }

                uint                    attachmentPoint = (uint)AttachmentPoint.HUDTop;
                ScenePresence           sp = scene.GetScenePresence(client.AgentId);
                List <SceneObjectGroup> existingAttachments = sp.GetAttachments(attachmentPoint);

                if (existingAttachments.Count == 0)
                {
                    IAttachmentsModule module = client.Scene.RequestModuleInterface <IAttachmentsModule>();
                    SceneObjectGroup   sog
                        = (SceneObjectGroup)module.RezSingleAttachmentFromInventory(
                              sp, new UUID(im.imSessionID), (uint)AttachmentPoint.HUDTop);

                    // A tempoary messy solution to an occasional race where the attached hud sometimes ends up positioned
                    // on the avatar itself and does not show up as attached within inventory.
                    Thread.Sleep(1000);

                    Vector3 newPos = new Vector3(0, 0, -0.1f);
                    m_log.InfoFormat("[WATER WARS]: Resetting HUD position to {0}", newPos);
                    module.UpdateAttachmentPosition(sog, newPos);

                    /*
                     * sog.UpdateGroupPosition(newPos);
                     * sog.HasGroupChanged = true;
                     * sog.ScheduleGroupForTerseUpdate();
                     */
                }
                else
                {
                    m_log.InfoFormat(
                        "[WATER WARS]: Not attaching given hud for {0} since something is already attached at {1}",
                        client.Name, attachmentPoint);
                }

                client.OnInstantMessage -= OnInstantMessage;
            }
        }
コード例 #15
0
        /// <summary>
        /// This Closes child agents on neighboring regions
        /// Calls an asynchronous method to do so..  so it doesn't lag the sim.
        /// </summary>
        protected IScenePresence CrossAgentToNewRegionAsync(IScenePresence agent, Vector3 pos,
                                                            GridRegion crossingRegion, bool isFlying)
        {
            m_log.DebugFormat("[EntityTransferModule]: Crossing agent {0} to region {1}", agent.Name, crossingRegion.RegionName);

            IScene m_scene = agent.Scene;

            if (crossingRegion != null)
            {
                //Make sure that all attachments are ready for the teleport
                IAttachmentsModule attModule = agent.Scene.RequestModuleInterface <IAttachmentsModule>();
                if (attModule != null)
                {
                    attModule.ValidateAttachments(agent.UUID);
                }

                int xOffset = crossingRegion.RegionLocX - m_scene.RegionInfo.RegionLocX;
                int yOffset = crossingRegion.RegionLocY - m_scene.RegionInfo.RegionLocY;

                if (xOffset < 0)
                {
                    pos.X += m_scene.RegionInfo.RegionSizeX;
                }
                else if (xOffset > 0)
                {
                    pos.X -= m_scene.RegionInfo.RegionSizeX;
                }

                if (yOffset < 0)
                {
                    pos.Y += m_scene.RegionInfo.RegionSizeY;
                }
                else if (yOffset > 0)
                {
                    pos.Y -= m_scene.RegionInfo.RegionSizeY;
                }

                //Make sure that they are within bounds (velocity can push it out of bounds)
                if (pos.X < 0)
                {
                    pos.X = 1;
                }
                if (pos.Y < 0)
                {
                    pos.Y = 1;
                }

                if (pos.X > crossingRegion.RegionSizeX)
                {
                    pos.X = crossingRegion.RegionSizeX - 1;
                }
                if (pos.Y > crossingRegion.RegionSizeY)
                {
                    pos.Y = crossingRegion.RegionSizeY - 1;
                }

                AgentData cAgent = new AgentData();
                agent.CopyTo(cAgent);
                cAgent.Position = pos;
                if (isFlying)
                {
                    cAgent.ControlFlags |= (uint)AgentManager.ControlFlags.AGENT_CONTROL_FLY;
                }

                AgentCircuitData agentCircuit = agent.ControllingClient.RequestClientInfo();
                agentCircuit.startpos = pos;
                agentCircuit.child    = false;
                IAvatarAppearanceModule appearance = agent.RequestModuleInterface <IAvatarAppearanceModule> ();
                if (appearance != null)
                {
                    agentCircuit.Appearance = appearance.Appearance;
                }

                IEventQueueService eq = agent.Scene.RequestModuleInterface <IEventQueueService>();
                if (eq != null)
                {
                    //This does UpdateAgent and closing of child agents
                    //  messages if they need to be called
                    ISyncMessagePosterService syncPoster = agent.Scene.RequestModuleInterface <ISyncMessagePosterService>();
                    if (syncPoster != null)
                    {
                        OSDMap map = syncPoster.Get(SyncMessageHelper.CrossAgent(crossingRegion, pos,
                                                                                 agent.Velocity, agentCircuit, cAgent, agent.Scene.RegionInfo.RegionHandle),
                                                    agent.Scene.RegionInfo.RegionHandle);
                        bool result = map["Success"].AsBoolean();
                        if (!result)
                        {
                            agent.ControllingClient.SendTeleportFailed(map["Reason"].AsString());
                            return(agent);
                        }
                    }
                }

                agent.MakeChildAgent();

                //Revolution- We already were in this region... we don't need updates about the avatars we already know about, right?
                // OLD: now we have a child agent in this region. Request and send all interesting data about (root) agents in the sim
                //agent.SendOtherAgentsAvatarDataToMe();
                //agent.SendOtherAgentsAppearanceToMe();

                //Kill the groups here, otherwise they will become ghost attachments
                //  and stay in the sim, they'll get readded below into the new sim
                KillAttachments(agent);
            }
            return(agent);
        }
コード例 #16
0
        public virtual void DoTeleport(IScenePresence sp, GridRegion finalDestination, Vector3 position, Vector3 lookAt, uint teleportFlags)
        {
            sp.ControllingClient.SendTeleportProgress(teleportFlags, "sending_dest");
            if (finalDestination == null)
            {
                sp.ControllingClient.SendTeleportFailed("Unable to locate destination");
                return;
            }

            m_log.DebugFormat(
                "[ENTITY TRANSFER MODULE]: Request Teleport to {0}:{1}/{2}",
                finalDestination.ServerURI, finalDestination.RegionName, position);

            sp.ControllingClient.SendTeleportProgress(teleportFlags, "arriving");

            // Fixing a bug where teleporting while sitting results in the avatar ending up removed from
            // both regions
            if (sp.ParentID != UUID.Zero)
            {
                sp.StandUp();
            }

            //Make sure that all attachments are ready for the teleport
            IAttachmentsModule attModule = sp.Scene.RequestModuleInterface <IAttachmentsModule>();

            if (attModule != null)
            {
                attModule.ValidateAttachments(sp.UUID);
            }

            AgentCircuitData agentCircuit = sp.ControllingClient.RequestClientInfo();

            agentCircuit.startpos = position;
            //The agent will be a root agent
            agentCircuit.child = false;
            //Make sure the appearnace is right
            IAvatarAppearanceModule appearance = sp.RequestModuleInterface <IAvatarAppearanceModule> ();

            agentCircuit.Appearance = appearance.Appearance;

            AgentData agent = new AgentData();

            sp.CopyTo(agent);
            //Fix the position
            agent.Position = position;

            IEventQueueService eq = sp.Scene.RequestModuleInterface <IEventQueueService>();

            if (eq != null)
            {
                ISyncMessagePosterService syncPoster = sp.Scene.RequestModuleInterface <ISyncMessagePosterService>();
                if (syncPoster != null)
                {
                    //This does CreateAgent and sends the EnableSimulator/EstablishAgentCommunication/TeleportFinish
                    //  messages if they need to be called and deals with the callback
                    OSDMap map = syncPoster.Get(SyncMessageHelper.TeleportAgent((int)sp.DrawDistance,
                                                                                agentCircuit, agent, teleportFlags, finalDestination, sp.Scene.RegionInfo.RegionHandle),
                                                sp.Scene.RegionInfo.RegionHandle);
                    bool result = map["Success"].AsBoolean();
                    if (!result)
                    {
                        // Fix the agent status
                        sp.IsChildAgent = false;
                        sp.ControllingClient.SendTeleportFailed(map["Reason"].AsString());
                        return;
                    }
                }
            }

            //Kill the groups here, otherwise they will become ghost attachments
            //  and stay in the sim, they'll get readded below into the new sim
            KillAttachments(sp);

            // Well, this is it. The agent is over there.
            KillEntity(sp.Scene, sp);

            //Make it a child agent for now... the grid will kill us later if we need to close
            sp.MakeChildAgent();
        }