mirror of
https://github.com/metrostroi-repo/MetrostroiAddon.git
synced 2026-05-02 00:42:29 +00:00
Оптимизация.
В gmod_subway_base добавлена переменная self.WagonCount и заменены везде на неё, где используется #self.WagonList. В 81-501 убран лишний цикл 18 провода. В БУВ 81-720 и 81-722 убрана неиспользуемая локальная переменная В sys_81_71_announcer добавленая локальная переменная для self.Train там где это релевантно, убраны лишние локальные перменные.
This commit is contained in:
@@ -360,7 +360,7 @@ function ENT:Think()
|
||||
--10th wire voltage readout imitation depending on the BPSNs and EKK state, not on the wagon battery switch state
|
||||
local hvcounter = 0
|
||||
local hvcar = nil
|
||||
local vdrop = 1.125*(#self.WagonList)
|
||||
local vdrop = 1.125*(self.WagonCount)
|
||||
for k,v in ipairs(self.WagonList) do
|
||||
if v.PowerSupply.X2_2 > 0 and v.A24.Value > 0 then
|
||||
hvcounter = hvcounter + 1
|
||||
@@ -372,9 +372,9 @@ function ENT:Think()
|
||||
end
|
||||
local PCV_o = hvcounter > 0 and math.Clamp(76+(hvcar.Electric.Aux750V - 600)*8/375, 76, 84) - vdrop or self.WagonList[1].Battery.Voltage
|
||||
--imitating converter overload protection only when control circuits are energized and at least one PC on the train is off; pretty useless btw (but fun)
|
||||
local pcloadratio = #self.WagonList/(hvcounter > 0 and hvcounter or 0.5)
|
||||
local pcloadratio = self.WagonCount/(hvcounter > 0 and hvcounter or 0.5)
|
||||
local _A = 25*(6 - 6/(5.01)) --assuming one PC on 6 cars can work for 25 secs while the cars' CCs are energized
|
||||
if pcloadratio > 1 and pcloadratio <= #self.WagonList and self.LK4.Value > 0 and self.PowerSupply.X2_2 > 0 and not self.pcrlxtimer then
|
||||
if pcloadratio > 1 and (pcloadratio <= self.WagonCount) and self.LK4.Value > 0 and self.PowerSupply.X2_2 > 0 and not self.pcrlxtimer then
|
||||
self.pcprotimer = self.pcprotimer or CurTime()
|
||||
--hyperbolic function of PC operating time depending on load coeff
|
||||
if CurTime() - self.pcprotimer > _A/(pcloadratio - 6/5.01) then
|
||||
|
||||
Reference in New Issue
Block a user