# Utils

### Enum

Converts an enumeration type to its underlying integral type.

```cpp
template <typename Enum>
constexpr auto to_underlying(Enum e) -> typename std::underlying_type<Enum>::type {
    return static_cast<typename std::underlying_type<Enum>::type>(e);
}
```

### Struct Vec2

This structure provides a simple representation of 2D vectors, commonly used for positions, velocities, scales, etc., in a 2D space.

```cpp
struct Vec2 {
    float x = 0.0f; ///< The x component of the vector.
    float y = 0.0f; ///< The y component of the vector.

    /**
     * @brief Construct a new Vec2 object with default values.
     */
    Vec2() = default;

    /**
     * @brief Construct a new Vec2 object with specified x and y components.
     * 
     * @param x The x component of the vector.
     * @param y The y component of the vector.
     */
    Vec2(float x, float y) : x(x), y(y) {}
};
```

### Struct PlayerId

This structure encapsulates the identifier of a player along with their position in a 2D space.

```cpp
struct PlayerId {
    std::size_t id = 0; ///< The unique identifier of the player.
    Vec2 pos; ///< The 2D position of the player.

    /**
     * @brief Construct a new PlayerId object with an identifier and position.
     * 
     * @param id The unique identifier of the player.
     * @param pos The 2D position of the player.
     */
    PlayerId(std::size_t id, Vec2 pos) : id(id), pos(pos) {}
};
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://r-type-5.gitbook.io/r-type/development-guidelines/ecs/graphic/utils.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
