当前位置: 首页>>代码示例>>C#>>正文


C# Framework.MapBlockData类代码示例

本文整理汇总了C#中OpenSim.Framework.MapBlockData的典型用法代码示例。如果您正苦于以下问题:C# MapBlockData类的具体用法?C# MapBlockData怎么用?C# MapBlockData使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


MapBlockData类属于OpenSim.Framework命名空间,在下文中一共展示了MapBlockData类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetAndSendBlocks

        protected override void GetAndSendBlocks(IClientAPI remoteClient, int minX, int minY, int maxX, int maxY, uint flag)
        {
            List<MapBlockData> mapBlocks = new List<MapBlockData>();
            List<GridRegion> regions = m_scene.GridService.GetRegionRange(m_scene.RegionInfo.ScopeID,
                minX * (int)Constants.RegionSize, maxX * (int)Constants.RegionSize, 
                minY * (int)Constants.RegionSize, maxY * (int)Constants.RegionSize);

            foreach (GridRegion r in regions)
            {
                MapBlockData block = new MapBlockData();
                MapBlockFromGridRegion(block, r);
                mapBlocks.Add(block);
            }

            // Different from super
            FillInMap(mapBlocks, minX, minY, maxX, maxY);
            //

            remoteClient.SendMapBlock(mapBlocks, 0);
        }
开发者ID:phantasmagoric,项目名称:InfiniteGrid-Opensim,代码行数:20,代码来源:HGWorldMapModule.cs

示例2: FillInMap

 private void FillInMap(List<MapBlockData> mapBlocks, int minX, int minY, int maxX, int maxY)
 {
     for (int x = minX; x <= maxX; x++)
     {
         for (int y = minY; y <= maxY; y++)
         {
             MapBlockData mblock = mapBlocks.Find(delegate(MapBlockData mb) { return ((mb.X == x) && (mb.Y == y)); });
             if (mblock == null)
             {
                 mblock = new MapBlockData();
                 mblock.X = (ushort)x;
                 mblock.Y = (ushort)y;
                 mblock.Name = "";
                 mblock.Access = 254; // not here???
                 mblock.MapImageId = UUID.Zero;
                 mapBlocks.Add(mblock);
             }
         }
     }
 }
开发者ID:ChrisD,项目名称:opensim,代码行数:20,代码来源:HGWorldMapModule.cs

示例3: OnMapNameRequest

        private void OnMapNameRequest (IClientAPI remoteClient, string mapName, uint flags)
        {
            if (mapName.Length < 1)
            {
                remoteClient.SendAlertMessage("Use a search string with at least 1 character");
                return;
            }

            bool TryCoordsSearch = false;
            int XCoord = 0;
            int YCoord = 0;

            string[] splitSearch = mapName.Split(',');
            if (splitSearch.Length != 1)
            {
                if (splitSearch[1].StartsWith (" "))
                    splitSearch[1] = splitSearch[1].Remove (0, 1);
                if (int.TryParse(splitSearch[0], out XCoord) && int.TryParse(splitSearch[1], out YCoord))
                    TryCoordsSearch = true;
            }

            List<MapBlockData> blocks = new List<MapBlockData>();

            List<GridRegion> regionInfos = m_scene.GridService.GetRegionsByName(UUID.Zero, mapName, 20);
            if (TryCoordsSearch)
            {
                GridRegion region = m_scene.GridService.GetRegionByPosition(m_scene.RegionInfo.ScopeID, (int)(XCoord * Constants.RegionSize), (int)(YCoord * Constants.RegionSize));
                if (region != null)
                {
                    region.RegionName = mapName + " - " + region.RegionName;
                    regionInfos.Add (region);
                }
            }
            List<GridRegion> allRegions = new List<GridRegion> ();
            foreach (GridRegion region in regionInfos)
            {
                //Add the found in search region first
                if (!allRegions.Contains (region))
                {
                    allRegions.Add (region);
                    blocks.Add (SearchMapBlockFromGridRegion (region));
                }
                //Then send surrounding regions
                List<GridRegion> regions = m_scene.GridService.GetRegionRange (m_scene.RegionInfo.ScopeID,
                    (region.RegionLocX - (4 * (int)Constants.RegionSize)),
                    (region.RegionLocX + (4 * (int)Constants.RegionSize)),
                    (region.RegionLocY - (4 * (int)Constants.RegionSize)),
                    (region.RegionLocY + (4 * (int)Constants.RegionSize)));
                if (regions != null)
                {
                    foreach (GridRegion r in regions)
                    {
                        if (!allRegions.Contains (region))
                        {
                            allRegions.Add (region);
                            blocks.Add (SearchMapBlockFromGridRegion (r));

                        }
                    }
                }
            }

            // final block, closing the search result
            MapBlockData data = new MapBlockData();
            data.Agents = 0;
            data.Access = 255;
            data.MapImageID = UUID.Zero;
            data.Name = mapName;
            data.RegionFlags = 0;
            data.WaterHeight = 0; // not used
            data.X = 0;
            data.Y = 0;
            blocks.Add(data);

            remoteClient.SendMapBlock (blocks, flags);
        }
