#ifndef FLUID_WIRING_HPP_
#define FLUID_WIRING_HPP_

#include <memory>
#include <vector>

#include <WorldComponent/Wiring/Wiring.hpp>
#include <FluidLink/FluidLink.hpp>

/**
 * @brief Defines the fluid wiring system.
 */
class FluidWiring : public Wiring
{
private:
    std::vector<std::shared_ptr<FluidLink>> links;
    bool linksCreatedYet = false;

    void updateFrom(LocalWorld &world, std::shared_ptr<WorldGridNode> node, std::vector<Port> &ports);

public:
    static size_t compIndex;
    static std::string compName;

    /**
     * @brief Construct an fluid wiring node from serialized data.
     */
    FluidWiring(const uint8_t *data, size_t size);

    /**
     * @brief Get the fluid link, starting at the specified port.
     */
    std::shared_ptr<FluidLink> getLink(
        LocalWorld &world,
        glm::ivec3 pos,
        Side side
    );

    virtual void onMachinePortsChanged(LocalWorld &world, std::shared_ptr<WorldGridNode> node, std::vector<Port> &ports) override;
    virtual bool isWalkableBlock(LocalWorld &world, int id) override;
    virtual std::string getDumpDirName() override;
};

#endif