Source code for pink_doom.doom.data

"""
Map level types.

The following data structures define the persistent format
used in the lumps of the WAD files.
"""
from dataclasses import dataclass
from enum import Enum, auto


[docs]class MapLump(Enum): """ Lump order in a map WAD. Each map needs a couple of lumps to provide a complete scene geometry description. """ LABEL = auto() """A separator, name, ExMx or MAPxx""" THINGS = auto() """Monsters, items..""" LINEDEFS = auto() """LineDefs, from editing""" SIDEDEFS = auto() """SideDefs, from editing""" VERTEXES = auto() """Vertices, edited and BSP splits generated""" SEGS = auto() """LineSegs, from LineDefs split by BSP""" SSECTORS = auto() """SubSectors, list of LineSegs""" NODES = auto() """BSP nodes""" SECTORS = auto() """Sectors, from editing""" REJECT = auto() """LUT, sector-sector visibility""" BLOCKMAP = auto() """LUT, motion clipping, walls/grid element"""
[docs]@dataclass class MapVertex: """A single Vertex.""" x: int y: int
[docs]@dataclass class MapSidedef: """ A SideDef. Defines the visual appearance of a wall, by setting textures and offsets. """ texture_offset: int row_offset: int top_texture: str bottom_texture: str mid_texture: str sector: int """Front sector, towards viewer."""
[docs]@dataclass class MapLinedef: """ A LineDef. As used for editing, and as input to the BSP builder. """ v1: int v2: int flags: int special: int tag: int sidenum: tuple[int, int] """sidenum[1] will be -1 if one sided"""
[docs]class LinedefAttribute(Enum): """LineDef attributes.""" BLOCKING = 0x001 """Solid, is an obstacle.""" BLOCK_MONSTERS = 0x002 """Blocks monsters only.""" TWO_SIDED = 0x004 """Backside will not be present at all if not two sided.""" # If a texture is pegged, the texture will have # the end exposed to air held constant at the # top or bottom of the texture (stairs or pulled # down things) and will move with a height change # of one of the neighbor sectors. # Unpegged textures always have the first row of # the texture at the top pixel of the line for both # top and bottom textures (use next to windows). DONT_PEG_TOP = 0x008 """upper texture unpegged""" DONT_PEG_BOTTOM = 0x010 """lower texture unpegged""" SECRET = 0x020 """In AutoMap: don't map as two sided: IT'S A SECRET!""" SOUND_BLOCK = 0x040 """Sound rendering: don't let sound cross two of these.""" DONT_DRAW = 0x080 """Don't draw on the automap at all.""" MAPPED = 0x100 """Set if already seen, thus drawn in automap."""
[docs]@dataclass class MapSector: """Sector definition, from editing.""" floor_height: int ceiling_height: int floor_pic: str ceiling_pic: str light_level: int special: int tag: int
[docs]@dataclass class MapSubsector: """SubSector, as generated by BSP.""" num_segs: int first_seg: int """Index of first one, segs are stored sequentially."""
[docs]@dataclass class MapSeg: """ LineSeg. Generated by splitting LineDefs using partition lines selected by BSP builder. """ v1: int v2: int angle: int linedef: int side: int offset: int
# BSP node structure.
[docs]class NodeFlag(Enum): """Flags related to BSP nodes.""" SUBSECTOR = 0x8000 """Indicate a leaf."""
[docs]@dataclass class MapNode: """Partition line from (x,y) to (x+dx, y+dy).""" x: int y: int dx: int dy: int bbox: tuple[tuple[int, int], tuple[int, int], tuple[int, int], tuple[int, int]] """ Bounding box for each child, clip against view frustum. """ children: tuple[int, int] """ If NodeFlag.SUBSECTOR it's a subsector, else it's a node of another subtree. """
[docs]@dataclass class MapThing: """ Thing definition, position, orientation and type. Plus skill/visibility flags and attributes. """ x: int y: int angle: int kind: int options: int