Exemplo n.º 1
0
        private static void SetLineSpecial(MapLinedef linedef, int flags, ushort type, ushort sectorTag)
        {
            if (flags.HasBits(0x0008))
            {
                linedef.UpperUnpegged = true;
            }
            if (flags.HasBits(0x0010))
            {
                linedef.LowerUnpegged = true;
            }

            // TODO
        }
Exemplo n.º 2
0
        private static Unpegged ToUnpegged(MapLinedef linedef)
        {
            bool lower = linedef.LowerUnpegged;
            bool upper = linedef.UpperUnpegged;

            if (!lower && !upper)
            {
                return(Unpegged.None);
            }
            if (lower && !upper)
            {
                return(Unpegged.Lower);
            }
            return(lower ? Unpegged.UpperAndLower : Unpegged.Upper);
        }
Exemplo n.º 3
0
        public Line(int index, MapLinedef linedef, Vec2F start, Vec2F end, Side front,
                    Side back = null)
        {
            Index    = index;
            Front    = front;
            Back     = new Optional <Side>(back);
            Segment  = new Seg2F(start, end);
            Unpegged = ToUnpegged(linedef);

            front.Line = this;
            if (back != null)
            {
                back.Line = this;
            }
        }
Exemplo n.º 4
0
        private static void ReadLinesOrThrow(MapData map, MapComponents components)
        {
            ByteReader reader = ByteReader.From(ByteOrder.Little, components.Linedefs.Value.Data);

            int count = reader.Length / BytesPerLine;

            for (int index = 0; index < count; index++)
            {
                MapLinedef linedef = new MapLinedef(index)
                {
                    StartVertex = reader.UShort(),
                    EndVertex   = reader.UShort()
                };

                ushort flags     = reader.UShort();
                ushort type      = reader.UShort();
                ushort sectorTag = reader.UShort();
                SetLineSpecial(linedef, flags, type, sectorTag);

                linedef.FrontSide = reader.UShort();
                int backID = reader.UShort();
                if (backID != NoSidedef)
                {
                    linedef.BackSide = backID;
                }

                if (!linedef.StartVertex.InRangeExclusive(0, map.Vertices.Count))
                {
                    throw new Exception($"Line {index} has out of range start vertex: {linedef.StartVertex}");
                }
                if (!linedef.EndVertex.InRangeExclusive(0, map.Vertices.Count))
                {
                    throw new Exception($"Line {index} has out of range start vertex: {linedef.EndVertex}");
                }
                if (!linedef.FrontSide.InRangeExclusive(0, map.Sidedefs.Count))
                {
                    throw new Exception($"Line {index} has out of range front sidedef: {linedef.FrontSide}");
                }
                if (linedef.BackSide != null && !linedef.FrontSide.InRangeExclusive(0, map.Sidedefs.Count))
                {
                    throw new Exception($"Line {index} has out of range back sidedef: {linedef.BackSide.Value}");
                }

                map.Linedefs.Add(linedef);
            }
        }