<?php

namespace Doom\Texture;

final class TextureX
{
    /**
     * @param int[] $offsets
     * @param TextureDefinition[] $textures
     */
    public function __construct(
        public readonly int $numTextures,
        public readonly array $offsets,
        public readonly array $textures,
    ) {}

    public function firstTextureByName(string $name): ?TextureDefinition
    {
        $name = strtoupper($name);

        foreach ($this->textures as $texture) {
            if ($texture->name === $name) {
                return $texture;
            }
        }

        return null;
    }
}
