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

@@ -63,6 +63,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})
--ЭПК
self.Train:LoadSystem("EPK","Relay","Switch",{ bass = true})
@@ -101,8 +102,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))
@@ -124,9 +123,6 @@ function TRAIN_SYSTEM:Initialize(parameters)
self.OldValuePos = self.DriverValvePosition
self.WeightLoadRatio = 0--math.max(0,math.min(1,(self.Train:GetNW2Float("PassengerCount",0)/200)))
self.HaveUAVA = not self.Train.SubwayTrain or not self.Train.SubwayTrain.ARS or not self.Train.SubwayTrain.ARS.NoUAVA
self.HaveEPK = not self.Train.SubwayTrain or not self.Train.SubwayTrain.ARS or not self.Train.SubwayTrain.ARS.NoEPK
end
function TRAIN_SYSTEM:Inputs()
@@ -150,7 +146,8 @@ function TRAIN_SYSTEM:TriggerInput(name,value)
elseif name == "ValveType" then
self.ValveType = math.floor(value)
elseif name == "Autostop" then
if self.HaveUAVA and self.Train.UAVA.Value == 0 then
local HaveUAVA = not self.Train.SubwayTrain or not self.Train.SubwayTrain.ARS or not self.Train.SubwayTrain.ARS.NoUAVA
if HaveUAVA and self.Train.UAVA.Value == 0 then
self.EmergencyValve = true
self.Train.UAVAC:TriggerInput("Set",0)
if value > 0 then RunConsoleCommand("say","Autostop braking",self.Train:GetDriverName()) end
@@ -355,10 +352,11 @@ function TRAIN_SYSTEM:Think(dT)
if BLDisconnect then
--print(self.BrakeLinePressure_dPdT,self.ReservoirPressure_dPdT,self.TrainLinePressure)
end
local HaveEPK = not Train.SubwayTrain or not Train.SubwayTrain.ARS or not Train.SubwayTrain.ARS.NoEPK
local leak
local pr_speed = 1.25*wagc
if self.HaveEPK and Train.EPKC then
if HaveEPK and Train.EPKC then
local leak = 0
local epkDiff = math.abs(self.EPKPressure-self.BrakeLinePressure)
if BLDisconnect and Train.EPK.Value>0 then
@@ -383,10 +381,6 @@ function TRAIN_SYSTEM:Think(dT)
self.EmergencyValveDisable=false
self.EmergencyValve=false
end
if Train.UKS and Train.UKS.UKSEmerTriggered > 0 and Train.UKSDisconnect.Value > 0 then
self.EmergencyValve=true
end
self.OldBrakeLinePressure = self.BrakeLinePressure
if self.EmergencyValve then
local leakst = 1.1*(Train:GetWagonCount())*math.Clamp(self.BrakeLinePressure/4,0,1)
@@ -400,12 +394,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
@@ -483,6 +471,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
-- Simulate cross-feed between different wagons
self:UpdatePressures(Train,dT)
@@ -519,9 +512,11 @@ function TRAIN_SYSTEM:Think(dT)
if self.DoorLinePressure > 3.5 then
if (Train.VDOL.Value == 1.0) and (Train.VDOP.Value == 0.0) and not self.DoorLeft then
self.DoorLeft = true
if self.VDOLLoud then Train:PlayOnce("vdol_loud","cabin",0.8+math.random()*0.2,self.VDOLLoud) end
end
if (Train.VDOL.Value == 0.0) and (Train.VDOP.Value == 1.0) and not self.DoorRight then
self.DoorRight = true
if self.VDORLoud then Train:PlayOnce("vdop_loud","cabin",0.8+math.random()*0.2,self.VDORLoud) end
end
if (Train.VDZ.Value == 1.0 or Train.VDOL.Value == 1.0 and Train.VDOP.Value == 1.0 or self.RZDTimer) and (self.DoorLeft or self.DoorRight) then
if not self.OpenWaitL or CurTime()-self.OpenWaitL < 0.2 then
@@ -542,29 +537,14 @@ function TRAIN_SYSTEM:Think(dT)
if self.VDOL ~= Train.VDOL.Value then
self.VDOL = Train.VDOL.Value
self:equalizePressure(dT,"TrainLinePressure", 0.0, 0.3)
if self.VDLoud and self.VDOL > 0 and not Train.LeftDoorsOpen then Train:PlayOnce("vdol_loud"..self.VDLoudID,"bass",self.VDLoud) end
end
if self.VDOP ~= Train.VDOP.Value then
self.VDOP = Train.VDOP.Value
self:equalizePressure(dT,"TrainLinePressure", 0.0, 0.3)
if self.VDLoud and self.VDOP > 0 and not Train.RightDoorsOpen then Train:PlayOnce("vdop_loud"..self.VDLoudID,"bass",self.VDLoud) end
end
if self.VDZ ~= Train.VDZ.Value then
self.VDZ = Train.VDZ.Value
self:equalizePressure(dT,"TrainLinePressure", 0.0, 0.3)
if self.VDLoud and self.VDZ > 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
@@ -575,9 +555,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
@@ -591,14 +571,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