--
-- Author: E.T.A La Marchoise
-- Date: 08-10-22
-- Version: 1.0.0.0
-- Copyright (C) E.T.A La Marchoise, All Rights Reserved
-- ExtendedCultivator.lua
--

ExtendedCultivator = {};
ExtendedCultivator.MOD_NAME = g_currentModName;

function ExtendedCultivator.prerequisitesPresent(specializations)
    return SpecializationUtil.hasSpecialization(MultiVineBaseDetector, specializations) and SpecializationUtil.hasSpecialization(Cultivator, specializations);
end

function ExtendedCultivator.initSpecialization()
end

function ExtendedCultivator.registerFunctions(vehicleType)
    --SpecializationUtil.registerFunction(vehicleType, "vineRaycastCallback", ExtendedCultivator.vineRaycastCallback)
end

function ExtendedCultivator.registerOverwrittenFunctions(vehicleType)
    SpecializationUtil.registerOverwrittenFunction(vehicleType, "getCanStartVineDetection", ExtendedCultivator.getCanStartVineDetection)
end

function ExtendedCultivator.registerEventListeners(vehicleType)
    SpecializationUtil.registerEventListener(vehicleType, "onPreLoad", ExtendedCultivator);
end

function ExtendedCultivator:onPreLoad(savegame)
    self.spec_extendedCultivator = self[("spec_%s.extendedCultivator"):format(ExtendedCultivator.MOD_NAME)];
end

function ExtendedCultivator:getCanStartVineDetection(superFunc)
    return superFunc(self) and (self.movingDirection > 0 and (self.getIsCultivationEnabled ~= nil and self:getIsCultivationEnabled()) and (self.getIsUnfolded ~= nil and self:getIsUnfolded()));
end