コード例 #1
0
        public void HandleObjectOwner(Message m)
        {
            var req = (ObjectOwner)m;

            if (req.CircuitSessionID != req.SessionID ||
                req.CircuitAgentID != req.AgentID)
            {
                return;
            }

            IAgent agent;

            if (!RootAgents.TryGetValue(req.AgentID, out agent) || !agent.IsActiveGod)
            {
                return;
            }

            UGUI owner;
            UGI  group = UGI.Unknown;

            if (!AvatarNameService.TryGetValue(req.OwnerID, out owner))
            {
                return;
            }

            if (UUID.Zero != group.ID && !GroupsNameService.TryGetValue(req.GroupID, out group))
            {
                return;
            }

            using (var propHandler = new ObjectPropertiesSendHandler(agent, ID))
            {
                foreach (uint d in req.ObjectList)
                {
#if DEBUG
                    m_Log.DebugFormat("ObjectOwner localid={0}", d);
#endif

                    ObjectPart prim;
                    if (!Primitives.TryGetValue(d, out prim))
                    {
                        continue;
                    }

                    prim.Owner = owner;
                    prim.Group = group;

                    propHandler.Send(prim);
                }
            }
        }
コード例 #2
0
        public void HandleObjectDuplicate(Message m)
        {
            var req = (Viewer.Messages.Object.ObjectDuplicate)m;

            if (req.AgentID != m.CircuitAgentID ||
                req.SessionID != m.CircuitSessionID)
            {
                return;
            }

            IAgent agent;
            var    objectgroups = new List <ObjectGroup>();

            if (!Agents.TryGetValue(req.AgentID, out agent))
            {
                return;
            }

            bool isGod = agent.IsInScene(this) && agent.IsActiveGod;

            foreach (UInt32 localid in req.ObjectLocalIDs)
            {
                try
                {
                    ObjectGroup grp = Primitives[localid].ObjectGroup;
                    if (isGod || CanTakeCopy(agent, grp, grp.Position))
                    {
                        objectgroups.Add(grp);
                    }
                }
                catch
                {
                    agent.SendAlertMessage("ALERT: CantFindObject", ID);
                }
            }

            foreach (ObjectGroup grp in objectgroups)
            {
                var newgrp = new ObjectGroup(grp);
                foreach (ObjectPart part in grp.ValuesByKey1)
                {
                    var newpart = new ObjectPart(UUID.Random, part)
                    {
                        RezDate     = Date.Now,
                        ObjectGroup = newgrp
                    };
                    newgrp.Add(part.LinkNumber, newpart.ID, newpart);
                    newpart.UpdateData(ObjectPartLocalizedInfo.UpdateDataFlags.All);

                    foreach (KeyValuePair <UUID, ObjectPartInventoryItem> kvp in part.Inventory.Key1ValuePairs)
                    {
                        ScriptInstance instance = kvp.Value.ScriptInstance;
                        var            newItem  = new ObjectPartInventoryItem(UUID.Random, kvp.Value)
                        {
                            ExperienceID = kvp.Value.ExperienceID
                        };
                        if (instance != null)
                        {
                            try
                            {
                                newItem.ScriptState = instance.ScriptState;
                            }
                            catch
                            {
                                /* if taking script state fails, we do not bail out */
                            }
                        }
                        newpart.Inventory.Add(newItem);
                    }
                    newgrp.GlobalPosition   += req.Offset;
                    newpart.IsChangedEnabled = true;
                }

                UGI ugi = UGI.Unknown;
                GroupsNameService?.TryGetValue(req.GroupID, out ugi);
                newgrp.Group = ugi;
                newgrp.Owner = agent.Owner;

                RezObject(newgrp, grp.Owner);
#if DEBUG
                m_Log.DebugFormat("Duplicated object {0} ({1}, {2}) as {3} ({4}, {5})", grp.Name, grp.LocalID, grp.ID, newgrp.Name, newgrp.LocalID, newgrp.ID);
#endif
            }
        }