from dataclasses import dataclass
from typing import TYPE_CHECKING


if TYPE_CHECKING:
    from ..context import ParsingContext


@dataclass
class SkyboxSettings:
    asset_name = "SkyboxSettings"

    version: int
    position: tuple[float, float, float]
    scale: float
    rotation: float
    texture_scheme: str
    start_pos: int
    end_pos: int

    @classmethod
    def parse(cls, context: "ParsingContext"):
        with context.read_asset() as asset_ctx:
            position = context.stream.readVector3()
            scale = context.stream.readFloat()
            rotation = context.stream.readFloat()
            texture_scheme = context.stream.readUInt16PrefixedAsciiString()

        return cls(version=asset_ctx.version, position=position, scale=scale, rotation=rotation, texture_scheme=texture_scheme, start_pos=asset_ctx.start_pos, end_pos=asset_ctx.end_pos)
