This commit is contained in:
Nikita Kruglickiy
2023-05-22 19:06:26 +03:00
parent 345e60cf1d
commit 09be0ea795
35 changed files with 1423 additions and 336 deletions

View File

@@ -1,10 +1,11 @@
-- @include ../gearboxes/manual.txt
require('../gearboxes/manual.txt')
-- require('../gearboxes/auto.txt')
-- require('../gearboxes/cvt.txt')
-- @include ../powertrain/gearboxes/manual.txt
GearboxFactory = class('GearboxFactory')
local ManualGearbox = require('../powertrain/gearboxes/manual.txt')
function GearboxFactory.create(...)
local GearboxFactory = class('GearboxFactory')
function GearboxFactory.static:create(...)
return ManualGearbox:new(...)
end
return GearboxFactory

View File

@@ -0,0 +1,34 @@
--@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