开发者ID:rknop,项目名称:Aurora-Sim,代码行数:76,代码来源:WorldMap.cs

示例4: HandleExportWorldMapConsoleCommand

        /// <summary>
        /// Export the world map
        /// </summary>
        /// <param name="fileName"></param>
        public void HandleExportWorldMapConsoleCommand(string module, string[] cmdparams)
        {
            if (m_scene.ConsoleScene() == null)
            {
                // FIXME: If console region is root then this will be printed by every module.  Currently, there is no
                // way to prevent this, short of making the entire module shared (which is complete overkill).
                // One possibility is to return a bool to signal whether the module has completely handled the command
                m_log.InfoFormat("[WORLD MAP]: Please change to a specific region in order to export its world map");
                return;
            }

            if (m_scene.ConsoleScene() != m_scene)
                return;

            string exportPath;

            if (cmdparams.Length > 1)
                exportPath = cmdparams[1];
            else
                exportPath = DEFAULT_WORLD_MAP_EXPORT_PATH;

            m_log.InfoFormat(
                "[WORLD MAP]: Exporting world map for {0} to {1}", m_scene.RegionInfo.RegionName, exportPath);

            List<MapBlockData> mapBlocks = new List<MapBlockData>();
            List<GridRegion> regions = m_scene.GridService.GetRegionRange(m_scene.RegionInfo.ScopeID,
                    (int)(m_scene.RegionInfo.RegionLocX - 9) * (int)Constants.RegionSize,
                    (int)(m_scene.RegionInfo.RegionLocX + 9) * (int)Constants.RegionSize,
                    (int)(m_scene.RegionInfo.RegionLocY - 9) * (int)Constants.RegionSize,
                    (int)(m_scene.RegionInfo.RegionLocY + 9) * (int)Constants.RegionSize);
            List<AssetBase> textures = new List<AssetBase>();
            List<Image> bitImages = new List<Image>();

            foreach (GridRegion r in regions)
            {
                MapBlockData mapBlock = new MapBlockData();
                MapBlockFromGridRegion(mapBlock, r);
                AssetBase texAsset = m_scene.AssetService.Get(mapBlock.MapImageId.ToString());

                if (texAsset != null)
                {
                    textures.Add(texAsset);
                }
                //else
                //{
                //    // WHAT?!? This doesn't seem right. Commenting (diva)
                //    texAsset = m_scene.AssetService.Get(mapBlock.MapImageId.ToString());
                //    if (texAsset != null)
                //    {
                //        textures.Add(texAsset);
                //    }
                //}
            }

            foreach (AssetBase asset in textures)
            {
                ManagedImage managedImage;
                Image image;

                if (OpenJPEG.DecodeToImage(asset.Data, out managedImage, out image))
                    bitImages.Add(image);
            }

            Bitmap mapTexture = new Bitmap(2560, 2560);
            Graphics g = Graphics.FromImage(mapTexture);
            SolidBrush sea = new SolidBrush(Color.DarkBlue);
            g.FillRectangle(sea, 0, 0, 2560, 2560);

            for (int i = 0; i < mapBlocks.Count; i++)
            {
                ushort x = (ushort)((mapBlocks[i].X - m_scene.RegionInfo.RegionLocX) + 10);
                ushort y = (ushort)((mapBlocks[i].Y - m_scene.RegionInfo.RegionLocY) + 10);
                g.DrawImage(bitImages[i], (x * 128), 2560 - (y * 128), 128, 128); // y origin is top
            }

            mapTexture.Save(exportPath, ImageFormat.Jpeg);

            m_log.InfoFormat(
                "[WORLD MAP]: Successfully exported world map for {0} to {1}",
                m_scene.RegionInfo.RegionName, exportPath);
        }
