Implemented engine
This commit is contained in:
@@ -1,18 +1,20 @@
|
||||
Gearbox = class("Gearbox")
|
||||
|
||||
function Gearbox:initialize(options)
|
||||
options = options or {}
|
||||
options = options or {}
|
||||
|
||||
self.ratios = options.ratios
|
||||
self.finalDrive = options.finalDrive
|
||||
self.ratios = options.Ratios
|
||||
self.finalDrive = options.FinalDrive
|
||||
self.reverse = options.Reverse
|
||||
|
||||
self._linkedDiffs = {}
|
||||
self.gear = 0
|
||||
|
||||
self.gear = 0
|
||||
self._linkedDiffs = {}
|
||||
self._clutch = nil
|
||||
end
|
||||
|
||||
function Gearbox:linkDiff(diff)
|
||||
table.insert(self._linkedDiffs, diff)
|
||||
table.insert(self._linkedDiffs, diff)
|
||||
end
|
||||
|
||||
function Gearbox:shift(dir)
|
||||
@@ -20,9 +22,16 @@ function Gearbox:shift(dir)
|
||||
end
|
||||
|
||||
function Gearbox:setGear(gear)
|
||||
self.gear = gear
|
||||
if gear >= -1 and gear <= #self.ratios then
|
||||
self.gear = gear
|
||||
end
|
||||
end
|
||||
|
||||
function Gearbox:linkClutch(clutch)
|
||||
self._clutch = clutch
|
||||
clutch:linkGearbox(self)
|
||||
end
|
||||
|
||||
function Gearbox:update()
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -1,4 +1,10 @@
|
||||
-- @include ./base.txt
|
||||
require("./base.txt")
|
||||
|
||||
CVT = class("CVT")
|
||||
CVT = class("CVT")
|
||||
|
||||
function CVT:initialize(options)
|
||||
options = options or {}
|
||||
|
||||
self.base = Gearbox:new(options)
|
||||
end
|
||||
|
||||
@@ -4,7 +4,14 @@ require("./base.txt")
|
||||
ManualGearbox = class("ManualGearbox")
|
||||
|
||||
function ManualGearbox:initialize(options)
|
||||
-- create base gearbox inside
|
||||
options = options or {}
|
||||
|
||||
-- might want to segregate construction options for base gearbox
|
||||
self.base = Gearbox:new(options)
|
||||
end
|
||||
|
||||
-- proxy the methods here
|
||||
function ManualGearbox:linkClutch(clutch)
|
||||
return self.base:linkClutch(clutch)
|
||||
end
|
||||
|
||||
-- proxy the methods here
|
||||
|
||||
Reference in New Issue
Block a user