Aurora.ScriptEngine.AuroraDotNetEngine.APIs.LSL_Api.llEdgeOfWorld C# (CSharp) Method

llEdgeOfWorld() public method

public llEdgeOfWorld ( Aurora.ScriptEngine.AuroraDotNetEngine.LSL_Types.Vector3 pos, Aurora.ScriptEngine.AuroraDotNetEngine.LSL_Types.Vector3 dir ) : Aurora.ScriptEngine.AuroraDotNetEngine.LSL_Types.LSLInteger
pos Aurora.ScriptEngine.AuroraDotNetEngine.LSL_Types.Vector3
dir Aurora.ScriptEngine.AuroraDotNetEngine.LSL_Types.Vector3
return Aurora.ScriptEngine.AuroraDotNetEngine.LSL_Types.LSLInteger
        public LSL_Integer llEdgeOfWorld(LSL_Vector pos, LSL_Vector dir)
        {
            if (!ScriptProtection.CheckThreatLevel(ThreatLevel.None, "LSL", m_host, "LSL", m_itemID)) return 0;


            // edge will be used to pass the Region Coordinates offset
            // we want to check for a neighboring sim
            LSL_Vector edge = new LSL_Vector(0, 0, 0);

            if (dir.x == 0)
            {
                if (dir.y == 0)
                {
                    // Direction vector is 0,0 so return
                    // false since we're staying in the sim
                    return 0;
                }
                // Y is the only valid direction
                edge.y = dir.y / Math.Abs(dir.y);
            }
            else
            {
                LSL_Float mag;
                if (dir.x > 0)
                {
                    mag = (World.RegionInfo.RegionSizeX - pos.x) / dir.x;
                }
                else
                {
                    mag = (pos.x / dir.x);
                }

                mag = Math.Abs(mag);

                edge.y = pos.y + (dir.y * mag);

                if (edge.y > World.RegionInfo.RegionSizeY || edge.y < 0)
                {
                    // Y goes out of bounds first
                    edge.y = dir.y / Math.Abs(dir.y);
                }
                else
                {
                    // X goes out of bounds first or its a corner exit
                    edge.y = 0;
                    edge.x = dir.x / Math.Abs(dir.x);
                }
            }
            IGridRegisterModule service = World.RequestModuleInterface<IGridRegisterModule>();
            List<GridRegion> neighbors = new List<GridRegion>();
            if (service != null)
                neighbors = service.GetNeighbors(World);

            int neighborX = World.RegionInfo.RegionLocX + (int)dir.x;
            int neighborY = World.RegionInfo.RegionLocY + (int)dir.y;
#if (!ISWIN)
            foreach (GridRegion neighbor in neighbors)
                if (neighbor.RegionLocX == neighborX && neighbor.RegionLocY == neighborY)
                    return LSL_Integer.TRUE;
#else
            if (neighbors.Any(neighbor => neighbor.RegionLocX == neighborX && neighbor.RegionLocY == neighborY))
            {
                return LSL_Integer.TRUE;
            }
#endif
            return LSL_Integer.FALSE;
        }
LSL_Api