// returns false if other is same vertex public bool SharesLine(LuaVertex other) { if (vertex.IsDisposed || other.vertex.IsDisposed) { throw new ScriptRuntimeException("Vertex has been disposed, can't SharesLine()"); } if (other == null) { throw new ScriptRuntimeException("Other vertex is null, can't SharesLine() (not enough arguments maybe?)"); } if (vertex == other.vertex) { // FIXME add a warning for this probably // is it possible for this to ever actually be correct and true return(false); } foreach (Linedef l in vertex.Linedefs) { if (!l.IsDisposed) { if (l.Start == other.vertex || l.End == other.vertex) { return(true); } } } return(false); }
public void Join(LuaVertex other) { if (vertex.IsDisposed) { throw new ScriptRuntimeException("Joining vertex has been disposed!"); } if (other.vertex.IsDisposed) { throw new ScriptRuntimeException("Joinee vertex has been disposed!"); } if (other == null) { throw new ScriptRuntimeException("Other vertex is null, can't Join() (not enough arguments maybe?)"); } vertex.Join(other.vertex); // Update cached values General.Map.Map.Update(); }
// returns a tuple of vertex, linedef, linedef public DynValue Split(LuaVertex v) { if (linedef.IsDisposed) { throw new ScriptRuntimeException("Linedef has been disposed, can't Split."); } if (v == null) { throw new ScriptRuntimeException("Vertex is null, can't Split (not enough arguments maybe?)."); } if (v.vertex.IsDisposed) { throw new ScriptRuntimeException("Vertex has been disposed, can't Split."); } v.vertex.SnapToAccuracy(); LuaLinedef newline = new LuaLinedef(linedef.Split(v.vertex)); if (newline.linedef == null) { throw new ScriptRuntimeException( "Split returned null linedef (max linedef limit reached? current count is " + General.Map.Map.Linedefs.Count + " of " + General.Map.FormatInterface.MaxLinedefs + ")"); } // Update cached values General.Map.Map.Update(); return(DynValue.NewTuple( DynValue.FromObject(ScriptContext.context.script, v), DynValue.FromObject(ScriptContext.context.script, newline), DynValue.FromObject(ScriptContext.context.script, this) )); }