开发者ID:gumho,项目名称:diva-distribution,代码行数:85,代码来源:WorldMapModule.cs

示例5: GetAndSendBlocks

 protected virtual void GetAndSendBlocks(IClientAPI remoteClient, int minX, int minY, int maxX, int maxY, uint flag)
 {
     List<MapBlockData> mapBlocks = new List<MapBlockData>();
     List<GridRegion> regions = m_scene.GridService.GetRegionRange(m_scene.RegionInfo.ScopeID,
         (minX - 4) * (int)Constants.RegionSize, 
         (maxX + 4) * (int)Constants.RegionSize,
         (minY - 4) * (int)Constants.RegionSize,
         (maxY + 4) * (int)Constants.RegionSize);
     foreach (GridRegion r in regions)
     {
         MapBlockData block = new MapBlockData();
         MapBlockFromGridRegion(block, r);
         mapBlocks.Add(block);
     }
     remoteClient.SendMapBlock(mapBlocks, flag);
 }
开发者ID:gumho,项目名称:diva-distribution,代码行数:16,代码来源:WorldMapModule.cs

示例6: MapLayerRequest

        /// <summary>
        /// Callback for a map layer request
        /// </summary>
        /// <param name="request"></param>
        /// <param name="path"></param>
        /// <param name="param"></param>
        /// <param name="agentID"></param>
        /// <param name="caps"></param>
        /// <returns></returns>
        public string MapLayerRequest(string request, string path, string param,
                                      UUID agentID, Caps caps)
        {
            //try
            //{
                //m_log.DebugFormat("[MAPLAYER]: request: {0}, path: {1}, param: {2}, agent:{3}",
                                  //request, path, param,agentID.ToString());

            // this is here because CAPS map requests work even beyond the 10,000 limit.
            ScenePresence avatarPresence = null;

            m_scene.TryGetScenePresence(agentID, out avatarPresence);

            if (avatarPresence != null)
            {
                bool lookup = false;

                lock (cachedMapBlocks)
                {
                    if (cachedMapBlocks.Count > 0 && ((cachedTime + 1800) > Util.UnixTimeSinceEpoch()))
                    {
                        List<MapBlockData> mapBlocks;

                        mapBlocks = cachedMapBlocks;
                        avatarPresence.ControllingClient.SendMapBlock(mapBlocks, 0);
                    }
                    else
                    {
                        lookup = true;
                    }
                }
                if (lookup)
                {
                    List<MapBlockData> mapBlocks = new List<MapBlockData>(); ;

                    List<GridRegion> regions = m_scene.GridService.GetRegionRange(m_scene.RegionInfo.ScopeID,
                        (int)(m_scene.RegionInfo.RegionLocX - 8) * (int)Constants.RegionSize,
                        (int)(m_scene.RegionInfo.RegionLocX + 8) * (int)Constants.RegionSize,
                        (int)(m_scene.RegionInfo.RegionLocY - 8) * (int)Constants.RegionSize,
                        (int)(m_scene.RegionInfo.RegionLocY + 8) * (int)Constants.RegionSize);
                    foreach (GridRegion r in regions)
                    {
                        MapBlockData block = new MapBlockData();
                        MapBlockFromGridRegion(block, r);
                        mapBlocks.Add(block);
                    }
                    avatarPresence.ControllingClient.SendMapBlock(mapBlocks, 0);

                    lock (cachedMapBlocks)
                        cachedMapBlocks = mapBlocks;

                    cachedTime = Util.UnixTimeSinceEpoch();
                }
            }
            LLSDMapLayerResponse mapResponse = new LLSDMapLayerResponse();
            mapResponse.LayerData.Array.Add(GetOSDMapLayerResponse());
            return mapResponse.ToString();
        }
