Continuing rewriting engine

This commit is contained in:
Ivan Grachyov
2021-11-12 00:29:52 +05:00
parent 902d2d18bb
commit 1650ac9a6d
9 changed files with 121 additions and 7 deletions

View File

@@ -27,7 +27,8 @@ function Engine:initialize(config, clutch)
self._fwInertia = self.flywheelMass * self.flywheelRadius ^ 2 / 2
self._limiterTime = 0
self._clutch = clutch
self.clutch = clutch
clutch.engine = self
end
function Engine:getInputs()
@@ -39,13 +40,13 @@ end
function Engine:getOutputs()
return {
RPM = 'number',
Torque = 'number'
Engine_Torque = 'number'
}
end
function Engine:updateOutputs()
wire.ports.RPM = self.rpm
wire.ports.Torque = self.torque
wire.ports.Engine_Torque = self.torque
end
function Engine:getThrottle()
@@ -77,7 +78,7 @@ function Engine:update()
local realInitialTorque = maxInitialTorque * masterThrottle
local loadTorque = self._clutch and self._clutch.torque or 0
local loadTorque = self.clutch and self.clutch.torque or 0
self.torque = realInitialTorque + self.friction