Exemplo n.º 1
0
        public float SafeDistanceToSq(LuaVector2D p, bool bounded)
        {
            if (linedef.IsDisposed)
            {
                throw new ScriptRuntimeException("Linedef has been disposed, can't SafeDistanceToSq.");
            }

            return(linedef.SafeDistanceToSq(p.vec, bounded));
        }
Exemplo n.º 2
0
        // Mouse moving
        public override void OnMouseMove(MouseEventArgs e)
        {
            base.OnMouseMove(e);

            if (selecting)
            {
                ClearHighlighted();
                RenderMultiSelection();
            }
            else
            {
                // ano - a lot of this is from codeimp's buildermodes plugins
                if (e.Button == MouseButtons.None)
                {
                    Linedef l = General.Map.Map.NearestLinedefRange(
                        mousemappos,
                        HIGHLIGHT_RANGE / renderer.Scale);

                    Thing t = MapSet.NearestThingSquareRange(
                        General.Map.ThingsFilter.VisibleThings,
                        mousemappos,
                        HIGHLIGHT_THINGS_RANGE / renderer.Scale);

                    Vertex v = General.Map.Map.NearestVertexSquareRange(
                        mousemappos,
                        HIGHLIGHT_VERTICES_RANGE / renderer.Scale);

                    Sector  s  = null;
                    Linedef ls = l;
                    if (ls == null)
                    {
                        ls = General.Map.Map.NearestLinedef(mousemappos);
                    }

                    if (ls != null)
                    {
                        // Check on which side of the linedef the mouse is
                        float side = ls.SideOfLine(mousemappos);

                        if (side > 0)
                        {
                            // Is there a sidedef here?
                            if (ls.Back != null)
                            {
                                s = ls.Back.Sector;
                            }
                        }
                        else if (ls.Front != null)
                        {
                            s = ls.Front.Sector;
                        }
                    }

                    HighlightType htype = HighlightType.Null;

                    if (v != null)
                    {
                        htype = HighlightType.Vertex;
                    }


                    if (t != null)
                    {
                        if (htype == HighlightType.Null)
                        {
                            htype = HighlightType.Thing;
                        }
                        else if (htype == HighlightType.Vertex &&
                                 v.DistanceToSq(mousemappos) > t.DistanceToSq(mousemappos))
                        {
                            // figure out which is closer and highlight that one
                            htype = HighlightType.Thing;
                        }
                    }


                    if (l != null)
                    {
                        switch (htype)
                        {
                        case HighlightType.Vertex:
                            break;

                        case HighlightType.Thing:
                            if (l.SafeDistanceToSq(mousemappos, false) < t.DistanceToSq(mousemappos))
                            {
                                // figure out which is closer and highlight that one
                                htype = HighlightType.Linedef;
                            }
                            break;

                        default:
                            htype = HighlightType.Linedef;
                            break;
                        }
                    }

                    if (htype == HighlightType.Null && s != null)
                    {
                        htype = HighlightType.Sector;
                    }

                    switch (htype)
                    {
                    case HighlightType.Linedef:
                        HighlightLinedef(l);
                        break;

                    case HighlightType.Sector:
                        HighlightSector(s);
                        break;

                    case HighlightType.Vertex:
                        HighlightVertex(v);
                        break;

                    case HighlightType.Thing:
                        HighlightThing(t);
                        break;

                    case HighlightType.Null:
                    default:
                        // highlight nothing
                        ClearHighlighted();
                        renderer.Present();
                        break;
                    } // switch
                }

                if (renderer.StartOverlay(true))
                {
                    DrawCursor();

                    renderer.Finish();
                    renderer.Present();
                }
            }
        }