开发者ID:gumho,项目名称:diva-distribution,代码行数:67,代码来源:WorldMapModule.cs

示例7: RequestNonVisibleMapTile

        private void RequestNonVisibleMapTile(IClientAPI remoteClient, int minX, int minY, int maxX, int maxY, uint flag)
        {
            List<MapBlockData> response = new List<MapBlockData>();

            // this should return one mapblock at most. But make sure: Look whether the one we requested is in there
            List<MapBlockData> mapBlocks = m_scene.SceneGridService.RequestNeighbourMapBlocks(minX, minY, maxX, maxY);
            if (mapBlocks != null)
            {
                foreach (MapBlockData block in mapBlocks)
                {
                    if (block.X == minX && block.Y == minY)
                    {
                        // found it => add it to response
                        response.Add(block);
                        break;
                    }
                }
            }

            if (response.Count == 0)
            {
                // response still empty => couldn't find the map-tile the user clicked on => tell the client
                MapBlockData block = new MapBlockData();
                block.X = (ushort)minX;
                block.Y = (ushort)minY;
                block.Access = 254; // == not there
                response.Add(block);
            }
            //(flag & 0x10000) != 0 is sent by v2 viewers, and it expects flag 2 back
            remoteClient.SendMapBlock(response, flag & 0xffff);
        }
开发者ID:BogusCurry,项目名称:halcyon,代码行数:31,代码来源:WorldMapModule.cs

示例8: RequestMapBlocks

        /// <summary>
        /// Requests map blocks in area of minX, maxX, minY, MaxY in world cordinates
        /// </summary>
        /// <param name="minX"></param>
        /// <param name="minY"></param>
        /// <param name="maxX"></param>
        /// <param name="maxY"></param>
        public virtual void RequestMapBlocks(IClientAPI remoteClient, int minX, int minY, int maxX, int maxY, uint flag)
        {
            //m_log.ErrorFormat("[YYY] RequestMapBlocks {0}={1}={2}={3} {4}", minX, minY, maxX, maxY, flag);
            if ((flag & 0x10000) != 0)  // user clicked on qthe map a tile that isn't visible
            {
                List<MapBlockData> response = new List<MapBlockData>();

                // this should return one mapblock at most. It is triggered by a click
                // on an unloaded square.
                // But make sure: Look whether the one we requested is in there
                List<GridRegion> regions = m_scene.GridService.GetRegionRange(m_scene.RegionInfo.ScopeID,
                    minX * (int)Constants.RegionSize, 
                    maxX * (int)Constants.RegionSize, 
                    minY * (int)Constants.RegionSize, 
                    maxY * (int)Constants.RegionSize);

                if (regions != null)
                {
                    foreach (GridRegion r in regions)
                    {
                        if ((r.RegionLocX == minX * (int)Constants.RegionSize) && 
                            (r.RegionLocY == minY * (int)Constants.RegionSize))
                        {
                            // found it => add it to response
                            MapBlockData block = new MapBlockData();
                            MapBlockFromGridRegion(block, r, flag);
                            response.Add(block);
                            break;
                        }
                    }
                }

                if (response.Count == 0)
                {
                    // response still empty => couldn't find the map-tile the user clicked on => tell the client
                    MapBlockData block = new MapBlockData();
                    block.X = (ushort)minX;
                    block.Y = (ushort)minY;
                    block.Access = 254; // means 'simulator is offline'
                    response.Add(block);
                }
                // The lower 16 bits are an unsigned int16
                remoteClient.SendMapBlock(response, flag & 0xffff);
            }
            else
            {
                // normal mapblock request. Use the provided values
                GetAndSendBlocks(remoteClient, minX, minY, maxX, maxY, flag);
            }
        }
