#include <Machine/MIndicatorLights/MIndicatorLights.hpp>
#include <Serialize/Serialize.hpp>
#include <FuelRuleRegistry/FuelRuleRegistry.hpp>
#include <World/LocalWorld/LocalWorld.hpp>
#include <Block/Block.hpp>
#include <SmeltingRuleRegistry/SmeltingRuleRegistry.hpp>
#include <MachineComponent/DataCableComponent/DataCableComponent.hpp>

MIndicatorLights::MIndicatorLights(LocalWorld &world, glm::ivec3 pos) : Machine(world, pos)
{
    attach<DataCableComponent>();
}

void MIndicatorLights::serializeState(std::vector<uint8_t> &outBytes)
{
    // NOP
}

void MIndicatorLights::deserializeState(const uint8_t *data, size_t size)
{
    // NOP
}

void MIndicatorLights::update()
{
    uint8_t currentMeta = *m_world.getBlockMeta(pos);
    uint8_t newMeta = getComponent<DataCableComponent>().getLastKnownInputs().unpack();

    if (newMeta != currentMeta)
    {
        m_world.setBlockMeta(pos, newMeta);
    }
}

Side MIndicatorLights::getDataInputSide()
{
    return Side::Bottom;
}