WaterConsumer = {}

function WaterConsumer.prerequisitesPresent(specializations)
    return SpecializationUtil.hasSpecialization(TurnOnVehicle, specializations)
        and SpecializationUtil.hasSpecialization(FillUnit, specializations)
end

function WaterConsumer.registerEventListeners(vehicleType)
    SpecializationUtil.registerEventListener(vehicleType, "onUpdate", WaterConsumer)
end

function WaterConsumer:onUpdate(dt)
    if not self:getIsTurnedOn() then
        return
    end

    self.waterUsageTimer = (self.waterUsageTimer or 0) + dt

    if self.waterUsageTimer > 1000 then -- alle 1 Sekunde
        local usage = 5 -- 10 ml
        local fillUnitIndex = 2 -- Index deines Wasser-Tanks (anpassen falls notwendig)

        self:addFillUnitFillLevel(
            self:getOwnerFarmId(),
            fillUnitIndex,
            -usage,
            FillType.WATER,
            ToolType.UNDEFINED,
            nil
        )

        self.waterUsageTimer = 0
    end
end