开发者ID:pluraldj,项目名称:opensim,代码行数:57,代码来源:WorldMapModule.cs

示例9: MapBlockFromGridRegion

 protected void MapBlockFromGridRegion(MapBlockData block, GridRegion r, uint flag)
 {
     block.Access = r.Access;
     switch (flag & 0xffff)
     {
     case 0:
         block.MapImageId = r.TerrainImage;
         break;
     case 2:
         block.MapImageId = r.ParcelImage;
         break;
     default:
         block.MapImageId = UUID.Zero;
         break;
     }
     block.Name = r.RegionName;
     block.X = (ushort)(r.RegionLocX / Constants.RegionSize);
     block.Y = (ushort)(r.RegionLocY / Constants.RegionSize);
 }
开发者ID:pluraldj,项目名称:opensim,代码行数:19,代码来源:WorldMapModule.cs

示例10: OnMapNameRequest

        private void OnMapNameRequest(IClientAPI remoteClient, string mapName, uint flags)
        {
            if (mapName.Length < 3)
            {
                remoteClient.SendAlertMessage("Use a search string with at least 3 characters");
                return;
            }

//m_log.DebugFormat("MAP NAME=({0})", mapName);
            
            // try to fetch from GridServer
            List<GridRegion> regionInfos = m_scene.GridService.GetRegionsByName(m_scene.RegionInfo.ScopeID, mapName, 20);
            if (regionInfos.Count == 0)
                remoteClient.SendAlertMessage("Hyperlink could not be established.");

            m_log.DebugFormat("[MAPSEARCHMODULE]: search {0} returned {1} regions. Flags={2}", mapName, regionInfos.Count, flags);
            List<MapBlockData> blocks = new List<MapBlockData>();

            MapBlockData data;
            if (regionInfos.Count > 0)
            {
                foreach (GridRegion info in regionInfos)
                {
                    data = new MapBlockData();
                    data.Agents = 0;
                    data.Access = info.Access;
                    if (flags == 2) // V2 sends this
                        data.MapImageId = UUID.Zero; 
                    else
                        data.MapImageId = info.TerrainImage;
                    data.Name = info.RegionName;
                    data.RegionFlags = 0; // TODO not used?
                    data.WaterHeight = 0; // not used
                    data.X = (ushort)(info.RegionLocX / Constants.RegionSize);
                    data.Y = (ushort)(info.RegionLocY / Constants.RegionSize);
                    blocks.Add(data);
                }
            }

            // final block, closing the search result
            data = new MapBlockData();
            data.Agents = 0;
            data.Access = 255;
            data.MapImageId = UUID.Zero;
            data.Name = ""; // mapName;
            data.RegionFlags = 0;
            data.WaterHeight = 0; // not used
            data.X = 0;
            data.Y = 0;
            blocks.Add(data);

            // flags are agent flags sent from the viewer.
            // they have different values depending on different viewers, apparently
            remoteClient.SendMapBlock(blocks, flags);
        }
开发者ID:4U2NV,项目名称:opensim,代码行数:55,代码来源:MapSearchModule.cs

