Example #1
0
        /// <summary>
        ///     Dupliate the entity and add it to the Scene
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        public ISceneEntity DuplicateEntity(ISceneEntity entity)
        {
            //Make an exact copy of the entity
            ISceneEntity copiedEntity = entity.Copy(false);
            //Add the entity to the scene and back it up
            //Reset the entity IDs
            ResetEntityIDs(copiedEntity);

            //Force the prim to backup now that it has been added
            copiedEntity.ForcePersistence();
            //Tell the entity that they are being added to a scene
            copiedEntity.AttachToScene(m_parentScene);
            //Now save the entity that we have 
            AddEntity(copiedEntity, false);
            //Fix physics representation now
//            entity.RebuildPhysicalRepresentation();
            return copiedEntity;
        }
        /// <summary>
        ///     Move the given scene object into a new region
        /// </summary>
        /// <param name="destination"></param>
        /// <param name="grp">Scene Object Group that we're crossing</param>
        /// <param name="attemptedPos"></param>
        /// <returns>
        ///     true if the crossing itself was successful, false on failure
        /// </returns>
        protected bool CrossPrimGroupIntoNewRegion(GridRegion destination, ISceneEntity grp, Vector3 attemptedPos)
        {
            bool successYN = false;
            if (destination != null)
            {
                if (grp.SitTargetAvatar.Count != 0)
                {
                    foreach (UUID avID in grp.SitTargetAvatar)
                    {
                        IScenePresence SP = grp.Scene.GetScenePresence(avID);
                        SP.Velocity = grp.RootChild.PhysActor.Velocity;
                        InternalCross(SP, attemptedPos, false, destination);
                    }
                    foreach (ISceneChildEntity part in grp.ChildrenEntities())
                        part.SitTargetAvatar = new List<UUID>();

                    IBackupModule backup = grp.Scene.RequestModuleInterface<IBackupModule>();
                    if (backup != null)
                        return backup.DeleteSceneObjects(new[] {grp}, false, false);
                    return true; //They do all the work adding the prim in the other region
                }

                ISceneEntity copiedGroup = grp.Copy(false);
                copiedGroup.SetAbsolutePosition(true, attemptedPos);
                if (grp.Scene != null)
                    successYN = grp.Scene.RequestModuleInterface<ISimulationService>()
                                   .CreateObject(destination, copiedGroup);

                if (successYN)
                {
                    // We remove the object here
                    try
                    {
                        IBackupModule backup = grp.Scene.RequestModuleInterface<IBackupModule>();
                        if (backup != null)
                            return backup.DeleteSceneObjects(new[] {grp}, false, true);
                    }
                    catch (Exception e)
                    {
                        MainConsole.Instance.ErrorFormat(
                            "[ENTITY TRANSFER MODULE]: Exception deleting the old object left behind on a border crossing for {0}, {1}",
                            grp, e);
                    }
                }
                else
                {
                    if (!grp.IsDeleted)
                    {
                        if (grp.RootChild.PhysActor != null)
                        {
                            grp.RootChild.PhysActor.CrossingFailure();
                        }
                    }

                    MainConsole.Instance.ErrorFormat("[ENTITY TRANSFER MODULE]: Prim crossing failed for {0}", grp);
                }
            }
            else
            {
                MainConsole.Instance.Error(
                    "[ENTITY TRANSFER MODULE]: destination was unexpectedly null in Scene.CrossPrimGroupIntoNewRegion()");
            }

            return successYN;
        }
        /// <summary>
        ///     Move the given scene object into a new region
        /// </summary>
        /// <param name="destination"></param>
        /// <param name="grp">Scene Object Group that we're crossing</param>
        /// <param name="attemptedPos"></param>
        /// <returns>
        ///     true if the crossing itself was successful, false on failure
        /// </returns>
        protected bool CrossPrimGroupIntoNewRegion(GridRegion destination, ISceneEntity grp, Vector3 attemptedPos)
        {
            bool successYN = false;

            if (destination != null)
            {
                if (grp.SitTargetAvatar.Count != 0)
                {
                    foreach (UUID avID in grp.SitTargetAvatar)
                    {
                        IScenePresence SP = grp.Scene.GetScenePresence(avID);
                        SP.Velocity = grp.RootChild.PhysActor.Velocity;
                        InternalCross(SP, attemptedPos, false, destination);
                    }
                    foreach (ISceneChildEntity part in grp.ChildrenEntities())
                    {
                        part.SitTargetAvatar = new List <UUID> ();
                    }

                    IBackupModule backup = grp.Scene.RequestModuleInterface <IBackupModule> ();
                    if (backup != null)
                    {
                        return(backup.DeleteSceneObjects(new [] { grp }, false, false));
                    }
                    return(true); //They do all the work adding the prim in the other region
                }

                ISceneEntity copiedGroup = grp.Copy(false);
                copiedGroup.SetAbsolutePosition(true, attemptedPos);
                if (grp.Scene != null)
                {
                    successYN = grp.Scene.RequestModuleInterface <ISimulationService> ()
                                .CreateObject(destination, copiedGroup);
                }

                if (successYN)
                {
                    // We remove the object here
                    try {
                        IBackupModule backup = grp.Scene.RequestModuleInterface <IBackupModule> ();
                        if (backup != null)
                        {
                            return(backup.DeleteSceneObjects(new [] { grp }, false, true));
                        }
                    } catch (Exception e) {
                        MainConsole.Instance.ErrorFormat(
                            "[Entity transfer]: Exception deleting the old object left behind on a border crossing for {0}, {1}",
                            grp, e);
                    }
                }
                else
                {
                    if (!grp.IsDeleted)
                    {
                        if (grp.RootChild.PhysActor != null)
                        {
                            grp.RootChild.PhysActor.CrossingFailure();
                        }
                    }

                    MainConsole.Instance.ErrorFormat("[Entity transfer]r]: Prim crossing failed for {0}", grp);
                }
            }
            else
            {
                MainConsole.Instance.Error(
                    "[Entity transfer]: destination was unexpectedly null in Scene.CrossPrimGroupIntoNewRegion()");
            }

            return(successYN);
        }
Example #4
0
        /// <summary>
        /// Dupliate the entity and add it to the Scene
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        public ISceneEntity DuplicateEntity (ISceneEntity entity)
        {
            //Make an exact copy of the entity
            ISceneEntity copiedEntity = entity.Copy (false);
            //Add the entity to the scene and back it up
            AddPrimToScene(copiedEntity);
            //Fix physics representation now
//            entity.RebuildPhysicalRepresentation();
            return copiedEntity;
        }
Example #5
0
        /// <summary>
        /// Dupliate the entity and add it to the Scene
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        public ISceneEntity DuplicateEntity (ISceneEntity entity)
        {
            //Make an exact copy of the entity
            ISceneEntity copiedEntity = entity.Copy (false);
            //Add the entity to the scene and back it up
            //Reset the entity IDs
            ResetEntityIDs (copiedEntity);

            IComponentManager manager = m_parentScene.RequestModuleInterface<IComponentManager> ();
            if (manager != null)
            {
                foreach(ISceneChildEntity childEntity in copiedEntity.ChildrenEntities())
                {
                    manager.RemoveComponents (childEntity.UUID);
                }
            }

            //Force the prim to backup now that it has been added
            copiedEntity.ForcePersistence ();
            //Tell the entity that they are being added to a scene
            copiedEntity.AttachToScene (m_parentScene);
            //Now save the entity that we have 
            AddEntity (copiedEntity, false);
            //Fix physics representation now
//            entity.RebuildPhysicalRepresentation();
            return copiedEntity;
        }