Exemplo n.º 1
0
        public void llBreakAllLinks()
        {
            if (!ScriptProtection.CheckThreatLevel(ThreatLevel.None, "LSL", m_host, "LSL", m_itemID))
            {
                return;
            }

            ISceneEntity parentPrim = m_host.ParentEntity;

            if (parentPrim.RootChild.AttachmentPoint != 0)
            {
                return; // Fail silently if attached
            }
            List <ISceneChildEntity> parts = new List <ISceneChildEntity>(parentPrim.ChildrenEntities());

            parts.Remove(parentPrim.RootChild);

            foreach (ISceneChildEntity part in parts)
            {
                parentPrim.DelinkFromGroup(part, true);
                parentPrim.TriggerScriptChangedEvent(Changed.LINK);
                part.ParentEntity.ScheduleGroupUpdate(PrimUpdateFlags.ForcedFullUpdate);
            }
            parentPrim.ScheduleGroupUpdate(PrimUpdateFlags.ForcedFullUpdate);
        }
Exemplo n.º 2
0
        public DateTime llCreateLink(string target, int parent)
        {
            if (!ScriptProtection.CheckThreatLevel(ThreatLevel.None, "LSL", m_host, "LSL", m_itemID))
            {
                return(DateTime.Now);
            }

            UUID invItemID = InventorySelf();
            UUID targetID;

            if (!UUID.TryParse(target, out targetID))
            {
                return(DateTime.Now);
            }

            TaskInventoryItem item;

            lock (m_host.TaskInventory) {
                item = m_host.TaskInventory[invItemID];
            }

            if ((item.PermsMask & ScriptBaseClass.PERMISSION_CHANGE_LINKS) == 0 &&
                !m_automaticLinkPermission)
            {
                Error("llCreateLink", "PERMISSION_CHANGE_LINKS permission not set");
                return(DateTime.Now);
            }

            IClientAPI     client = null;
            IScenePresence sp     = World.GetScenePresence(item.PermsGranter);

            if (sp != null)
            {
                client = sp.ControllingClient;
            }

            ISceneChildEntity targetPart = World.GetSceneObjectPart(targetID);

            if (targetPart.ParentEntity.RootChild.AttachmentPoint != 0)
            {
                return(DateTime.Now);
            }
            // Fail silently if attached
            ISceneEntity parentPrim = null;
            ISceneEntity childPrim  = null;

            if (parent != 0)
            {
                parentPrim = m_host.ParentEntity;
                childPrim  = targetPart.ParentEntity;
            }
            else
            {
                parentPrim = targetPart.ParentEntity;
                childPrim  = m_host.ParentEntity;
            }
            //                byte uf = childPrim.RootPart.UpdateFlag;
            parentPrim.LinkToGroup(childPrim);
            //                if (uf != (Byte)0)
            //                    parent.RootPart.UpdateFlag = uf;

            parentPrim.TriggerScriptChangedEvent(Changed.LINK);
            parentPrim.RootChild.CreateSelected = true;
            parentPrim.ScheduleGroupUpdate(PrimUpdateFlags.ForcedFullUpdate);

            if (client != null)
            {
                parentPrim.GetProperties(client);
            }

            return(PScriptSleep(m_sleepMsOnCreateLink));
        }
Exemplo n.º 3
0
        public void llBreakLink(int linknum)
        {
            if (!ScriptProtection.CheckThreatLevel(ThreatLevel.None, "LSL", m_host, "LSL", m_itemID))
            {
                return;
            }

            UUID invItemID = InventorySelf();

            lock (m_host.TaskInventory) {
                if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_CHANGE_LINKS) == 0 &&
                    !m_automaticLinkPermission)
                {
                    Error("llBreakLink", "PERMISSION_CHANGE_LINKS permission not set");
                    return;
                }
            }

            if (linknum < ScriptBaseClass.LINK_THIS)
            {
                return;
            }

            ISceneEntity parentPrim = m_host.ParentEntity;

            if (parentPrim.RootChild.AttachmentPoint != 0)
            {
                return; // Fail silently if attached
            }
            ISceneChildEntity childPrim = null;

            if (linknum == ScriptBaseClass.LINK_ROOT)
            {
            }
            else if (linknum == ScriptBaseClass.LINK_SET ||
                     ScriptBaseClass.LINK_ALL_OTHERS ||
                     ScriptBaseClass.LINK_ALL_CHILDREN ||
                     ScriptBaseClass.LINK_THIS)
            {
                foreach (ISceneChildEntity part in parentPrim.ChildrenEntities())
                {
                    if (part.UUID != m_host.UUID)
                    {
                        childPrim = part;
                        break;
                    }
                }
            }
            else
            {
                IEntity target = m_host.ParentEntity.GetLinkNumPart(linknum);
                if (target is ISceneChildEntity)
                {
                    childPrim = target as ISceneChildEntity;
                }
                else
                {
                    return;
                }
                if (childPrim.UUID == m_host.UUID)
                {
                    childPrim = null;
                }
            }

            if (linknum == ScriptBaseClass.LINK_ROOT)
            {
                // Restructuring Multiple Prims.
                List <ISceneChildEntity> parts = new List <ISceneChildEntity>(parentPrim.ChildrenEntities());
                parts.Remove(parentPrim.RootChild);
                foreach (ISceneChildEntity part in parts)
                {
                    parentPrim.DelinkFromGroup(part, true);
                }
                parentPrim.ScheduleGroupUpdate(PrimUpdateFlags.ForcedFullUpdate);
                parentPrim.TriggerScriptChangedEvent(Changed.LINK);

                if (parts.Count > 0)
                {
                    ISceneChildEntity newRoot = parts[0];
                    parts.Remove(newRoot);
                    foreach (ISceneChildEntity part in parts)
                    {
                        newRoot.ParentEntity.LinkToGroup(part.ParentEntity);
                    }
                    newRoot.ParentEntity.ScheduleGroupUpdate(PrimUpdateFlags.ForcedFullUpdate);
                }
            }
            else
            {
                if (childPrim == null)
                {
                    return;
                }

                parentPrim.DelinkFromGroup(childPrim, true);
                childPrim.ParentEntity.ScheduleGroupUpdate(PrimUpdateFlags.ForcedFullUpdate);
                parentPrim.ScheduleGroupUpdate(PrimUpdateFlags.ForcedFullUpdate);
                parentPrim.TriggerScriptChangedEvent(Changed.LINK);
            }
        }