示例11: OnMapNameRequest

        private void OnMapNameRequest(IClientAPI remoteClient, string mapName, uint flags)
        {
            List<MapBlockData> blocks = new List<MapBlockData>();
            MapBlockData data;
            if (mapName.Length < 3 || (mapName.EndsWith("#") && mapName.Length < 4))
            {
                // final block, closing the search result
                AddFinalBlock(blocks);

                // flags are agent flags sent from the viewer.
                // they have different values depending on different viewers, apparently
                remoteClient.SendMapBlock(blocks, flags);
                remoteClient.SendAlertMessage("Use a search string with at least 3 characters");
                return;
            }


            //m_log.DebugFormat("MAP NAME=({0})", mapName);

            // Hack to get around the fact that ll V3 now drops the port from the
            // map name. See https://jira.secondlife.com/browse/VWR-28570
            //
            // Caller, use this magic form instead:
            // secondlife://http|!!mygrid.com|8002|Region+Name/128/128
            // or url encode if possible.
            // the hacks we do with this viewer...
            //
            string mapNameOrig = mapName;
            if (mapName.Contains("|"))
                mapName = mapName.Replace('|', ':');
            if (mapName.Contains("+"))
                mapName = mapName.Replace('+', ' ');
            if (mapName.Contains("!"))
                mapName = mapName.Replace('!', '/');
            
            // try to fetch from GridServer
            List<GridRegion> regionInfos = m_scene.GridService.GetRegionsByName(m_scene.RegionInfo.ScopeID, mapName, 20);

            m_log.DebugFormat("[MAPSEARCHMODULE]: search {0} returned {1} regions. Flags={2}", mapName, regionInfos.Count, flags);
            if (regionInfos.Count > 0)
            {
                foreach (GridRegion info in regionInfos)
                {
                    data = new MapBlockData();
                    data.Agents = 0;
                    data.Access = info.Access;
                    if (flags == 2) // V2 sends this
                        data.MapImageId = UUID.Zero; 
                    else
                        data.MapImageId = info.TerrainImage;
                    // ugh! V2-3 is very sensitive about the result being
                    // exactly the same as the requested name
                    if (regionInfos.Count == 1 && mapNameOrig.Contains("|") || mapNameOrig.Contains("+"))
                        data.Name = mapNameOrig;
                    else
                        data.Name = info.RegionName;
                    data.RegionFlags = 0; // TODO not used?
                    data.WaterHeight = 0; // not used
                    data.X = (ushort)(info.RegionLocX / Constants.RegionSize);
                    data.Y = (ushort)(info.RegionLocY / Constants.RegionSize);
                    blocks.Add(data);
                }
            }

            // final block, closing the search result
            AddFinalBlock(blocks);

            // flags are agent flags sent from the viewer.
            // they have different values depending on different viewers, apparently
            remoteClient.SendMapBlock(blocks, flags);

            // send extra user messages for V3
            // because the UI is very confusing
            // while we don't fix the hard-coded urls
            if (flags == 2) 
            {
                if (regionInfos.Count == 0)
                    remoteClient.SendAlertMessage("No regions found with that name.");
                else if (regionInfos.Count == 1)
                    remoteClient.SendAlertMessage("Region found!");
            }
        }
开发者ID:Michelle-Argus,项目名称:opensim,代码行数:82,代码来源:MapSearchModule.cs

示例12: FillInMap

 private void FillInMap(List<MapBlockData> mapBlocks, int minX, int minY, int maxX, int maxY)
 {
     for (int x = minX; x <= maxX; x++)
     {
         for (int y = minY; y <= maxY; y++)
         {
             MapBlockData mblock = mapBlocks.Find(delegate(MapBlockData mb) { return ((mb.X == x) && (mb.Y == y)); });
             if (mblock == null)
             {
                 mblock = new MapBlockData();
                 mblock.X = (ushort)x;
                 mblock.Y = (ushort)y;
                 mblock.Name = "";
                 mblock.Access = 254; // means 'simulator is offline'. We need this because the viewer ignores 255's
                 mblock.MapImageId = UUID.Zero;
                 mapBlocks.Add(mblock);
             }
         }
     }
 }
开发者ID:phantasmagoric,项目名称:InfiniteGrid-Opensim,代码行数:20,代码来源:HGWorldMapModule.cs

