Exemplo n.º 1
0
        public void BindTag(int tag, LinedefProperties ldprops)
        {
            Linedef line = null;

            // try to find an line without an action
            foreach (Sidedef sd in sector.Sidedefs)
            {
                if (sd.Line.Action == 0 && sd.Line.Tag == 0 && line == null)
                {
                    line = sd.Line;
                }

                // if a line of the control sector already has the tag
                // nothing has to be done
                if (sd.Line.Args[0] == tag)
                {
                    return;
                }
            }

            // no lines without an action, so a line has to get split
            // find the longest line to split
            if (line == null)
            {
                line = sector.Sidedefs.First().Line;

                foreach (Sidedef sd in sector.Sidedefs)
                {
                    if (sd.Line.Length > line.Length)
                    {
                        line = sd.Line;
                    }
                }

                // Lines may not have a length of less than 1 after splitting
                if (line.Length / 2 < 1)
                {
                    throw new Exception("Can't split more lines in Sector " + line.Front.Sector.Index.ToString() + ".");
                }

                Vertex v = General.Map.Map.CreateVertex(line.Line.GetCoordinatesAt(0.5f));
                v.SnapToAccuracy();

                line = line.Split(v);

                General.Map.Map.Update();
                General.Interface.RedrawDisplay();
            }

            if (ldprops != null)
            {
                ldprops.Apply(new List <Linedef>()
                {
                    line
                }, false);
            }

            line.Action  = 160;
            line.Args[0] = tag;
            line.Args[1] = type;
            line.Args[2] = flags;
            line.Args[3] = alpha;
        }