コード例 #1
0
ファイル: Seg.cs プロジェクト: MSylvia/DoomEngine
 public Seg(Vertex vertex1, Vertex vertex2, Fixed offset, Angle angle, SideDef sideDef, LineDef lineDef, Sector frontSector, Sector backSector)
 {
     this.vertex1     = vertex1;
     this.vertex2     = vertex2;
     this.offset      = offset;
     this.angle       = angle;
     this.sideDef     = sideDef;
     this.lineDef     = lineDef;
     this.frontSector = frontSector;
     this.backSector  = backSector;
 }
コード例 #2
0
ファイル: LineDef.cs プロジェクト: MSylvia/DoomEngine
        public LineDef(Vertex vertex1, Vertex vertex2, LineFlags flags, LineSpecial special, short tag, SideDef frontSide, SideDef backSide)
        {
            this.vertex1   = vertex1;
            this.vertex2   = vertex2;
            this.flags     = flags;
            this.special   = special;
            this.tag       = tag;
            this.frontSide = frontSide;
            this.backSide  = backSide;

            this.dx = vertex2.X - vertex1.X;
            this.dy = vertex2.Y - vertex1.Y;

            if (this.dx == Fixed.Zero)
            {
                this.slopeType = SlopeType.Vertical;
            }
            else if (this.dy == Fixed.Zero)
            {
                this.slopeType = SlopeType.Horizontal;
            }
            else
            {
                if (this.dy / this.dx > Fixed.Zero)
                {
                    this.slopeType = SlopeType.Positive;
                }
                else
                {
                    this.slopeType = SlopeType.Negative;
                }
            }

            this.boundingBox             = new Fixed[4];
            this.boundingBox[Box.Top]    = Fixed.Max(vertex1.Y, vertex2.Y);
            this.boundingBox[Box.Bottom] = Fixed.Min(vertex1.Y, vertex2.Y);
            this.boundingBox[Box.Left]   = Fixed.Min(vertex1.X, vertex2.X);
            this.boundingBox[Box.Right]  = Fixed.Max(vertex1.X, vertex2.X);

            this.frontSector = frontSide?.Sector;
            this.backSector  = backSide?.Sector;
        }
コード例 #3
0
ファイル: SideDef.cs プロジェクト: MSylvia/DoomEngine
        public static SideDef[] FromWad(string fileName, TextureLookup textures, Sector[] sectors)
        {
            var reader = new BinaryReader(DoomApplication.Instance.FileSystem.Read(fileName));
            var length = reader.BaseStream.Length;

            if (length % SideDef.dataSize != 0)
            {
                throw new Exception();
            }

            var data  = reader.ReadBytes((int)reader.BaseStream.Length);
            var count = length / SideDef.dataSize;
            var sides = new SideDef[count];

            ;

            for (var i = 0; i < count; i++)
            {
                var offset = SideDef.dataSize * i;
                sides[i] = SideDef.FromData(data, offset, textures, sectors);
            }

            return(sides);
        }
コード例 #4
0
        public Map(TextureLookup textures, FlatLookup flats, TextureAnimation animation, World world)
        {
            try
            {
                this.textures  = textures;
                this.flats     = flats;
                this.animation = animation;
                this.world     = world;

                var options = world.Options;

                string name;

                if (DoomApplication.Instance.IWad == "doom2" ||
                    DoomApplication.Instance.IWad == "freedoom2" ||
                    DoomApplication.Instance.IWad == "plutonia" ||
                    DoomApplication.Instance.IWad == "tnt")
                {
                    name = "MAP" + options.Map.ToString("00");
                }
                else
                {
                    name = "E" + options.Episode + "M" + options.Map;
                }

                Console.Write("Load map '" + name + "': ");

                var map = $"MAPS/{name}/";

                if (!DoomApplication.Instance.FileSystem.Files().Any(file => file.StartsWith(map)))
                {
                    throw new Exception("Map '" + name + "' was not found!");
                }

                this.vertices   = Vertex.FromWad($"{map}VERTEXES");
                this.sectors    = Sector.FromWad($"{map}SECTORS", flats);
                this.sides      = SideDef.FromWad($"{map}SIDEDEFS", textures, this.sectors);
                this.lines      = LineDef.FromWad($"{map}LINEDEFS", this.vertices, this.sides);
                this.segs       = Seg.FromWad($"{map}SEGS", this.vertices, this.lines);
                this.subsectors = Subsector.FromWad($"{map}SSECTORS", this.segs);
                this.nodes      = Node.FromWad($"{map}NODES", this.subsectors);
                this.things     = MapThing.FromWad($"{map}THINGS");
                this.blockMap   = BlockMap.FromWad($"{map}BLOCKMAP", this.lines);
                this.reject     = Reject.FromWad($"{map}REJECT", this.sectors);

                this.GroupLines();

                this.skyTexture = this.GetSkyTextureByMapName(name);

                if (DoomApplication.Instance.IWad == "doom2" ||
                    DoomApplication.Instance.IWad == "freedoom2" ||
                    DoomApplication.Instance.IWad == "plutonia" ||
                    DoomApplication.Instance.IWad == "tnt")
                {
                    if (DoomApplication.Instance.IWad == "plutonia")
                    {
                        this.title = DoomInfo.MapTitles.Plutonia[options.Map - 1];
                    }
                    else if (DoomApplication.Instance.IWad == "tnt")
                    {
                        this.title = DoomInfo.MapTitles.Tnt[options.Map - 1];
                    }
                    else
                    {
                        this.title = DoomInfo.MapTitles.Doom2[options.Map - 1];
                    }
                }
                else
                {
                    this.title = DoomInfo.MapTitles.Doom[options.Episode - 1][options.Map - 1];
                }

                Console.WriteLine("OK");
            }
            catch (Exception e)
            {
                Console.WriteLine("Failed");
                ExceptionDispatchInfo.Throw(e);
            }
        }