示例13: GetAndSendBlocks

        protected override List<MapBlockData> GetAndSendBlocks(IClientAPI remoteClient, int minX, int minY, int maxX, int maxY, uint flag)
        {
            List<MapBlockData> mapBlocks = new List<MapBlockData>();
            List<GridRegion> regions = m_scene.GridService.GetRegionRange(m_scene.RegionInfo.ScopeID,
                minX * (int)Constants.RegionSize, maxX * (int)Constants.RegionSize, 
                minY * (int)Constants.RegionSize, maxY * (int)Constants.RegionSize);

            foreach (GridRegion r in regions)
            {
                uint x = 0, y = 0;
                long handle = 0;
                if (r.RegionSecret != null && r.RegionSecret != string.Empty)
                {
                    if (long.TryParse(r.RegionSecret, out handle))
                    {
                        Utils.LongToUInts((ulong)handle, out x, out y);
                        x = x / Constants.RegionSize;
                        y = y / Constants.RegionSize;
                    }
                }

                if (handle == 0 || 
                    // Check the distance from the current region
                    (handle != 0 && Math.Abs((int)(x - m_scene.RegionInfo.RegionLocX)) < 4096 && Math.Abs((int)(y - m_scene.RegionInfo.RegionLocY)) < 4096))
                {
                    MapBlockData block = new MapBlockData();
                    MapBlockFromGridRegion(block, r);
                    mapBlocks.Add(block);
                }
            }

            // Different from super
            FillInMap(mapBlocks, minX, minY, maxX, maxY);
            //

            remoteClient.SendMapBlock(mapBlocks, 0);

            return mapBlocks;
        }
开发者ID:francogrid,项目名称:sim,代码行数:39,代码来源:HGWorldMapModule.cs

