#ifndef BELT_VIEW_HPP_
#define BELT_VIEW_HPP_

#include <Belt/Belt.hpp>
#include <Frustum/Frustum.hpp>
#include <Item/Item.hpp>
#include <Serialize/Serialize.hpp>

#include <cstdint>

/**
 * @brief Represents the drawable state of a belt.
 */
class BeltView
{
private:
    uint64_t advanceCounter = 0;
    uint32_t lastBeltBlockLength = 0;
    glm::ivec3 lastKnownStartPos = glm::ivec3(0);

public:
    Belt state;
    bool isActive;

    /**
     * @brief Try advancing the belt in the view.
     */
    void advance();

    /**
     * @brief Returns true if we need to be updated against the specified state.
     */
    bool needsUpdate(const Belt& belt, bool isActive) const;

    /**
     * @brief Draw the belt.
     */
    void draw(WorldDisplay &worldDisplay, const Frustum &viewingFrustum);

    /**
     * @brief Update the SVO with the next animation frame.
     */
    void updateAnimation(WorldDisplay &worldDisplay, const Frustum &viewingFrustum, uint32_t spriteId);
};

DERIVE_STRUCT_SERIALIZER(
    BeltView,
    self.state,
    self.isActive
);

#endif