Ejemplo n.º 1
0
    private WallTex ParseWallTex(string name, Tokenizer levelTokens, bool trailing)
    {
        levelTokens.EnsureNextToken(name);

        WallTex tex = new WallTex();

        tex.Texture = levelTokens.RequireNextInt();
        tex.ShiftX = levelTokens.RequireNextFloat();
        tex.ShiftY = levelTokens.RequireNextFloat();

        if (trailing) {
            levelTokens.RequireNextInt();
        }

        return tex;
    }
Ejemplo n.º 2
0
    private void ParseHeader(Tokenizer levelTokens)
    {
        levelTokens.EnsureNextToken("LEV");
        levelTokens.RequireNextToken(); // skip version.

        levelTokens.EnsureNextToken("LEVELNAME");
        _name = levelTokens.RequireNextToken();

        levelTokens.EnsureNextToken("PALETTE");
        _pal = levelTokens.RequireNextToken();

        levelTokens.EnsureNextToken("MUSIC");
        _music = levelTokens.RequireNextToken();

        levelTokens.EnsureNextToken("PARALLAX");
        _parallax.x = levelTokens.RequireNextFloat();
        _parallax.y = levelTokens.RequireNextFloat();
    }
Ejemplo n.º 3
0
    private Wall ParseWall(Tokenizer levelTokens)
    {
        levelTokens.EnsureNextToken("WALL");

        Wall wall = new Wall();

        levelTokens.EnsureNextToken("LEFT:");
        wall.V0 = levelTokens.RequireNextInt();
        levelTokens.EnsureNextToken("RIGHT:");
        wall.V1 = levelTokens.RequireNextInt();

        wall.TexMid = ParseWallTex("MID:", levelTokens, true);
        wall.TexTop = ParseWallTex("TOP:", levelTokens, true);
        wall.TexBottom = ParseWallTex("BOT:", levelTokens, true);
        wall.TexSign = ParseWallTex("SIGN:", levelTokens, false);

        levelTokens.EnsureNextToken("ADJOIN:");
        wall.Adjoin = levelTokens.RequireNextInt();

        levelTokens.EnsureNextToken("MIRROR:");
        wall.Mirror = levelTokens.RequireNextInt();

        levelTokens.EnsureNextToken("WALK:");
        wall.Walk = levelTokens.RequireNextInt();

        levelTokens.EnsureNextToken("FLAGS:");
        wall.Flags0 = (Wall.EFlags0)levelTokens.RequireNextInt();
        wall.Flags1 = levelTokens.RequireNextInt();
        wall.Flags2 = (Wall.EFlags2)levelTokens.RequireNextInt();

        levelTokens.EnsureNextToken("LIGHT:");
        wall.Light = levelTokens.RequireNextInt();

        return wall;
    }
Ejemplo n.º 4
0
    private void ParseTextures(Tokenizer levelTokens)
    {
        levelTokens.EnsureNextToken("TEXTURES");
        levelTokens.RequireNextInt();

        while (true) {
            if (levelTokens.IsNextToken("NUMSECTORS")) {
                levelTokens.RequireNextInt(); // eat sector count.
                break;
            }

            string texture = levelTokens.GetNextToken();
            _textures.Add(texture);
        }
    }
Ejemplo n.º 5
0
    private void ParseSectorWalls(Sector sector, Tokenizer levelTokens)
    {
        levelTokens.EnsureNextToken("WALLS");

        int numWalls = levelTokens.RequireNextInt();

        for (int i = 0; i < numWalls; ++i) {
            Wall wall = ParseWall(levelTokens);
            if ((wall.Light + sector.Ambient) > 31) {
                wall.Light = 31 - sector.Ambient;
            } else if ((wall.Light + sector.Ambient) < 0) {
                wall.Light = -sector.Ambient;
            }

            sector.Walls.Add(wall);
        }
    }
Ejemplo n.º 6
0
    private void ParseSectorVertices(Sector sector, Tokenizer levelTokens)
    {
        levelTokens.EnsureNextToken("VERTICES");

        int numVerts = levelTokens.RequireNextInt();

        for (int i = 0; i < numVerts; ++i) {
            Vector2 v;

            levelTokens.EnsureNextToken("X:");
            v.x = levelTokens.RequireNextFloat();
            levelTokens.EnsureNextToken("Z:");
            v.y = levelTokens.RequireNextFloat();

            sector.Vertices.Add(v);
        }
    }
Ejemplo n.º 7
0
    private Sector ParseSectorHeader(Tokenizer levelTokens)
    {
        Sector sector = new Sector();

        levelTokens.EnsureNextToken("NAME");
        string sectorName = levelTokens.GetNextToken();

        if (sectorName != "AMBIENT") {
            sector.Name = sectorName;
        } else { // unnamed sector
            levelTokens.UngetToken();
        }

        levelTokens.EnsureNextToken("AMBIENT");
        sector.Ambient = levelTokens.RequireNextInt();

        levelTokens.EnsureNextToken("FLOOR");
        levelTokens.EnsureNextToken("TEXTURE");
        sector.FloorTex = levelTokens.RequireNextInt();
        sector.FloorShiftX = levelTokens.RequireNextFloat();
        sector.FloorShiftZ = levelTokens.RequireNextFloat();
        levelTokens.RequireNextInt();

        levelTokens.EnsureNextToken("FLOOR");
        levelTokens.EnsureNextToken("ALTITUDE");
        sector.FloorAlt = -levelTokens.RequireNextFloat();

        levelTokens.EnsureNextToken("CEILING");
        levelTokens.EnsureNextToken("TEXTURE");
        sector.CeilTex = levelTokens.RequireNextInt();
        sector.CeilShiftX = levelTokens.RequireNextFloat();
        sector.CeilShiftZ = levelTokens.RequireNextFloat();
        levelTokens.RequireNextInt();

        levelTokens.EnsureNextToken("CEILING");
        levelTokens.EnsureNextToken("ALTITUDE");
        sector.CeilAlt = -levelTokens.RequireNextFloat();

        levelTokens.EnsureNextToken("SECOND");
        levelTokens.EnsureNextToken("ALTITUDE");
        sector.SecondAlt = -levelTokens.RequireNextFloat();

        levelTokens.EnsureNextToken("FLAGS");
        sector.Flags0 = (Sector.EFlags0)levelTokens.RequireNextInt();
        sector.Flags1 = levelTokens.RequireNextInt();
        sector.Flags2 = levelTokens.RequireNextInt();

        levelTokens.EnsureNextToken("LAYER");
        sector.Layer = levelTokens.RequireNextInt();

        return sector;
    }