示例14: Teleport

        public void Teleport(ScenePresence sp, ulong regionHandle, Vector3 position, Vector3 lookAt, uint teleportFlags)
        {
            if (!sp.Scene.Permissions.CanTeleport(sp.UUID))
                return;

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

            // Reset animations; the viewer does that in teleports.
            sp.Animator.ResetAnimations();

            try
            {
                if (regionHandle == sp.Scene.RegionInfo.RegionHandle)
                {
                    m_log.DebugFormat(
                        "[ENTITY TRANSFER MODULE]: RequestTeleportToLocation {0} within {1}",
                        position, sp.Scene.RegionInfo.RegionName);

                    // Teleport within the same region
                    if (IsOutsideRegion(sp.Scene, position) || position.Z < 0)
                    {
                        Vector3 emergencyPos = new Vector3(128, 128, 128);

                        m_log.WarnFormat(
                            "[ENTITY TRANSFER MODULE]: RequestTeleportToLocation() was given an illegal position of {0} for avatar {1}, {2}.  Substituting {3}",
                            position, sp.Name, sp.UUID, emergencyPos);
                        position = emergencyPos;
                    }

                    // TODO: Get proper AVG Height
                    float localAVHeight = 1.56f;
                    float posZLimit = 22;

                    // TODO: Check other Scene HeightField
                    if (position.X > 0 && position.X <= (int)Constants.RegionSize && position.Y > 0 && position.Y <= (int)Constants.RegionSize)
                    {
                        posZLimit = (float)sp.Scene.Heightmap[(int)position.X, (int)position.Y];
                    }

                    float newPosZ = posZLimit + localAVHeight;
                    if (posZLimit >= (position.Z - (localAVHeight / 2)) && !(Single.IsInfinity(newPosZ) || Single.IsNaN(newPosZ)))
                    {
                        position.Z = newPosZ;
                    }

                    // Only send this if the event queue is null
                    if (eq == null)
                        sp.ControllingClient.SendTeleportLocationStart();

                    sp.ControllingClient.SendLocalTeleport(position, lookAt, teleportFlags);
                    sp.Teleport(position);
                }
                else // Another region possibly in another simulator
                {
                    uint x = 0, y = 0;
                    Utils.LongToUInts(regionHandle, out x, out y);
                    GridRegion reg = m_aScene.GridService.GetRegionByPosition(sp.Scene.RegionInfo.ScopeID, (int)x, (int)y);

                    if (reg != null)
                    {
                        GridRegion finalDestination = GetFinalDestination(reg);
                        if (finalDestination == null)
                        {
                            m_log.DebugFormat("[ENTITY TRANSFER MODULE]: Final destination is having problems. Unable to teleport agent.");
                            sp.ControllingClient.SendTeleportFailed("Problem at destination");
                            return;
                        }
                        m_log.DebugFormat("[ENTITY TRANSFER MODULE]: Final destination is x={0} y={1} uuid={2}",
                            finalDestination.RegionLocX / Constants.RegionSize, finalDestination.RegionLocY / Constants.RegionSize, finalDestination.RegionID);

                        //
                        // This is it
                        //
                        DoTeleport(sp, reg, finalDestination, position, lookAt, teleportFlags, eq);
                        //
                        //
                        //
                    }
                    else
                    {
                        // TP to a place that doesn't exist (anymore)
                        // Inform the viewer about that
                        sp.ControllingClient.SendTeleportFailed("The region you tried to teleport to doesn't exist anymore");

                        // and set the map-tile to '(Offline)'
                        uint regX, regY;
                        Utils.LongToUInts(regionHandle, out regX, out regY);

                        MapBlockData block = new MapBlockData();
                        block.X = (ushort)(regX / Constants.RegionSize);
                        block.Y = (ushort)(regY / Constants.RegionSize);
                        block.Access = 254; // == not there

                        List<MapBlockData> blocks = new List<MapBlockData>();
                        blocks.Add(block);
                        sp.ControllingClient.SendMapBlock(blocks, 0);
                    }
                }
            }
            catch (Exception e)
//.........这里部分代码省略.........
开发者ID:gumho,项目名称:diva-distribution,代码行数:101,代码来源:EntityTransferModule.cs

示例15: TeleportAgentToDifferentRegion

        /// <summary>
        /// Teleports the agent to a different region.
        /// </summary>
        /// <param name='sp'></param>
        /// <param name='regionHandle'>/param>
        /// <param name='position'></param>
        /// <param name='lookAt'></param>
        /// <param name='teleportFlags'></param>
        /// <param name='finalDestination'></param>
        private void TeleportAgentToDifferentRegion(
            ScenePresence sp, ulong regionHandle, Vector3 position,
            Vector3 lookAt, uint teleportFlags, out GridRegion finalDestination)
        {
            uint x = 0, y = 0;
            Utils.LongToUInts(regionHandle, out x, out y);
            GridRegion reg = Scene.GridService.GetRegionByPosition(sp.Scene.RegionInfo.ScopeID, (int)x, (int)y);

            if (reg != null)
            {
                finalDestination = GetFinalDestination(reg);

                if (finalDestination == null)
                {
                    m_log.WarnFormat(
                        "[ENTITY TRANSFER MODULE]: Final destination is having problems. Unable to teleport {0} {1}",
                        sp.Name, sp.UUID);

                    sp.ControllingClient.SendTeleportFailed("Problem at destination");
                    return;
                }

                // Check that these are not the same coordinates
                if (finalDestination.RegionLocX == sp.Scene.RegionInfo.RegionLocX &&
                    finalDestination.RegionLocY == sp.Scene.RegionInfo.RegionLocY)
                {
                    // Can't do. Viewer crashes
                    sp.ControllingClient.SendTeleportFailed("Space warp! You would crash. Move to a different region and try again.");
                    return;
                }

                // Validate assorted conditions
                string reason = string.Empty;
                if (!ValidateGenericConditions(sp, reg, finalDestination, teleportFlags, out reason))
                {
                    sp.ControllingClient.SendTeleportFailed(reason);
                    return;
                }

                //
                // This is it
                //
                DoTeleportInternal(sp, reg, finalDestination, position, lookAt, teleportFlags);
                //
                //
                //
            }
            else
            {
                finalDestination = null;

                // TP to a place that doesn't exist (anymore)
                // Inform the viewer about that
                sp.ControllingClient.SendTeleportFailed("The region you tried to teleport to doesn't exist anymore");

                // and set the map-tile to '(Offline)'
                uint regX, regY;
                Utils.LongToUInts(regionHandle, out regX, out regY);

                MapBlockData block = new MapBlockData();
                block.X = (ushort)(regX / Constants.RegionSize);
                block.Y = (ushort)(regY / Constants.RegionSize);
                block.Access = 254; // == not there

                List<MapBlockData> blocks = new List<MapBlockData>();
                blocks.Add(block);
                sp.ControllingClient.SendMapBlock(blocks, 0);
            }
        }
开发者ID:skidzTweak,项目名称:opensim,代码行数:78,代码来源:EntityTransferModule.cs


注:本文中的OpenSim.Framework.MapBlockData类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。