Пример #1
0
        public float DistanceTo(LuaVector2D p, bool bounded)
        {
            if (linedef.IsDisposed)
            {
                throw new ScriptRuntimeException("Linedef has been disposed, can't DistanceTo.");
            }

            return(linedef.DistanceTo(p.vec, bounded));
        }
Пример #2
0
        // Mouse moves
        public override void OnMouseMove(MouseEventArgs e)
        {
            base.OnMouseMove(e);

            // Not holding any buttons?
            if (e.Button == MouseButtons.None)
            {
                // Find the nearest items within highlight range
                Vertex  v = General.Map.Map.NearestVertexSquareRange(mousemappos, VERTEX_HIGHLIGHT_RANGE / renderer.Scale);
                Thing   t = General.Map.Map.NearestThingSquareRange(mousemappos, THING_HIGHLIGHT_RANGE / renderer.Scale);
                Linedef l = General.Map.Map.NearestLinedef(mousemappos);
                Sector  s;

                // Check on which side of the linedef the mouse is
                float side = l.SideOfLine(mousemappos);
                if (side > 0)
                {
                    // Is there a sidedef here?
                    if (l.Back != null)
                    {
                        s = l.Back.Sector;
                    }
                    else
                    {
                        s = null;
                    }
                }
                else
                {
                    // Is there a sidedef here?
                    if (l.Front != null)
                    {
                        s = l.Front.Sector;
                    }
                    else
                    {
                        s = null;
                    }
                }

                // Both a vertex and thing in range?
                if ((v != null) && (t != null))
                {
                    // Highlight closest
                    float vd = v.DistanceToSq(mousemappos);
                    float td = t.DistanceToSq(mousemappos);
                    if (vd < td)
                    {
                        Highlight(v);
                    }
                    else
                    {
                        Highlight(t);
                    }
                }
                // Vertex in range?
                else if (v != null)
                {
                    // Highlight vertex
                    Highlight(v);
                }
                // Thing in range?
                else if (t != null)
                {
                    // Highlight thing
                    Highlight(t);
                }
                else
                {
                    // Linedef within in range?
                    float ld = l.DistanceTo(mousemappos, true);
                    if (ld < (LINEDEF_HIGHLIGHT_RANGE / renderer.Scale))
                    {
                        // Highlight line
                        Highlight(l);
                    }
                    // Mouse inside a sector?
                    else if (s != null)
                    {
                        // Highlight sector
                        Highlight(s);
                    }
                    else
                    {
                        // Highlight nothing
                        Highlight(null);
                    }
                }
            }
        }