Example #1
0
 public static LuaLine2D From(LuaLinedef linedef)
 {
     if (linedef.linedef.IsDisposed)
     {
         throw new ScriptRuntimeException("Linedef is disposed, can't Line2D.From().");
     }
     return(new LuaLine2D(linedef.linedef.Line));
 }
Example #2
0
        // ano - TODO probably a bad idea to let lua access? let's think about this

        /*
         * // This joins the line with another line
         * // This line will be disposed
         * // Returns false when the operation could not be completed
         * public bool Join(LuaLinedef other)
         * {
         *  if (linedef.IsDisposed || other.linedef.IsDisposed)
         *  {
         *      throw new ScriptRuntimeException("Linedef has been disposed, can't Split.");
         *  }
         *  return linedef.Join(other.linedef);
         * }
         */

        // used to swap indices sort of
        public void SwapProperties(LuaLinedef other)
        {
            if (linedef.IsDisposed)
            {
                throw new ScriptRuntimeException("Linedef has been disposed, can't SwapProperties.");
            }
            if (other == null)
            {
                throw new ScriptRuntimeException("Other linedef is null, can't SwapProperties (not enough arguments maybe?).");
            }
            if (other.linedef.IsDisposed)
            {
                throw new ScriptRuntimeException("Other linedef has been disposed, can't SwapProperties.");
            }

            linedef.SwapProperties(other.linedef);
        }
Example #3
0
        // splits middle of line
        // returns a tuple of vertex, linedef, linedef
        public DynValue Split()
        {
            if (linedef.IsDisposed)
            {
                throw new ScriptRuntimeException("Linedef has been disposed, can't Split.");
            }

            Vertex v = General.Map.Map.CreateVertex(linedef.GetCenterPoint());

            if (v == null)
            {
                throw new ScriptRuntimeException(
                          "Split returned null vertex (max vertex limit reached? current count is "
                          + General.Map.Map.Vertices.Count
                          + ")");
            }

            v.SnapToAccuracy();

            LuaLinedef newline = new LuaLinedef(linedef.Split(v));

            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, new LuaVertex(v)),
                       DynValue.FromObject(ScriptContext.context.script, newline),
                       DynValue.FromObject(ScriptContext.context.script, this)
                       ));
        }
Example #4
0
        // 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)
                       ));
        }