Exemplo n.º 1
0
        public virtual SceneObjectGroup RezPrim(SceneObjectPart sourcePart, SceneObjectPart newPart, int param, out string reason)
        {
            // Rez object
            Vector3 pos = newPart.AbsolutePosition;
            SceneObjectGroup group = new SceneObjectGroup(newPart);
            bool isTemp = (group.RootPart.GetEffectiveObjectFlags() & PrimFlags.TemporaryOnRez) != 0;

            ILandObject parcel = LandChannel.GetLandObject(pos.X, pos.Y);
            if (parcel == null)
            {
                reason = "land";
                return null;
            }

            // Pass 0 for landImpact here so that it can be tested separately.
            if (!Permissions.CanRezObject(0, newPart.OwnerID, sourcePart.UUID, pos, isTemp))
            {
                reason = "permission";
                return null;
            }

            if (!CheckLandImpact(parcel, group.LandImpact, out reason))
            {
                return null;
            }

            // Check for grey goo fence
            if (!CheckGreyGoo(sourcePart, group))
            {
                reason = "fence";
                return null;
            }

            // Allowing the rez... update the last rez time and the new group fields
            sourcePart.StampLastRez();
            group.CurrentParcel = parcel;   // initialize _currentParcel (and auto-return)
            group.SetGeneration(group.RootPart.Generation); // now update the rest of the parts
            group.ResetIDs();

            //set the group's group before setting the object's position.
            //this will make sure that the group id is correct during the script
            //engine's group check
            group.SetGroup(sourcePart.ParentGroup.RootPart.GroupID, null);

            AddNewSceneObject(group, !isTemp);

            SceneObjectPart rootPart = group.GetChildPart(group.UUID);

            rootPart.TrimPermissions();

            if (group.RootPart.IsPrim)
            {
                group.ClearPartAttachmentData();
            }

            group.CreateScriptInstances(param, ScriptStartFlags.PostOnRez, DefaultScriptEngine, (int)ScriptStateSource.PrimData, null);
            rootPart.ScheduleFullUpdate(PrimUpdateFlags.ForcedFullUpdate);

            reason = "success";
            return rootPart.ParentGroup;
        }
Exemplo n.º 2
0
        /// <summary>
        /// Rez an object into the scene from a prim's inventory.
        /// </summary>
        /// <param name="sourcePart"></param>
        /// <param name="item"></param>
        /// <param name="pos"></param>
        /// <param name="rot"></param>
        /// <param name="vel"></param>
        /// <param name="param"></param>
        /// <returns>The SceneObjectGroup rezzed or null if rez was unsuccessful</returns>
        /// 
        public virtual IEnumerable<SceneObjectGroup> RezObject(
            SceneObjectPart sourcePart, TaskInventoryItem item, bool rezAtRoot,
            Vector3 pos, Quaternion rot, Vector3 vel, int? param, out string reason)
        {
            // Rez object
            if (item != null)
            {
                UUID ownerID = item.OwnerID;

                AssetBase rezAsset = CommsManager.AssetCache.GetAsset(item.AssetID, AssetRequestInfo.InternalRequest());

                if (rezAsset != null)
                {
                    CoalescedObject cobj = null;
                    SceneObjectGroup grp = null;
                    List<SceneObjectGroup> allGroups = new List<SceneObjectGroup>();

                    int totalLandImpact = 0;
                    bool isTemp = true;

                    if (item.ContainsMultipleItems)
                    {
                        cobj = this.DoDeserializeCoalesced(item.ItemID, rezAsset.Data);
                        foreach (var subGrp in cobj.Groups)
                        {
                            totalLandImpact += subGrp.LandImpact;
                            //for a coalesced, we set istemp to false if any parts are not temp
                            if ((subGrp.RootPart.GetEffectiveObjectFlags() & PrimFlags.TemporaryOnRez) == 0)
                            {
                                isTemp = false;
                            }

                            allGroups.Add(subGrp);
                        }
                    }
                    else
                    {
                        grp = this.DoDeserializeGroup(item.ItemID, rezAsset.Data);
                        totalLandImpact = grp.LandImpact;
                        isTemp = (grp.RootPart.GetEffectiveObjectFlags() & PrimFlags.TemporaryOnRez) != 0;
                        allGroups.Add(grp);
                    }

                    ILandObject parcel = LandChannel.GetLandObject(pos.X, pos.Y);
                    if (parcel == null)
                    {
                        reason = "land";
                        return null;
                    }

                    // Pass 0 for landImpact here so that it can be tested separately.
                    if (!Permissions.CanRezObject(0, ownerID, sourcePart.UUID, pos, isTemp))
                    {
                        reason = "permission";
                        return null;
                    }

                    if (!CheckLandImpact(parcel, totalLandImpact, out reason))
                    {
                        return null;
                    }

                    foreach (var subGrp in allGroups)
                    {
                        // Check for grey goo fence
                        if (!CheckGreyGoo(sourcePart, subGrp))
                        {
                            reason = "fence";
                            return null;
                        }

                        Vector3 actualPos = pos;
                        if (!rezAtRoot)
                            actualPos += (subGrp.RootPart.AbsolutePosition - subGrp.BoundingBox().Center);

                        // update the last rez time and the new group fields
                        sourcePart.StampLastRez();
                        subGrp.CurrentParcel = parcel;  // initialize _currentParcel (and auto-return)
                        subGrp.SetGeneration(subGrp.RootPart.Generation); // now update the rest of the parts

                        //change the velocity for rez
                        subGrp.RootPart.ReplaceSerializedVelocity(vel);
                    }

                    bool rezSucceeded;
                    if (!item.ContainsMultipleItems)
                    {
                        // Since renaming the item in the inventory does not affect the name stored
                        // in the serialization, transfer the correct name from the inventory to the
                        // object itself before we rez.
                        grp.Name = item.Name;
                        grp.RootPart.Description = item.Description;

                        //reset the rotation
                        grp.RootPart.RotationOffset = rot;

                        //rez the single group
                        Vector3 actualPos = pos;
                        if (!rezAtRoot)
                            actualPos += (grp.RootPart.AbsolutePosition - grp.BoundingBox().Center);
                        rezSucceeded = this.RezSingleObjectToWorld(null, item.ItemID, grp, actualPos, actualPos, UUID.Zero, (byte)1, (byte)1, false, false, actualPos,
                            grp.Name, grp.RootPart.Description, item, ItemPermissionBlock.FromOther(item), param, 
                            sourcePart.ParentGroup.RootPart.GroupID, sourcePart.UUID) != null;
                    }
                    else
                    {
                        //rez the coalesced
                        rezSucceeded = this.RezCoalescedObject(null, item.ItemID, cobj, pos, pos, UUID.Zero, (byte)1, (byte)1, 
                            false, rezAtRoot, pos, item, param, sourcePart.ParentGroup.RootPart.GroupID, sourcePart.UUID);
                    }

                    if (!rezSucceeded)
                    {
                        reason = "rez";
                        return null;
                    }
                    else
                    {
                        if (!Permissions.BypassPermissions())
                        {
                            //if the item is no copy, it should be removed
                            if ((item.CurrentPermissions & (uint)PermissionMask.Copy) != (uint)PermissionMask.Copy)
                            {
                                sourcePart.Inventory.RemoveInventoryItem(item.ItemID);
                            }
                        }

                        reason = "success";
                        return allGroups;
                    }
                }
            }

            reason = "item";
            return null;
        }