-- PowerTake.lua
--
-- Author Aluha74rus

-- 08.06.2020
--

PowerTake = {};

local PowerTake_directory = g_currentModDirectory;


function PowerTake.prerequisitesPresent(specializations)
    return true;
end


function PowerTake.registerEventListeners(vehicleType)	
	SpecializationUtil.registerEventListener(vehicleType, "onLoad", PowerTake);
	SpecializationUtil.registerEventListener(vehicleType, "onDelete", PowerTake)
	SpecializationUtil.registerEventListener(vehicleType, "onUpdate", PowerTake)
end
function PowerTake:onLoad(savegame)
    if self.isClient then
        self.vomAnimationNodes = g_animationManager:loadAnimations(self.xmlFile, "vehicle.turnOnVomK700.animationNodes", self.components, self, self.i3dMappings)
    end
end
function PowerTake:onDelete()
    if self.isClient then
        g_animationManager:deleteAnimations(self.vomAnimationNodes)
    end
end
function PowerTake:onUpdate(dt, isActiveForInput, isSelected)
    if self.isClient then
            for _, implement in pairs(self.spec_attacherJoints.attachedImplements) do
				if implement.object:getIsPowerTakeOffActive() then
                        g_animationManager:startAnimations(self.vomAnimationNodes)
                    else
                        g_animationManager:stopAnimations(self.vomAnimationNodes)
			    end;
		    end;
    end
end