<?php

namespace Doom\Wad\Types;

use Doom\Picture\Picture;
use Doom\Picture\PictureParser;
use Doom\Texture\PNamesParser;
use Doom\Texture\TextureX;
use Doom\Texture\TextureXParser;

final class Lump
{
    public function __construct(
        public readonly int $offset,
        public readonly int $size,
        public readonly string $name,
        private readonly string $data,
        public readonly int $index,
    ) {}

    public function data(): string
    {
        return $this->data;
    }

    public function asPicture(): Picture
    {
        return PictureParser::parseBytes($this->data);
    }

    public function asTextureX(): TextureX
    {
        return TextureXParser::parseBytes($this->data);
    }

    /**
     * @return string[]
     */
    public function asPNames(): array
    {
        return PNamesParser::parseBytes($this->data);
    }
}
