--@include ../powertrain/engine.txt --@include ../powertrain/clutch.txt --@include ../powertrain/differential.txt --@include ../powertrain/wheel.txt --@include ./gearbox.txt --@include ../enums/powertrain_component.txt local Engine = require('../powertrain/engine.txt') local Clutch = require('../powertrain/clutch.txt') local Differential = require('../powertrain/differential.txt') local Wheel = require('../powertrain/wheel.txt') local GearboxFactory = require('./gearbox.txt') local POWERTRAIN_COMPONENT = require('../enums/powertrain_component.txt') local PowertrainComponentFactory = class('PowertrainComponentFactory') function PowertrainComponentFactory.static:create(vehicle, type, name, config) local args = { vehicle, name, config } if type == POWERTRAIN_COMPONENT.Engine then return Engine:new(unpack(args)) elseif type == POWERTRAIN_COMPONENT.Clutch then return Clutch:new(unpack(args)) elseif type == POWERTRAIN_COMPONENT.Gearbox then return GearboxFactory:create(unpack(args)) elseif type == POWERTRAIN_COMPONENT.Differential then return Differential:new(unpack(args)) elseif type == POWERTRAIN_COMPONENT.Wheel then return Wheel:new(unpack(args)) end end return PowertrainComponentFactory