AsphaltProducer = {}

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

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

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

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

    if self.asphaltFillTimer > 1000 then -- alle 1 Sekunde
        local amount = 120 -- 10 Liter pro Sekunde
        local fillUnitIndex = 4 -- Ziel-FillUnit für Asphalt

        self:addFillUnitFillLevel(
            self:getOwnerFarmId(),
            fillUnitIndex,
            amount,
            FillType.ASPHALT,
            ToolType.UNDEFINED,
            nil
        )

        self.asphaltFillTimer = 0
    end
end
