1
0
mirror of https://github.com/metrostroi-repo/MetrostroiAddon.git synced 2026-05-02 00:42:29 +00:00

release branch init

This commit is contained in:
g_brzhezinskiy
2021-01-02 15:32:05 +03:00
parent 1d05caf866
commit 09566ce158
398 changed files with 8389 additions and 77275 deletions

View File

@@ -90,6 +90,7 @@ function TRAIN_SYSTEM:Initialize(parameters)
self.Train:LoadSystem("AirDistributorDisconnect","Relay","Switch")
--УАВА
self.Train:LoadSystem("UAVA","Relay","Switch",{ bass = true})
self.Train:LoadSystem("UAVAContact","Relay","Switch")
self.Train:LoadSystem("UAVAC","Relay","",{normally_closed=true,bass=true})
--Стояночный тормоз
@@ -123,8 +124,6 @@ function TRAIN_SYSTEM:Initialize(parameters)
self.RightDoorDir = { 0,0,0,0 }
self.LeftDoorSpeed = {0,0,0,0}
self.RightDoorSpeed = {0,0,0,0}
self.LeftDoorStuck = {false, false, false, false}
self.RightDoorStuck = {false, false, false, false}
local start = math.Rand(0.6,0.8)
-- 0.6-1
self.DoorSpeedMain = -math.Rand(start,math.Rand(start+0.1,start+0.2))
@@ -354,7 +353,7 @@ function TRAIN_SYSTEM:Think(dT)
end
-- 013: 7 0.0 Atm
if (self.RealDriverValvePosition == 7) and BLDisconnect then
if (self.RealDriverValvePosition == 7) and BLDisconnect and TLDisconnect then
self:equalizePressure(dT,"BrakeLinePressure", 0.0, pr_speed)
end
trainLineConsumption_dPdT = trainLineConsumption_dPdT + math.max(0,self.BrakeLinePressure_dPdT)
@@ -399,12 +398,6 @@ function TRAIN_SYSTEM:Think(dT)
if (Train.UAVA.Blocked>0) ~= UAVABlocked then
Train.UAVA:TriggerInput("Block",UAVABlocked and 1 or 0)
end
local UAVACBlocked = self.EmergencyValve and not self.EmergencyValveDisable
if (Train.UAVAC.Blocked>0) ~= UAVACBlocked then
Train.UAVAC:TriggerInput("Block",UAVACBlocked and 1 or 0)
end
Train:SetPackedRatio("EmergencyValve_dPdT", -leak/wagc)
local leak = 0
@@ -482,6 +475,11 @@ function TRAIN_SYSTEM:Think(dT)
Train:PlayOnce("PN2end","stop")
end
if Train.UAVAContact.Value > 0.5 and Train.UAVAC.Value < 0.5 then
Train.UAVAC:TriggerInput("Set",1)
Train:PlayOnce("uava_reset","bass",1)
end
--Parking brake simulation
local PBPressure = math.Clamp(self.TrainLinePressure/5,0,1)*2.7
if Train.ParkingBrake.Value == 0 then
@@ -552,29 +550,14 @@ function TRAIN_SYSTEM:Think(dT)
if self.U2 ~= Train.U2.Value then
self.U2 = Train.U2.Value
self:equalizePressure(dT,"TrainLinePressure", 0.0, 0.3)
if self.VDLoud and self.U2 > 0 and not Train.LeftDoorsOpen then Train:PlayOnce("vdol_loud"..self.VDLoudID,"bass",self.VDLoud) end
end
if self.U3 ~= Train.U3.Value then
self.U3 = Train.U3.Value
self:equalizePressure(dT,"TrainLinePressure", 0.0, 0.3)
if self.VDLoud and self.U3 > 0 and not Train.RightDoorsOpen then Train:PlayOnce("vdop_loud"..self.VDLoudID,"bass",self.VDLoud) end
end
if self.U1 ~= Train.U1.Value then
self.U1 = Train.U1.Value
self:equalizePressure(dT,"TrainLinePressure", 0.0, 0.3)
if self.VDLoud and self.U1 > 0 and (Train.RightDoorsOpen or Train.LeftDoorsOpen) then Train:PlayOnce("vzd_loud"..self.VDLoudID,"bass",self.VDLoud) end
end
if Train.CanStuckPassengerLeft then
for i in ipairs(self.LeftDoorStuck) do
self.LeftDoorStuck[i] = math.random() < (0.6+math.min(2,2-self.LeftDoorSpeed[i])*0.2)*Train.CanStuckPassengerLeft*0.6 and (math.random() > 0.7 and CurTime()+math.random()*15)
end
Train.CanStuckPassengerLeft = false
end
if Train.CanStuckPassengerRight then
for i in ipairs(self.RightDoorStuck) do
self.RightDoorStuck[i] = math.random() < (0.6+math.min(2,2-self.LeftDoorSpeed[i])*0.2)*Train.CanStuckPassengerRight*0.6 and (math.random() > 0.7 and CurTime()+math.random()*15)
end
Train.CanStuckPassengerRight = false
end
@@ -585,9 +568,9 @@ function TRAIN_SYSTEM:Think(dT)
for i=1,4 do
self.LeftDoorDir[i] = math.Clamp(self.LeftDoorDir[i]+dT/(self.DoorLeft and self.LeftDoorSpeed[i] or -self.LeftDoorSpeed[i]),-1,1)
self.RightDoorDir[i] = math.Clamp(self.RightDoorDir[i]+dT/(self.DoorRight and self.RightDoorSpeed[i] or -self.RightDoorSpeed[i]),-1,1)
self.LeftDoorState[i] = math.Clamp(self.LeftDoorState[i] + ((self.LeftDoorDir[i]/self.LeftDoorSpeed[i])*dT),self.LeftDoorStuck[i] and 0.3 or 0,1)
self.LeftDoorState[i] = math.Clamp(self.LeftDoorState[i] + ((self.LeftDoorDir[i]/self.LeftDoorSpeed[i])*dT),0,1)
if self.LeftDoorState[i] == 0 or self.LeftDoorState[i] == 1 then self.LeftDoorDir[i] = 0 end
self.RightDoorState[i] = math.Clamp(self.RightDoorState[i] + ((self.RightDoorDir[i]/self.RightDoorSpeed[i])*dT),self.RightDoorStuck[i] and 0.3 or 0,1)
self.RightDoorState[i] = math.Clamp(self.RightDoorState[i] + ((self.RightDoorDir[i]/self.RightDoorSpeed[i])*dT),0,1)
if self.RightDoorState[i] == 0 or self.RightDoorState[i] == 1 then self.RightDoorDir[i] = 0 end
if not Train.LeftDoorsOpen and self.LeftDoorState[i] > 0 then
Train.LeftDoorsOpen = true
@@ -601,14 +584,6 @@ function TRAIN_SYSTEM:Think(dT)
end
Train:SetPackedRatio("DoorL"..i,self.LeftDoorState[i])
Train:SetPackedRatio("DoorR"..i,self.RightDoorState[i])
if self.LeftDoorStuck[i] and (self.DoorLeft or type(self.LeftDoorStuck[i]) == "number" and CurTime()-self.LeftDoorStuck[i] > 0) then
self.LeftDoorStuck[i] = false
end
if self.RightDoorStuck[i] and (self.DoorRight or type(self.RightDoorStuck[i]) == "number" and CurTime()-self.RightDoorStuck[i] > 0) then
self.RightDoorStuck[i] = false
end
Train:SetPackedBool("DoorLS"..i,self.LeftDoorStuck[i])
Train:SetPackedBool("DoorRS"..i,self.RightDoorStuck[i])
end
if openL and not self.OpenWaitL then self.OpenWaitL = CurTime() end
if openR and not self.OpenWaitR then self.OpenWaitR = CurTime() end