public LineDef( Vertex vertex1, Vertex vertex2, LineFlags flags, LineSpecial special, short tag, SideDef side0, SideDef side1) { Vertex1 = vertex1; Vertex2 = vertex2; Flags = flags; Special = special; Tag = tag; Side0 = side0; Side1 = side1; Dx = vertex2.X - vertex1.X; Dy = vertex2.Y - vertex1.Y; if (Dx == Fixed.Zero) { SlopeType = SlopeType.Vertical; } else if (Dy == Fixed.Zero) { SlopeType = SlopeType.Horizontal; } else { if (Dy / Dx > Fixed.Zero) { SlopeType = SlopeType.Positive; } else { SlopeType = SlopeType.Negative; } } Box = new Fixed[4]; Box[ManagedDoom.Box.Top] = Fixed.Max(vertex1.Y, vertex2.Y); Box[ManagedDoom.Box.Bottom] = Fixed.Min(vertex1.Y, vertex2.Y); Box[ManagedDoom.Box.Left] = Fixed.Min(vertex1.X, vertex2.X); Box[ManagedDoom.Box.Right] = Fixed.Max(vertex1.X, vertex2.X); FrontSector = side0?.Sector; BackSector = side1?.Sector; }
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; dx = vertex2.X - vertex1.X; dy = vertex2.Y - vertex1.Y; if (dx == Fixed.Zero) { slopeType = SlopeType.Vertical; } else if (dy == Fixed.Zero) { slopeType = SlopeType.Horizontal; } else { if (dy / dx > Fixed.Zero) { slopeType = SlopeType.Positive; } else { slopeType = SlopeType.Negative; } } boundingBox = new Fixed[4]; boundingBox[Box.Top] = Fixed.Max(vertex1.Y, vertex2.Y); boundingBox[Box.Bottom] = Fixed.Min(vertex1.Y, vertex2.Y); boundingBox[Box.Left] = Fixed.Min(vertex1.X, vertex2.X); boundingBox[Box.Right] = Fixed.Max(vertex1.X, vertex2.X); frontSector = frontSide?.Sector; backSector = backSide?.Sector; }
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; }
public static SideDef[] FromWad(Wad wad, int lump, TextureLookup textures, Sector[] sectors) { var length = wad.GetLumpSize(lump); if (length % dataSize != 0) { throw new Exception(); } var data = wad.ReadLump(lump); var count = length / dataSize; var sides = new SideDef[count];; for (var i = 0; i < count; i++) { var offset = dataSize * i; sides[i] = FromData(data, offset, textures, sectors); } return(sides); }
public Map(Wad wad, TextureLookup textures, FlatLookup flats, World world) { this.textures = textures; this.flats = flats; this.world = world; var options = world.Options; string name; if (wad.Names.Contains("doom") || wad.Names.Contains("doom1")) { name = "E" + options.Episode + "M" + options.Map; } else { name = "MAP" + options.Map.ToString("00"); } var map = wad.GetLumpNumber(name); vertices = Vertex.FromWad(wad, map + 4); sectors = Sector.FromWad(wad, map + 8, flats); sides = SideDef.FromWad(wad, map + 3, textures, sectors); lines = LineDef.FromWad(wad, map + 2, vertices, sides); segs = Seg.FromWad(wad, map + 5, vertices, lines); subsectors = Subsector.FromWad(wad, map + 6, segs); nodes = Node.FromWad(wad, map + 7, subsectors); things = MapThing.FromWad(wad, map + 1); blockMap = BlockMap.FromWad(wad, map + 10, lines); reject = Reject.FromWad(wad, map + 9, sectors); GroupLines(); skyTexture = GetSkyTextureByMapName(name); }
public Map(Wad wad, ITextureLookup textures, IFlatLookup 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 (wad.GameMode == GameMode.Commercial) { name = "MAP" + options.Map.ToString("00"); } else { name = "E" + options.Episode + "M" + options.Map; } Console.Write("Load map '" + name + "': "); var map = wad.GetLumpNumber(name); if (map == -1) { throw new Exception("Map '" + name + "' was not found!"); } vertices = Vertex.FromWad(wad, map + 4); sectors = Sector.FromWad(wad, map + 8, flats); sides = SideDef.FromWad(wad, map + 3, textures, sectors); lines = LineDef.FromWad(wad, map + 2, vertices, sides); segs = Seg.FromWad(wad, map + 5, vertices, lines); subsectors = Subsector.FromWad(wad, map + 6, segs); nodes = Node.FromWad(wad, map + 7, subsectors); things = MapThing.FromWad(wad, map + 1); blockMap = BlockMap.FromWad(wad, map + 10, lines); reject = Reject.FromWad(wad, map + 9, sectors); GroupLines(); skyTexture = GetSkyTextureByMapName(name); if (options.GameMode == GameMode.Commercial) { switch (options.MissionPack) { case MissionPack.Plutonia: title = DoomInfo.MapTitles.Plutonia[options.Map - 1]; break; case MissionPack.Tnt: title = DoomInfo.MapTitles.Tnt[options.Map - 1]; break; default: title = DoomInfo.MapTitles.Doom2[options.Map - 1]; break; } } else { title = DoomInfo.MapTitles.Doom[options.Episode - 1][options.Map - 1]; } Console.WriteLine("OK"); } catch (Exception e) { Console.WriteLine("Failed"); ExceptionDispatchInfo.Throw(e); } }